Docs / Public API
Public API
The Aizen public API gives you read-only access to analytics data with site-scoped API keys. It covers aggregate metrics, timeseries data, breakdowns, and realtime visitors.
Overview
Base URL: https://aizenanalytics.com
- Public stats endpoints live under
/api/v1/stats/*. - API key management endpoints live under
/api/sites/[siteId]/api-keys. - All public API keys are read-only and currently use the
stats:readscope. - All tokens must be sent in the
Authorizationheader. Query-string tokens are not supported.
Authentication
Send your API key as a bearer token:
Authorization: Bearer aiz_live_xxx- Missing bearer token returns
401. - Invalid, malformed, expired, or revoked tokens return
401with aWWW-Authenticatechallenge. - Scope failures return
403. - API access is also gated by the site owner's billing access. If the owner does not currently have access, usage endpoints return
403.
API Key Management
Only the site owner can list, create, or revoke API keys. These endpoints use the normal signed-in dashboard session, not a bearer token.
GET /api/sites/{siteId}/api-keys
Lists API keys for a site. Each item includes a masked preview.
POST /api/sites/{siteId}/api-keys
Creates a new API key. The full token is returned once in the response and should be stored immediately.
POST /api/sites/{siteId}/api-keys
Content-Type: application/json
{
"name": "Production reporting",
"expiresAt": "2026-12-31T23:59:59Z"
}{
"key": {
"id": "c3a66f42d3084c58a8fb98ec4d642c91",
"site_id": "site_123",
"created_by_user_id": "user_123",
"name": "Production reporting",
"scope": "stats:read",
"key_prefix": "aiz_live_8c31d4a0d1e9",
"expires_at": 1798761599,
"last_used_at": null,
"revoked_at": null,
"created_at": 1775159000,
"updated_at": 1775159000,
"preview": "aiz_live_8c31d4a0d1e9_********************************"
},
"token": "aiz_live_8c31d4a0d1e9_7f0d9a..."
}DELETE /api/sites/{siteId}/api-keys/{keyId}
Revokes an API key and returns { "ok": true }.
Query Model
All stats endpoints work against a site's configured timezone, but timeseries timestamps are returned as UTC ISO-8601 bucket-start timestamps for deterministic parsing.
Periods
| Period | Meaning |
|---|---|
today | Current day in the site timezone |
yesterday | Previous day in the site timezone |
24h | Rolling last 24 hours; hourly only |
7d | Last 7 days |
30d | Last 30 days |
12m | Last 365 days |
wtd | Week to date, Monday start |
mtd | Month to date |
ytd | Year to date |
month | Previous full calendar month |
custom | Requires both from and to in YYYY-MM-DD |
all | All currently retained data for the site |
Common Filters
| Parameter | Meaning |
|---|---|
page | Exact page path filter, for example /pricing |
referrer | Exact referrer domain filter, for example google.com |
country | Exact country code or stored country value |
device | Exact device type, for example desktop or mobile |
browser | Exact browser name |
os | Exact operating system name |
perioddefaults to30d.fromandtoare only valid whenperiod=custom.allmeans all currently retained data for the site.meta.from_rollupsistruewhenever any part of the response used rollup data.- Filtered queries are only supported inside the 90-day raw event window. Older filtered queries return
422 unsupported_query.
Endpoints
GET /api/v1/stats/aggregate
Returns top-line metrics. Supported metrics: visitors, pageviews, bounce_rate, and visit_duration.
curl 'https://aizenanalytics.com/api/v1/stats/aggregate?period=30d&metrics=visitors,pageviews,bounce_rate' \
-H 'Authorization: Bearer aiz_live_xxx'{
"period": {
"from": "2026-02-05",
"to": "2026-03-06",
"preset": "30d"
},
"metrics": {
"visitors": 18324,
"pageviews": 42102,
"bounce_rate": 37.8
},
"meta": {
"timezone": "America/Los_Angeles",
"from_rollups": false
}
}GET /api/v1/stats/timeseries
Returns chart points for visitors and/or pageviews. Supported intervals: hour, day, week, and month.
- Default interval is
hourfor24hor single-day ranges, otherwiseday. period=24honly supportsinterval=hour.- Hourly queries are only available when the entire range is inside raw retention.
curl 'https://aizenanalytics.com/api/v1/stats/timeseries?period=7d&interval=day&metrics=visitors,pageviews' \
-H 'Authorization: Bearer aiz_live_xxx'{
"period": {
"from": "2026-02-28",
"to": "2026-03-06",
"preset": "7d"
},
"interval": "day",
"results": [
{
"date": "2026-02-28T08:00:00.000Z",
"visitors": 2421,
"pageviews": 5510
}
],
"meta": {
"timezone": "America/Los_Angeles",
"from_rollups": false
}
}GET /api/v1/stats/breakdown
Returns paginated breakdown rows. Use property to choose the dimension, metrics to choose the values, and sort=metric.asc|metric.desc to control ordering.
| Property | Allowed metrics |
|---|---|
page | visitors, pageviews |
entry_page | entries |
exit_link | clicks |
channel | visitors, pageviews |
referrer | visitors, pageviews |
country | visitors, pageviews |
region | visitors, pageviews; requires country |
city | visitors, pageviews; requires country, optional region |
device | visitors, pageviews |
browser | visitors, pageviews |
os | visitors, pageviews |
- Pagination uses
limitandpage_number. property=regionrequirescountry.property=cityrequirescountryand accepts optionalregionto scope the city list.
curl 'https://aizenanalytics.com/api/v1/stats/breakdown?period=30d&property=exit_link&metrics=clicks&sort=clicks.desc&limit=10' \
-H 'Authorization: Bearer aiz_live_xxx'{
"property": "exit_link",
"period": {
"from": "2026-02-05",
"to": "2026-03-06",
"preset": "30d"
},
"results": [
{
"value": "https://github.com/example/repo",
"clicks": 47
}
],
"pagination": {
"page_number": 1,
"limit": 10,
"total_rows": 1,
"total_pages": 1
},
"meta": {
"timezone": "America/Los_Angeles",
"from_rollups": true
}
}GET /api/v1/stats/realtime
Returns the current visitor count for a recent window. The minutes parameter defaults to 10 and is clamped between 1 and 60.
curl 'https://aizenanalytics.com/api/v1/stats/realtime?minutes=10' \
-H 'Authorization: Bearer aiz_live_xxx'{
"current_visitors": 18,
"window_minutes": 10
}Errors and Rate Limits
Errors use a consistent JSON shape:
{
"error": {
"code": "invalid_request",
"message": "property is required"
}
}| Status | When it is returned |
|---|---|
401 | Missing, malformed, invalid, expired, or revoked bearer token |
403 | Insufficient scope or API access unavailable for the site |
422 | Query needs raw filtered data outside the 90-day raw retention window |
429 | Rate limit exceeded; includes Retry-After |
- Successful bearer-authenticated responses include
X-RateLimit-Limit,X-RateLimit-Remaining, andX-RateLimit-Reset. - The current limits are 600 requests per hour per API key and 60 requests per minute per IP address.
- Realtime and
429responses are markedCache-Control: no-store.