Insights
Get sleep insights
Your sleep insights as the app shows them: per period (day, week or month) a score and rating with metrics (total sleep, efficiency, stages, sleep debt, consistency, breathing, heart rate, HRV and more) and comparisons to the prior period.
For days, the anchor day (or every day, with include_all_sessions) carries its sessions: onset and wake, sleep stages and heart rate / breath rate / HRV per epoch (each session's epoch_seconds gives the length, usually 30 s), and each session_id (for rate_sleep_sessions). Omit granularity for the default bundle (14 days, this and last week, this and last month).
Request parameters
Authorization string requiredYour API key as a bearer token: Bearer os_…. Make one on the API keys page; see Authentication.
granularityenum<string>Period size. Omit for the default bundle.
Possible values:
dayweekmonthanchorstring pattern ^\d{4}-\d{2}-\d{2}$YYYY-MM-DD inside the last period to return. Defaults to today.
countinteger min 1max 60Periods to return, ending at the anchor (1–60). Defaults: day 14, week 8, month 6.
include_all_sessionsbooleanDay granularity only: every day's sessions with their per-epoch arrays, not just the anchor day's. At most 31 days with this on.
Response parameters
user_idstring requiredtimezonestring requiredgranularitiesrecord<string, object> requiredPer granularity (day / week / month): periods with scores, metrics and sessions
Errors
Every error answers { "error": { "code", "message" } }.
get_insights