Public statistics API¶
Overview¶
The /api/stats endpoint returns public statistics on oriented visitors: visitors who viewed a product page or performed a search on the map.
Data is aggregated from PostHog according to the requested periodicity.
Endpoint¶
GET /api/stats
Query parameters¶
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
No |
|
KPI grouping granularity. Allowed values: |
|
integer |
No |
|
Number of period iterations to include (e.g. |
Request examples¶
Monthly statistics (default)¶
GET /api/stats
Last 30 days statistics¶
GET /api/stats?periodicity=day&since=30
Last 12 months statistics¶
GET /api/stats?periodicity=month&since=12
Last 4 weeks statistics¶
GET /api/stats?periodicity=week&since=4
Response¶
Format¶
{
"description": "Oriented visitors: visitors who viewed a product page or performed a search on the map",
"stats": [
{
"date": 1704067200,
"iso_date": "2024-01-01T00:00:00+00:00",
"value": 1234
},
{
"date": 1704153600,
"iso_date": "2024-01-02T00:00:00+00:00",
"value": 1456
}
]
}
Response fields¶
Field |
Type |
Description |
|---|---|---|
|
string |
Description of the returned metric |
|
array |
List of data points, sorted by ascending date |
|
integer |
Unix timestamp (seconds) for the start of the period |
|
string |
ISO 8601 date for the start of the period (UTC) |
|
float |
Number of oriented visitors for this period |
Interactive documentation¶
This API route can be tested at /api/docs, which provides an interactive Swagger/OpenAPI interface to try the endpoint directly from the browser.
Technical notes¶
Data is fetched from PostHog via the Query API
Dates are normalized to the start of the requested period (e.g. start of month for
month)If communication with PostHog fails, the API returns an HTTP 502 error
The
sinceparameter limits the time range of returned data (e.g.since=30withperiodicity=dayreturns the last 30 days)