GET /api/devices
Returns a count of events grouped by device category for the given domain and optional date range. Device type is inferred from thescreen_width recorded in each event — no User-Agent parsing is performed.
Device categories are determined by the visitor’s
window.innerWidth (viewport width) at the time the event fires:| Screen width | Device category |
|---|---|
| < 768 px | Mobile |
| 768 – 1023 px | Tablet |
| ≥ 1024 px | Desktop |
Unlike other analytics endpoints,
/api/devices counts all event types — not just $pageview. If you want device breakdown by pageview only, filter client-side from the raw counts or raise a feature request.Query parameters
The domain to query (e.g.
example.com). Must match the d field sent in event payloads exactly.Start of the date range, inclusive. ISO 8601 date string (
YYYY-MM-DD). If omitted, results cover all time up to to.End of the date range, inclusive. ISO 8601 date string (
YYYY-MM-DD). If omitted, results cover all time from from.Response
Returns a JSON array of device stat objects, ordered bycount descending.
Device category:
Mobile, Tablet, or Desktop.Total number of events (all types) from that device category in the requested window.
Response shape
| Status | Meaning |
|---|---|
200 OK | Query succeeded (empty array if no data) |
400 Bad Request | domain query parameter is missing |
500 Internal Server Error | Database query failed |