Get traffic
Read traffic totals, time series, and reports for pages, referrers, campaigns, devices, or countries.
Request
/api/v1/stats/trafficCall this endpoint from your server with a website-scoped Stats API bearer key. Follow Get started to create a key. The key selects your website; do not send a website ID.
Query parameters
| Parameter | Accepted values |
|---|---|
days | 1, 7, 30, or 90. Defaults to 30. Use this or a pair of explicit dates. |
startDate | Inclusive UTC date in YYYY-MM-DD format. Requires endDate. |
endDate | Inclusive UTC date in YYYY-MM-DD format. Requires startDate. |
interval | hourly or daily. Defaults to hourly for days=1, otherwise daily. |
section | summary (default), pages, referrers, campaigns, devices, or countries. |
Explicit ranges cover up to 365 days through today. Hourly ranges cover at most seven days. Do not combine days with explicit dates. Unknown or repeated parameters return 400 INVALID_QUERY.
Response
A successful response contains data with the report and meta.generatedAt and meta.expiresAt with its cache timestamps. The report contains these fields:
period- The reporting interval, UTC boundaries, and calculation time.
section- The requested summary or dimension report.
summary, previous- Traffic totals for the current and previous period when section=summary.
series- The traffic time series when section=summary.
rows, metric, limit- Up to ten aggregate rows for a dimension report. Pages count pageviews; other dimensions count session entries.
Matching reports are cached for 900 seconds. Each key allows 60 requests per minute, including cache hits. Read the shared freshness and limits and errors and retries before integrating. An empty report is a successful response; a failed calculation returns an error.