Skip to content
Convor
Convor Docs
API ReferenceVisitors

Get visitor statistics

Returns visitor totals, online visitor count, new-versus-returning counts, and top countries for the requested period.

GET/api/visitors/stats

Returns visitor totals, online visitor count, new-versus-returning counts, and top countries for the requested period. period defaults to 24h and accepts 24h, 7d, or 30d. onlineNow counts visitors seen in the last five minutes. Statistics are calculated for the authenticated organization and can lag recent write-side events while asynchronous analytics are being processed.

Endpoint requirements

Credentials
Use either Bearer API key or X-API-Key header.
Required scope
visitors:read
Module
Automation & API module (api_access)
Organization and site scope
Requests can access only resources owned by the authenticated organization. The API does not reveal whether an identifier belongs to another organization or site.
Retry behavior
Safe read: You can safely retry this read-only request after a transport failure. It does not change resource state.

Query Parameters

period?string

Query parameter. Period. Allowed values: 24h, 7d, 30d.

Value in

  • "24h"
  • "7d"
  • "30d"
scope?"all"

Query parameter. Scope. Allowed values: all.

Value in

  • "all"

Header Parameters

X-Project-Id?|

DA-4035: selects the active site (project) for project-scoped operations. Accepts a site UUID, or the literal all to aggregate across every accessible site on read-only aggregate routes (single-or-all-read). Mutations and single-site routes reject all. Path-owned project routes (/api/projects/{projectId}/…) resolve the site from the URL and ignore this header. Conflicting selectors across header/query/body/path return PROJECT_CONTEXT_CONFLICT (400); an archived site returns PROJECT_ARCHIVED (410).

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

{  "total": 120,  "onlineNow": 8,  "newVsReturning": {    "new": 45,    "returning": 75  },  "topCountries": [    {      "country": "US",      "count": 60    },    {      "country": "PL",      "count": 20    }  ],  "period": "7d",  "nextOnlineExpiryInSeconds": 180}

Request examples

curl

curl --request GET \
  'https://api.convor.io/api/visitors/stats' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer convor_sk_...'

JavaScript

const response = await fetch("https://api.convor.io/api/visitors/stats", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": "Bearer convor_sk_..."
  },
});

const contentType = response.headers.get("content-type") ?? "";
const data = response.status === 204
  ? null
  : contentType.includes("json")
    ? await response.json()
    : contentType.startsWith("text/")
      ? await response.text()
      : await response.blob();

if (!response.ok) {
  const message = typeof data === "object" && data !== null
    && "error" in data && typeof data.error === "object"
    && data.error !== null && "message" in data.error
      ? String(data.error.message)
      : "Convor API request failed (" + response.status + ")";
  throw new Error(message);
}

console.log(data);

Was this page helpful?

On this page