Documentation · API reference
GET
/api/v1/sites/{site}/statsFigures for a period
This page as Markdown, or in an AI chatMore ways to read this page
Metrics for a site, optionally broken down by one dimension, filtered, and compared with another period.
# Figures for a period
> tidekeeper's API reference: https://tidekeeper.eu/docs/api/get-sites-site-stats
`GET /api/v1/sites/{site}/stats`
Metrics for a site, optionally broken down by one dimension, filtered, and compared with another period.
## Parameters
- `site` (in path, needed): A site's id or name
- `period` (in query): `today`, `yesterday`, `7d`, `30d`, `month`, `year`, `all`, a date, or two dates with `..` between
- `metrics` (in query): Comma-separated metric names. `visitors,views` when left out
- `by` (in query): A dimension to break down by
- `filter` (in query): `dim:op:value`, repeatable. `op` is `is`, `is_not`, `contains` or `matches`
- `compare` (in query): `previous`, `year`, or a period
- `limit` (in query): Most rows wanted
- `goal` (in query): For the goal metrics
## The answer
200, `StatsResponse`
- `by` (string or null)
- `caveats` (list of CaveatView, needed)
- `compare` (PeriodView or null)
- `metrics` (list of string, needed)
- `period` (PeriodView, needed)
- `previous_totals` (list of number or null or null)
- `rows` (list of StatRow, needed)
- `site` (string, needed)
- `totals` (list of number or null, needed)
## Asking
```sh
curl -G https://tidekeeper.eu/api/v1/sites/example.org/stats \
-H "Authorization: Bearer $TIDEKEEPER_TOKEN" \
-d metrics=visitors,views -d by=source -d period=7d
```
Parameters
- sitein the address
- neededA site's id or name
- periodin the query
- `today`, `yesterday`, `7d`, `30d`, `month`, `year`, `all`, a date, or two dates with `..` between
- metricsin the query
- Comma-separated metric names. `visitors,views` when left out
- byin the query
- A dimension to break down by
- filterin the query
- `dim:op:value`, repeatable. `op` is `is`, `is_not`, `contains` or `matches`
- comparein the query
- `previous`, `year`, or a period
- limitin the query
- Most rows wanted
- goalin the query
- For the goal metrics
The answer
Status 200
StatsResponse
- by
- string or null
- caveats
- list of CaveatViewneeded
- compare
- PeriodView or null
- metrics
- list of stringneeded
- period
- PeriodViewneeded
- previous_totals
- list of number or null or null
- rows
- list of StatRowneeded
- site
- stringneeded
- totals
- list of number or nullneeded
Asking
curl -G https://tidekeeper.eu/api/v1/sites/example.org/stats \ -H "Authorization: Bearer $TIDEKEEPER_TOKEN" \ -d metrics=visitors,views -d by=source -d period=7d
const answer = await fetch("https://tidekeeper.eu/api/v1/sites/example.org/stats?metrics=visitors,views&by=source&period=7d", { headers: { Authorization: `Bearer ${process.env.TIDEKEEPER_TOKEN}`, }, }).then((r) => r.json());