Skip to content

Read API

Fetch your statistics programmatically: internal dashboards, reports, exports. Restricted to the Pro and Agency plans, the beta and active trials.

Authentication

Create a token in Dashboard → API tokens, then pass it as a Bearer:

curl -H "Authorization: Bearer YOUR_TOKEN" \
  "https://quietmetrics.dev/api/v1/stats/qm_pub_XXXXXXXXXXXXXXXXX/summary?period=30d"

All routes are prefixed with /api/v1/stats/{site_public_key}. A token only grants access to the sites on your account; a site that does not belong to you returns 404 (no existence leak).

A token covers either all your sites, current and future, or only the sites picked when it was created: a site on your account that it does not cover returns 403. It stops working on the expiry date shown in the token list.

Back-office widgets. The Laravel package (Filament widget) and the WordPress plugin (dashboard widget) read your figures with such a token. Create one restricted to that single site: it only reads statistics, through the routes below, and stays separate from the site's collection keys (qm_pub_…, qm_sec_…). Revoking it never stops measurement, and a collection key read in your pages never opens your statistics. Create a new one before the expiry date shown in the list, otherwise the widget reports that the token was refused.

Endpoints

Endpoint Content
GET /summary Metrics for the period, and for the previous period of the same length or the same dates one year earlier
GET /timeseries Time series: one point per day, or per hour when the period fits in a single day; per week or per month on request
GET /breakdown Ranking of the values of a dimension ({label, value})
GET /realtime Active visitors over the last 5 minutes ({"visitors": N})

Common parameters

period

A dashboard preset: today, yesterday, 7d, 30d (default), month (current month), last_month, 12m. Rolling periods end today, today included.

Or an explicit range, for example ?period=custom:2026-07-01..2026-07-31:

  • custom:YYYY-MM-DD..YYYY-MM-DD: from the first day to the second, both included, over 760 days at most. Reversed bounds are put back in order. The range may end today, not later.

Dates are those of the site's timezone.

An invalid period does not produce an error: it is replaced with 30d. This applies to an unknown preset as well as to a malformed range (any format other than YYYY-MM-DD, a date that does not exist), a range that is too long, or one that ends in the future. So check the period you were served: every response except realtime carries period.from and period.to, and summary adds period.preset, which is custom for an accepted range and 30d after a replacement.

The previous period (previous in summary) has the same number of days and ends the day before the period starts. For month, it is therefore not the whole previous month, but as many days as the current month has had so far.

compare (summary)

compare chooses the compared window, returned in previous:

  • previous (default): the previous period described above.
  • year: one year earlier, in the site's timezone, the same number of days, on the same dates give or take one day around 29 February. The window ends on the same date one year earlier (29 February becomes 28 February) and has as many days as the period: 28 February to 1 March 2029 is compared with 29 February to 1 March 2028.

Any other value returns 422. comparison states the window actually read (mode, from, to) and carries measured, which is false when the site was not measured yet on the first day of that window, or when those days are beyond the retention of your plan. With year, every metric of previous is then null: there is nothing to compare with, it is not an empty audience, and a change computed against zero would read -100%. With previous, the figures are still returned as before this parameter existed, but a window whose measured is false is not a comparison base.

filters

filters takes the same filters as the dashboard, in dimension:value format, separated by ;. A sign right after the dimension changes the operator:

