Stats & Insights
Beyond raw readings, the public API offers precomputed analytics. All endpoints are GET under /api/v1/public/patients/:patientId/, need the read scope and a key linked to the patient.
Endpoints
| Endpoint | Window | Returns |
|---|---|---|
…/stats | Last 7 days (fixed) | Advanced stats: TIR, CV, patterns, stability, milestones |
…/insights | Last 30 days (fixed) | Longer-horizon patterns and observations |
…/readings/resampled | Last 24h (or startTime/endTime) | 15-minute resampled series |
…/daily/:date | One day (YYYY-MM-DD) | That day’s readings + { min, max, avg, tir, count } (stats: null when empty) |
…/events | Last 7 days (or startTime/endTime), paginated max 100 | Meals, insulin, exercise, notes, medication |
…/custom-levels | — | Patient thresholds { veryLow, low, high, veryHigh }, or null when unset |
curl "https://api.levelcast.org/api/v1/public/patients/PATIENT_ID/stats" \ -H "X-API-KEY: lc_your_key_here"
curl "https://api.levelcast.org/api/v1/public/patients/PATIENT_ID/daily/2026-10-01" \ -H "X-API-KEY: lc_your_key_here"
curl "https://api.levelcast.org/api/v1/public/patients/PATIENT_ID/events?startTime=2026-09-01T00:00:00.000Z&page=1&limit=50" \ -H "X-API-KEY: lc_your_key_here"Pagination
List endpoints accept page (1-based) and limit and return { success: true, data: […], pagination: { page, limit, total } }. Per-endpoint caps: readings history 50, most lists 100.
Patient events (CRUD)
Events are also writable (write scope) — see the API reference:
POST …/events—eventTime,eventType(meal|insulin|exercise|note|medication), optionalsubType,value,valueUnit,notes,metadata→201 { data: { id } }GET/PUT/DELETE …/events/:eventId— the event must belong to the patient in the path