PureStats documentation

Stats API

Read a PureStats site's totals, time series, breakdowns, realtime, Web Vitals, experiments, ecommerce and site search from your own scripts with a site API key.

The Stats API returns the numbers behind a site's reports as JSON. It is read-only and works with a site API key.

Create a key

Open Site settings → API keys, enter a name and choose the access:

  • Read reports for the Stats API.
  • Read reports and add deployment annotations if the same key should also create deployment markers.

The key is shown once. Store it in your secret manager. A key works for its own site only; to rotate it, create a replacement, update your scripts and revoke the old key.

Authentication

Send the key in the X-API-Key header and the site's ID as site_id:

curl "https://purestats.io/api/stats/aggregate?site_id=123&period=28d" \
  -H "X-API-Key: $PURESTATS_API_KEY"

Each key can make 120 requests per minute from one address. A missing or unknown key gets 401, a key for another site 403, and too many requests 429 with Retry-After.

Common parameters

Parameter Values
site_id The site's ID, required.
period today, yesterday, 7d (default), 28d, 91d, month, last_month, 12m, year, all or custom.
from, to Dates as YYYY-MM-DD, with period=custom.
traffic human, all, bot, ai, spam or suspicious. Without it, the site's default applies.

Endpoints

Endpoint Returns
GET /api/stats/aggregate Totals for the period.
GET /api/stats/timeseries One metric (visitors, visits, pageviews, bounce_rate, visit_duration) per interval (minute, hour, day, week, month).
GET /api/stats/breakdown Top values of a property (pages, referrers, countries, devices, browsers, os), up to limit rows (1–500, default 100).
GET /api/stats/realtime Activity in the last 30 minutes.
GET /api/stats/web-vitals Web Vitals percentiles.
GET /api/stats/experiments Results of the experiment you name.
GET /api/stats/commerce Revenue and orders, optionally for one currency.
GET /api/stats/custom-dimensions Active custom dimensions and their most common values.
GET /api/stats/site-search Search terms, up to limit rows.

Avoid the api_key query parameter, which the API also accepts: addresses with keys end up in logs and browser histories.