?filters=country:FR;device:mobile
?filters=page:/pricing
?filters=channel:search;browser:Firefox
?filters=country!:FR
?filters=page~:/blog;referrer:(none)
  • dimension:value: the dimension is exactly that value.
  • dimension!:value: the dimension is not that value. Visits without a value, from an unknown country or without a referring domain for instance, are still counted.
  • dimension~:text: the dimension contains that text, upper and lower case alike. Accents count, and % and _ are ordinary characters.
  • The value (none) means no value: referrer:(none) counts visits without a referring domain, campaign!:(none) those that carry a campaign. It applies to referrer, source, medium, campaign, country, region, browser, os and lang; on another dimension it gets a 422. After ~, it is text like any other.
  • The value starts after the first :, so it may contain :, ! or ~. It cannot contain ;, which separates filters.
  • The dimensions you can filter on are marked in the table below. Any other dimension, including entry and exit, gets a 422 naming it: you receive an error rather than unfiltered numbers. A sign other than ! or ~ also gets a 422.
  • One value per dimension and operator: when the same key appears twice, the last one wins (?filters=device:mobile;device:desktop keeps only desktop). Different keys add up, even on the same dimension (country!:FR;page~:/blog): only pageviews and events that match all of them are counted.
  • filters only accepts values of at most 500 characters: beyond that the value is dropped without an error, and it then does not appear in the response's filters.
  • The filters of summary carries only the filters ACTUALLY applied, not the request received: a dimension listed there did restrict the numbers next to it. Each key keeps its operator ("country!": "FR").
  • Closed vocabulary: channel is one of direct, search, social, referral, email, campaign or ai (AI assistants: ChatGPT, Perplexity, Claude, Gemini, Copilot…); device is one of desktop, mobile, tablet or other.
  • As soon as a filter applies, metrics are recomputed from raw events, and both bounce_rate and avg_duration are null.
  • Raw events are kept for less time than the daily statistics: their period is your plan's filterable detail, the statistics' one is the longer history. Over a period that starts before the oldest day of detail kept, a filtered request answers 422 with that day, rather than zeros. Without filters, the same period reads normally. In summary, if only the compared window (the previous period, or last year with compare=year) goes back before that day, previous carries metrics set to null, never to zero.
  • In breakdown, a dimension:value filter on the ranked dimension is ignored for that ranking: ?dimension=country&filters=country:FR returns every country, so that the filter does not shrink the ranking down to its own value. With ! or ~, it restricts it: ?dimension=country&filters=country!:FR returns every country but France.

dimension (breakdown)

dimension What value counts Usable in filters
page Pageviews yes
entry Entries: sessions that started on this page no
exit Exits: sessions that ended on this page, computed the following night (the current day has none yet, except under a filter) no
referrer Sessions, by referring domain yes
channel Sessions, by acquisition channel yes
source Sessions, by utm_source value yes
medium Sessions, by utm_medium value yes
campaign Sessions, by utm_campaign value yes
country Pageviews, by country (two-letter ISO code) yes
region Pageviews, by region yes
browser Pageviews, by browser yes
os Pageviews, by operating system yes
device Pageviews, by device type yes
lang Pageviews, by language yes
event Occurrences, by event name yes

A dimension missing from this table returns 422. label is null for visits without a value, for example without a referring domain.

limit (breakdown): number of rows, 10 by default, bounded between 1 and 1,000.

Event properties (dimension=property)

dimension=property ranks the values of one property of one custom event over the period: where your outbound links lead (event=Lien sortant and property=url, encoded Lien%20sortant in the address), which files are downloaded (event=Téléchargement and property=url), which plan your sign-ups choose.

  • event and property are required: without either, the response is 422.
  • No filter combines with it, since the values are only kept as daily aggregates: a filters parameter answers 422 rather than returning unfiltered figures.
  • value counts the occurrences of the event that carried this value. Strings are trimmed, numbers written in plain decimals, booleans read true or false, and label is null for an empty value.
  • In a value or a key, only the piece that looks like an email address, a token, a long identifier, an IP address or a phone number is replaced by ~: write to ~ tomorrow keeps the rest of the text. Any run of nine digits or more is treated as a phone number: a timestamp, an ISBN or a long reference becomes ~ too.
  • The response repeats event and property. capped is scoped to the event_prop cap there, and its folded_values stays null: that number is never computed for properties. Beyond the cap, a value is grouped under ~autres within its key; a key itself beyond the cap reads ~autres, and so does its value.

Time series granularity

GET /timeseries returns one point per day in general, and one point per hour as soon as the period fits in a single local day (today, yesterday, or a custom: range whose two bounds are equal). The date field then takes the form YYYY-MM-DD HH:MM, in the site's local time, instead of YYYY-MM-DD.

