API reference

Query analytics

Ask for one or more query types over a date range and get one result per type.

curl -X POST "https://api.databuddy.cc/v1/query?website_id=$DATABUDDY_WEBSITE_ID&timezone=Europe/Berlin" \
  -H "x-api-key: $DATABUDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "parameters": ["summary_metrics", "top_pages"],
    "preset": "last_7d",
    "filters": [{ "field": "country", "op": "in", "value": ["US", "CA"] }],
    "limit": 10
  }'
{
  "success": true,
  "requestId": "req_abc123",
  "queryId": "",
  "data": [
    { "parameter": "summary_metrics", "success": true, "data": [{ "pageviews": 1250, "unique_visitors": 890, "sessions": 1100 }] },
    { "parameter": "top_pages", "success": true, "data": [{ "name": "/", "pageviews": 450, "visitors": 320 }] }
  ],
  "meta": { "parameters": ["summary_metrics", "top_pages"], "total_parameters": 2, "page": 1, "limit": 10, "filters_applied": 1 }
}

Top-level success: true means the request was valid. Check success on each item in data before you trust its numbers.

Build the request

EndpointWhat it doesKey needed
POST /v1/queryRuns query typesread:data
POST /v1/query/compileChecks and builds one query without running itread:data
GET /v1/query/websitesLists the websites the key can readread:data
GET /v1/query/typesLists query types, their filters and date presets; add ?include_meta=true for output fieldsNone

Pass one of these in the URL of POST /v1/query:

Query parameterFor
website_idWebsite analytics
link_idShort link clicks
schedule_idUptime monitor analytics
organization_idOrganization-wide query types
timezoneOptional IANA timezone for dates and buckets, UTC by default
Body fieldTypeNotes
parametersarrayRequired. Query type names, or { "name", "id", "start_date", "end_date", "granularity" }. Up to 25.
presetstringA date preset, or send both dates
startDate, endDatestringYYYY-MM-DD
filtersarrayUp to 25 { "field", "op", "value" }; up to 1,000 values in a list
limitnumberRows per parameter, 1 to 10,000. Default 100.
pagenumber1 to 1,000. Default 1.
granularitystringhourly, daily, week or month (hour and day also work). Hourly covers at most 30 days.
sortBy, sortOrderstringAn output column, then asc or desc
timeZonestringSame as the timezone URL parameter
idstringEchoed back as queryId

Not every query type supports every granularity or filter. GET /v1/query/types?include_meta=true lists what each accepts.

Pick a date range

PresetCovers
today, yesterdayOne day
last_7d, last_14d, last_30d, last_60d, last_90dThat many days, including today
last_3_weeks21 days, including today
this_week, last_weekThe current week so far, or the previous full week
this_month, last_monthThe current month so far, or the previous full month
this_yearThe current year so far

Give one parameter its own range with { "name": "top_pages", "start_date": "2026-11-01", "end_date": "2026-11-15", "id": "first-half" }.

Filter results

OperatorMatchesExample value
eq, neEqual, not equal"US"
contains, not_containsHas the text, or not"chrome"
starts_with, ends_withBegins or ends with"/blog"
in, not_inOne of a list, or none["US", "CA"]
regex, not_regexAn RE2 pattern up to 500 characters"^/docs/v[0-9]+/"
gt, gte, lt, lteCompares numbers100
is_set, is_not_setHas a value, or not; value is ignored""

Common fields are country, device_type, browser_name, os_name, path and referrer. Event properties filter as properties.<key> where the query type lists them. A rejected filter's error lists what that type accepts.

Batch several queries

Send an array of up to 25 request bodies, with at most 100 parameters in total.

[
  { "id": "this-month", "parameters": ["summary_metrics"], "preset": "this_month" },
  { "id": "last-month", "parameters": ["summary_metrics"], "preset": "last_month" }
]

The response is { "success": true, "batch": true, "results": [...] }, one entry per request with its queryId. Send Accept: text/event-stream to get each result as a result event as soon as it's ready, then a done event.

Share a public overview

When a website's dashboard is public, anyone can read its unfiltered overview without a key. GET /v1/query/types marks those query types publicAccess: true. Filters, custom events, errors, vitals, profiles and revenue still need a key with access. Page, referrer and campaign labels in a public overview are visible to everyone, so check them before you share.

How is this guide?