Skip to main content
GET
/
api
/
websites
/
:id
/
realtime
Get Realtime Data
curl --request GET \
  --url https://api.example.com/api/websites/:id/realtime
{
  "data": {
    "active_visitors": 123,
    "recent_events": [
      {
        "event_type": "<string>",
        "url": "<string>",
        "referrer_domain": "<string>",
        "country": "<string>",
        "browser": "<string>",
        "device_type": "<string>",
        "ts": "<string>"
      }
    ],
    "pagination": {
      "limit": 123,
      "total_in_window": 123
    }
  }
}

Path Parameters

id
string
required
Website ID

Query Parameters

include_bots
boolean
Whether to include bot traffic in results. Defaults to website’s bot policy setting.

Response

data
object
Real-time analytics data.
active_visitors
integer
Number of visitors who had activity in the last 5 minutes.
recent_events
array
Array of recent events (up to 100 most recent).
event_type
string
Type of event: pageview or event.
url
string
The page URL where the event occurred.
referrer_domain
string
Referrer domain (if available).
country
string
ISO 3166-1 alpha-2 country code (if available).
browser
string
Browser name (if available).
device_type
string
Device type: desktop, mobile, or tablet (if available).
ts
string
Timestamp of the event in ISO 8601 format.
pagination
object
Pagination metadata for recent events.
limit
integer
Maximum number of events returned.
total_in_window
integer
Total number of events in the real-time window.

Example Request

curl -X GET "https://analytics.example.com/api/websites/abc123/realtime" \
  -H "Authorization: Bearer spk_live_your_api_key"

Example Response

{
  "data": {
    "active_visitors": 47,
    "recent_events": [
      {
        "event_type": "pageview",
        "url": "https://example.com/pricing",
        "referrer_domain": "google.com",
        "country": "US",
        "browser": "Chrome",
        "device_type": "desktop",
        "ts": "2024-03-07T15:42:31.123Z"
      },
      {
        "event_type": "pageview",
        "url": "https://example.com/",
        "referrer_domain": null,
        "country": "GB",
        "browser": "Safari",
        "device_type": "mobile",
        "ts": "2024-03-07T15:42:28.456Z"
      },
      {
        "event_type": "event",
        "url": "https://example.com/signup",
        "referrer_domain": "twitter.com",
        "country": "CA",
        "browser": "Firefox",
        "device_type": "desktop",
        "ts": "2024-03-07T15:42:15.789Z"
      },
      {
        "event_type": "pageview",
        "url": "https://example.com/docs/getting-started",
        "referrer_domain": "github.com",
        "country": "DE",
        "browser": "Edge",
        "device_type": "desktop",
        "ts": "2024-03-07T15:41:52.321Z"
      }
    ],
    "pagination": {
      "limit": 100,
      "total_in_window": 234
    }
  }
}

Notes

  • Active visitors are counted based on activity within the last 5 minutes
  • Recent events are limited to the most recent 100 events
  • This endpoint is optimized for frequent polling (every 5-10 seconds)
  • Events are returned in descending order by timestamp (newest first)
  • No date range parameters are needed as this endpoint always shows real-time data
  • The total_in_window shows all events in the time window, even though only the most recent 100 are returned

Build docs developers (and LLMs) love