A local day is not always 24 hours long. On the two clock changes of the year, the series therefore carries 23, 24 or 25 points: do not rely on a fixed count.

  • Night the clocks go back: 25 points. The replayed local hour (02:00 in Paris) yields two consecutive points carrying the same date, each with its own metrics. This format carries no UTC offset: locate those points by their position in the list, never by their label.
  • Night the clocks go forward: 23 points, the skipped local hour (02:00 in Paris) is absent. No point spills over into the next day.

The visitors of an hourly point are those who were active during that hour: someone present over two hours shows up in both, so hourly points do not add up to a daily total.

The hourly step is read from raw events. A single day older than the detail kept therefore returns one daily point, in the YYYY-MM-DD form: its hours are no longer known, and the series does not replace them with zeros.

granularity (timeseries)

granularity sets the step: day, week or month. Without it, the rule above applies, and day returns one point per day even over a single day. Any other value returns 422. The response always carries granularity, the step actually served: hour, day, week or month.

  • week follows ISO weeks, Monday to Sunday, in the site's local dates; month follows calendar months.
  • Each point carries date, its first day read, and to, its last one. The first and last weeks (or months) are cut at the bounds of the period: you recognise them by their length, not by a dip in audience.
  • Each metric is the sum of the point's days. For visitors, it is therefore the sum of each day's visitors, like kpis.visitors over a period of several days: someone who came back on two days of the same week counts twice.

Response examples

summary

GET /summary?period=30d:

{
    "site": "mysite.com",
    "period": { "preset": "30d", "from": "2026-06-17", "to": "2026-07-16" },
    "filters": {},
    "kpis": { "pageviews": 9873, "visitors": 4210, "sessions": 4630, "events": 312, "bounce_rate": 47.2, "avg_duration": 74 },
    "previous": { "pageviews": 9145, "visitors": 3877, "sessions": 4288, "events": 290, "bounce_rate": 49.1, "avg_duration": 71 },
    "comparison": { "mode": "previous", "from": "2026-05-18", "to": "2026-06-16", "measured": true }
}
kpis Content
pageviews Pageviews
visitors Unique visitors of each day, summed over the period: someone who comes back the next day is counted twice
sessions Visits
events Measured events other than pageviews
bounce_rate Bounce rate as a percentage, from 0 to 100, rounded to one decimal place: share of sessions with a single measured pageview or event. null when there is no session at all, or as soon as a filter applies
avg_duration Average session duration, in whole seconds. null when there is no session at all, or as soon as a filter applies

previous carries the same keys for the previous period. The API computes no change: derive it from the two values yourself, and handle a previous value of zero or null separately.

GET /summary?period=7d&filters=device:mobile:

{
    "site": "mysite.com",
    "period": { "preset": "7d", "from": "2026-07-10", "to": "2026-07-16" },
    "filters": { "device": "mobile" },
    "kpis": { "pageviews": 1204, "visitors": 611, "sessions": 655, "events": 38, "bounce_rate": null, "avg_duration": null },
    "previous": { "pageviews": 1139, "visitors": 590, "sessions": 622, "events": 41, "bounce_rate": null, "avg_duration": null },
    "comparison": { "mode": "previous", "from": "2026-07-03", "to": "2026-07-09", "measured": true }
}

On a site measured for less than a year, GET /summary?period=30d&compare=year:

{
    "site": "mysite.com",
    "period": { "preset": "30d", "from": "2026-06-17", "to": "2026-07-16" },
    "filters": {},
    "kpis": { "pageviews": 9873, "visitors": 4210, "sessions": 4630, "events": 312, "bounce_rate": 47.2, "avg_duration": 74 },
    "previous": { "pageviews": null, "visitors": null, "sessions": null, "events": null, "bounce_rate": null, "avg_duration": null },
    "comparison": { "mode": "year", "from": "2025-06-17", "to": "2025-07-16", "measured": false }
}

timeseries

One point per day, days without traffic included (they are zero).

GET /timeseries?period=custom:2026-07-14..2026-07-16:

