Skip to content
Documentation
Stats API

Get traffic

Read traffic totals, time series, and reports for pages, referrers, campaigns, devices, or countries.

Request

GET/api/v1/stats/traffic

Call 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.

request.sh
curl 'https://talvess.vercel.app/api/v1/stats/traffic?days=7&section=summary' \
  -H "Authorization: Bearer $TALVESS_STATS_KEY"

Query parameters

ParameterAccepted values
days1, 7, 30, or 90. Defaults to 30. Use this or a pair of explicit dates.
startDateInclusive UTC date in YYYY-MM-DD format. Requires endDate.
endDateInclusive UTC date in YYYY-MM-DD format. Requires startDate.
intervalhourly or daily. Defaults to hourly for days=1, otherwise daily.
sectionsummary (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.