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:read scope.
  • All tokens must be sent in the Authorization header. 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 401 with a WWW-Authenticate challenge.
  • 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

PeriodMeaning
todayCurrent day in the site timezone
yesterdayPrevious day in the site timezone
24hRolling last 24 hours; hourly only
7dLast 7 days
30dLast 30 days
12mLast 365 days
wtdWeek to date, Monday start
mtdMonth to date
ytdYear to date
monthPrevious full calendar month
customRequires both from and to in YYYY-MM-DD
allAll currently retained data for the site

Common Filters

ParameterMeaning
pageExact page path filter, for example /pricing
referrerExact referrer domain filter, for example google.com
countryExact country code or stored country value
deviceExact device type, for example desktop or mobile
browserExact browser name
osExact operating system name
  • period defaults to 30d.
  • from and to are only valid when period=custom.
  • all means all currently retained data for the site.
  • meta.from_rollups is true whenever 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 hour for 24h or single-day ranges, otherwise day.
  • period=24h only supports interval=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.

PropertyAllowed metrics
pagevisitors, pageviews
entry_pageentries
exit_linkclicks
channelvisitors, pageviews
referrervisitors, pageviews
countryvisitors, pageviews
regionvisitors, pageviews; requires country
cityvisitors, pageviews; requires country, optional region
devicevisitors, pageviews
browservisitors, pageviews
osvisitors, pageviews
  • Pagination uses limit and page_number.
  • property=region requires country.
  • property=city requires country and accepts optional region to 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"
  }
}
StatusWhen it is returned
401Missing, malformed, invalid, expired, or revoked bearer token
403Insufficient scope or API access unavailable for the site
422Query needs raw filtered data outside the 90-day raw retention window
429Rate limit exceeded; includes Retry-After
  • Successful bearer-authenticated responses include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.
  • The current limits are 600 requests per hour per API key and 60 requests per minute per IP address.
  • Realtime and 429 responses are marked Cache-Control: no-store.