{
    "period": { "from": "2026-07-14", "to": "2026-07-16" },
    "granularity": "day",
    "data": [
        { "date": "2026-07-14", "pageviews": 341, "visitors": 142, "sessions": 158, "events": 9 },
        { "date": "2026-07-15", "pageviews": 298, "visitors": 131, "sessions": 144, "events": 12 },
        { "date": "2026-07-16", "pageviews": 0, "visitors": 0, "sessions": 0, "events": 0 }
    ]
}

When the period fits in a single day (today, yesterday, or a range whose two bounds are equal), the series switches to hours: one point per hour of the local day, from 00:00 to 23:00 in the site's local time (23 or 25 points on clock-change days, see “Time series granularity”), and date takes the form YYYY-MM-DD HH:MM. The visitors of an hourly point are those active during that hour: someone present over two hours shows up in both, so the points do not add up to a daily total.

GET /timeseries?period=custom:2026-07-16..2026-07-16, the first three of the 24 points:

{
    "period": { "from": "2026-07-16", "to": "2026-07-16" },
    "granularity": "hour",
    "data": [
        { "date": "2026-07-16 00:00", "pageviews": 4, "visitors": 3, "sessions": 3, "events": 0 },
        { "date": "2026-07-16 01:00", "pageviews": 1, "visitors": 1, "sessions": 1, "events": 0 },
        { "date": "2026-07-16 02:00", "pageviews": 0, "visitors": 0, "sessions": 0, "events": 0 }
    ]
}

Per week, GET /timeseries?period=custom:2026-07-01..2026-07-16&granularity=week: 1 July 2026 is a Wednesday, so the first week has five days and the last one four.

{
    "period": { "from": "2026-07-01", "to": "2026-07-16" },
    "granularity": "week",
    "data": [
        { "date": "2026-07-01", "to": "2026-07-05", "pageviews": 1502, "visitors": 655, "sessions": 721, "events": 44 },
        { "date": "2026-07-06", "to": "2026-07-12", "pageviews": 2210, "visitors": 948, "sessions": 1037, "events": 61 },
        { "date": "2026-07-13", "to": "2026-07-16", "pageviews": 980, "visitors": 421, "sessions": 466, "events": 25 }
    ]
}

breakdown

GET /breakdown?dimension=page&limit=3:

{
    "dimension": "page",
    "period": { "from": "2026-06-17", "to": "2026-07-16" },
    "data": [
        { "label": "/", "value": 3120 },
        { "label": "/pricing", "value": 1284 },
        { "label": "/docs", "value": 977 }
    ],
    "capped": {
        "any": true,
        "dimensions": [
            { "dimension": "page", "days": 2, "days_repaired": 1, "folded_values": 1406, "cap": 2000 }
        ]
    }
}

With no capping over the period, capped is {"any": false, "dimensions": []}.

GET /breakdown?dimension=property&event=Lien%20sortant&property=url&limit=2:

{
    "dimension": "property",
    "event": "Lien sortant",
    "property": "url",
    "period": { "from": "2026-06-17", "to": "2026-07-16" },
    "data": [
        { "label": "https://github.com/", "value": 214 },
        { "label": "https://www.php.net/", "value": 87 }
    ],
    "capped": { "any": false, "dimensions": [] }
}

realtime

GET /realtime:

{ "visitors": 3 }

Cardinality cap (capped)

Each site measures a bounded number of distinct values per day and per dimension. Beyond that, further values are counted together under a single label, ~autres: the detail is grouped, no visit is lost and the totals remain exact. breakdown reports this state in the capped key:

  • any is always present and dimensions is always a list: the schema does not vary with the state of the site, so no branching is needed to read it.
  • dimension is the capped dimension, not the one you asked for. entry and exit are grouped by the page cap; source and medium are grouped by the campaign cap; property is grouped by the event_prop cap.
  • days counts the capped local days in the period; cap is the highest threshold actually applied (it can vary if a raise is applied mid-period).
  • folded_values: null does NOT mean zero. The number of grouped values is only known after the nightly rebuild, which processes a day no earlier than D+2. null means "cap reached, count not known yet"; 0 means "day rebuilt, no value grouped". Showing 0 instead of null would tell your users they are losing no detail, which is false.
  • days_repaired says on how many of the days days the count is known. If days_repaired < days, folded_values is a partial sum, as in the example above.

