conventions

How the API behaves

JSON in, JSON out. camelCase fields. Predictable errors, periods and rate limits.

Periods

Read endpoints accept either a relative range or an absolute window.

  • ?range= — today, yesterday, 7d, 30d, 90d, wtd, mtd, or a number of days.
  • ?from=&to= — absolute dates (YYYY-MM-DD).
  • ?grain= — hour, day, week or month (for timeseries).
curl "https://datalenk.com/api/v1/sites/3/stats/summary?range=30d" -H "Authorization: Bearer dlk_live_…"
curl "https://datalenk.com/api/v1/sites/3/stats/timeseries?from=2026-06-01&to=2026-06-30&grain=day" -H "Authorization: Bearer dlk_live_…"

Filters

Cross-filter any dataset with ?filter[dim]=value. Dimensions: channel, referrer, country, device, browser, os, region, city, language, campaign, source, page.

curl "https://datalenk.com/api/v1/sites/3/stats/pages?filter[channel]=Organic%20Search" -H "Authorization: Bearer dlk_live_…"

Pagination and limits

Dimension datasets accept ?limit= (default 50, max 200). Exports stream and page internally with a temporal cursor.

Rate limits

  • Reads: 600 requests / minute.
  • Writes: 300 requests / minute.
  • Exports: 20 requests / hour.

Over the limit returns 429 with a Retry-After header. Read endpoints are cached for 60s, so tight polling stays cheap.

Errors

Every error is a JSON object with a stable code and an actionable message.

{ "error": { "code": "plan_limit",
    "message": "Plan site limit reached. Upgrade your plan or delete a site to add more.",
    "docs": "https://datalenk.com/docs/api/sites" } }