Skip to content
Documentation
Stats API

Get counts

Read pageview, visitor, session, bounced-session, and continued-session totals for a selected period or lifetime.

Request

GET/api/v1/stats/counts

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/counts?startDate=2026-10-18&endDate=2026-10-18' \
  -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.
periodlifetime. Count all retained native traffic up to calculation time. Omit days, startDate, endDate, and interval.

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.

days=1 selects the rolling last 24 hours. Longer presets use UTC calendar days including today. Both explicit dates are inclusive: the example includes all of October 18 in UTC and excludes midnight on October 19. Counts use timestamps greater than or equal to period.start and less than period.endExclusive. The interval option changes period metadata, not the total; these endpoints do not return a time series. Use Get traffic for charts and dimension reports.

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.
counts.pageviews
All recorded pageviews, including those without a visitor or session identifier.
counts.visitors
Distinct non-null anonymous visitor identifiers on pageviews with a session identifier, deduplicated across the entire period.
counts.sessions
Distinct non-null session identifiers with at least one pageview in the period, including sessions that started earlier.
counts.bouncedSessions
Sessions with exactly one recorded pageview inside the selected period.
counts.continuedSessions
Sessions with two or more recorded pageviews inside the selected period. Together with bouncedSessions, these sum to sessions.
previous
start, endExclusive, and the same counts for the immediately preceding period of equal duration. Null for lifetime.

All counts are non-negative JSON integers. An empty period returns zero for every count. Counts use native Talvess records and exclude imported provider history. Anonymous visitor identifiers represent observed traffic, not verified people; missing identifiers can make visitor and session totals lower than pageviews. Visitor totals deduplicate across the whole range, so adding daily visitor counts can overcount the period total. Session behavior counts use only pageviews inside each period.

Example response for the request above:

response.json
{
  "data": {
    "period": {
      "start": "2026-10-18T00:00:00.000Z",
      "endExclusive": "2026-10-19T00:00:00.000Z",
      "seriesEnd": "2026-10-19T00:00:00.000Z",
      "asOf": "2026-10-19T12:00:00.000Z",
      "timezone": "UTC",
      "interval": "daily"
    },
    "counts": {
      "pageviews": 3,
      "visitors": 1,
      "sessions": 1,
      "bouncedSessions": 0,
      "continuedSessions": 1
    },
    "previous": {
      "start": "2026-10-17T00:00:00.000Z",
      "endExclusive": "2026-10-18T00:00:00.000Z",
      "counts": {
        "pageviews": 0,
        "visitors": 0,
        "sessions": 0,
        "bouncedSessions": 0,
        "continuedSessions": 0
      }
    }
  },
  "meta": {
    "generatedAt": "2026-10-19T12:00:00.000Z",
    "expiresAt": "2026-10-19T12:15:00.000Z"
  }
}

Use period=lifetime for all retained native traffic before period.asOf, including history older than 365 days. Do not combine it with days, explicit dates, or interval. The response sets period.range to lifetime and period.start to the first recorded pageview timestamp, or null when empty. period.endExclusive and period.seriesEnd equal the calculation time.period.interval and previous are null. Lifetime uses the same 900-second cache and counts distinct recorded visitor identifiers across the whole history, rather than summing daily visitor totals.

lifetime-request.sh
curl 'https://talvess.vercel.app/api/v1/stats/counts?period=lifetime' \
  -H "Authorization: Bearer $TALVESS_STATS_KEY"
lifetime-response.json
{
  "data": {
    "period": {
      "range": "lifetime",
      "start": "2026-10-18T10:00:00.000Z",
      "endExclusive": "2026-10-19T12:00:00.000Z",
      "seriesEnd": "2026-10-19T12:00:00.000Z",
      "asOf": "2026-10-19T12:00:00.000Z",
      "timezone": "UTC",
      "interval": null
    },
    "counts": {
      "pageviews": 3,
      "visitors": 1,
      "sessions": 1,
      "bouncedSessions": 0,
      "continuedSessions": 1
    },
    "previous": null
  },
  "meta": {
    "generatedAt": "2026-10-19T12:00:00.000Z",
    "expiresAt": "2026-10-19T12:15:00.000Z"
  }
}

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.