capped only describes the dimension you asked for. It is also {"any": false, "dimensions": []} as soon as a filter applies to the ranking: the ranking is then read from raw events, where nothing is grouped.

summary and timeseries do not carry this key: they read no dimension and are insensitive to capping.

The dashboard CSV export carries the same indicator, but in the X-Cardinality-Capped HTTP header rather than in the file body: {"capped":false}, or {"capped":true,"dimension":"page","days":1,"days_repaired":1,"folded_values":2812,"cap":2000} scoped to the exported dimension only. The CSV body stays pure machine data, with no metadata row: no synthetic row can skew a total or break a fixed-arity parser.

This cap can be raised for your site: write to support.

PHP example

$response = json_decode(file_get_contents(
    'https://quietmetrics.dev/api/v1/stats/qm_pub_XXXX/summary?period=7d',
    false,
    stream_context_create(['http' => ['header' => "Authorization: Bearer YOUR_TOKEN\r\nAccept: application/json"]])
), true);

echo $response['kpis']['visitors'];

Errors

An error body is a JSON object whose message key describes the cause.

Code Meaning
401 Token missing, invalid, revoked or expired
403 The site is yours, but the token does not cover it, or your plan does not include the API (expired trial included)
403 Your account is suspended or awaiting approval: the API stays closed, whatever the plan
403 A new version of your contract documents is in force for your account and awaits your acceptance (reason is terms_acceptance_required, see below)
404 Unknown site, or one belonging to another account
422 Unknown breakdown dimension, a filters dimension you cannot filter on, an unknown filters operator, (none) on a dimension that always has a value, dimension=property without event and property or with filters, filters over a period that starts before the oldest day of detail kept, or a compare or granularity value outside the documented list
429 Too many requests: at most 120 per minute per token, and 300 per minute for the whole account, all tokens combined. The Retry-After header gives the wait time, in seconds

New version of the terms to accept

When a new material version of the Terms of Use, the Terms of Sale or the data processing agreement (DPA) is in force for your account and you have not accepted it, every call returns 403, just as your workspace then opens on the acceptance screen. It never applies without warning: an e-mail announces it at least 30 days before its effective date for your account, then reminders go out about 7 days before and the day before. The token stays valid: the API answers again as soon as you have accepted, with no change to your integration. The same screen also lets you refuse the new version.

Response body:

{
  "message": "A new version of a contract document is in force for your account and has not been accepted: Terms of Use. The read API is suspended until you accept it. Read it, then accept or refuse it at https://quietmetrics.dev/app/conditions.",
  "reason": "terms_acceptance_required",
  "accept_url": "https://quietmetrics.dev/app/conditions",
  "documents": [
    {"slug": "cgu", "version": "2026-11-02", "effective_at": "2026-12-03"}
  ]
}
  • reason is stable: test it, not the text of message. The message follows the language of the Accept-Language header (French, English or Spanish), or your account language otherwise.
  • accept_url is the page where you read, accept or refuse the new version.
  • documents lists each pending document (cgu for the Terms of Use, cgv for the Terms of Sale, dpa), the version to accept and its effective date for your account.

Best practices

  • Cache on your side: querying once an hour is more than enough. Be aware, though, that a closed day is not frozen for good: the nightly rebuild revisits capped days and can recompute their aggregates up to two days later. So plan for a short cache, or a re-query, on the last two days; beyond that, the values no longer move.
  • Read period in every response before displaying a figure: an invalid period does not produce an error, it is replaced with 30d.
  • One token per use case (one for the internal dashboard, one for the monthly report): revocation stays surgical, and two use cases do not compete for the same token's limit.
  • For a one-off export, every dashboard view can also be exported as CSV from the dashboard; no need to write code.