REST API Reference v2.1 — Analytics
GET /analytics/events
Returns a time-series stream of raw analytics events. Events are returned in reverse chronological order.
Parameters
| Name | Type | Description |
|---|---|---|
| start | string | ISO 8601 start time (required). Example: 2025-01-01T00:00:00Z |
| end | string | ISO 8601 end time (required). Maximum range: 7 days. |
| event_type | string | Filter by event type: pageview, click, conversion, error. |
| source | string | Filter by traffic source (e.g., organic, paid, referral). |
| cursor | string | Pagination cursor from a previous response. |
| limit | integer | Results per page (default: 100, max: 1000) |
Response
{
"data": [
{
"id": "evt_a1b2c3",
"type": "pageview",
"timestamp": "2025-01-20T14:22:11Z",
"session_id": "sess_xyz",
"properties": {
"path": "/pricing",
"referrer": "https://google.com",
"duration_ms": 4200
}
}
],
"cursor": "eyJsYXN0X2lkIjoiZXZ0X2ExYjJjMyJ9",
"has_more": true
}
POST /analytics/query
Executes an aggregation query against the analytics data warehouse. Supports grouping, filtering, and multiple aggregation functions.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| start | string | Yes | ISO 8601 start time for the query window. |
| end | string | Yes | ISO 8601 end time. Maximum range: 90 days. |
| metrics | array | Yes | Aggregation metrics to compute. Supported: count, unique_count, sum, avg, p50, p95, p99. |
| group_by | array | No | Dimensions to group by: event_type, source, country, device, path. |
| filters | array | No | Filter conditions. Each filter has field, operator (eq, neq, gt, lt, contains), and value. |
| granularity | string | No | Time bucketing: minute, hour, day, week, month. Default: day. |
Example Request
curl -X POST https://api.example.com/analytics/query \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"start": "2025-01-01T00:00:00Z",
"end": "2025-01-31T23:59:59Z",
"metrics": ["count", "unique_count"],
"group_by": ["event_type", "source"],
"filters": [
{"field": "country", "operator": "eq", "value": "US"}
],
"granularity": "day"
}'
Response
{
"data": [
{
"period": "2025-01-20",
"dimensions": {
"event_type": "pageview",
"source": "organic"
},
"metrics": {
"count": 14523,
"unique_count": 8891
}
},
{
"period": "2025-01-20",
"dimensions": {
"event_type": "conversion",
"source": "paid"
},
"metrics": {
"count": 342,
"unique_count": 298
}
}
],
"meta": {
"query_time_ms": 284,
"rows_scanned": 1482031,
"cache_hit": false
}
}
Queries that scan more than 10 million rows are automatically queued and return a 202 Accepted response with a polling URL. Complex queries may take up to 30 seconds. Results are cached for 5 minutes; subsequent identical queries return cached results with cache_hit: true.
All external references have been reviewed by our editorial team.