query_sleep
Read cached sleep sessions and main-sleep summaries by inclusive start_date and end_date, with optional naps, pagination, and data-quality details.
Instructions
Read sleep sessions (start-date filtered) and a main-sleep summary (local wake-date filtered) over an inclusive YYYY-MM-DD range. Returns data.sessions, count, main_sessions, metrics and data_quality; main sleep is the longest valid non-nap per wake date. include_naps defaults true and affects the raw list only, not main-sleep selection. Times include start_at/end_at; durations are minutes; sleep_score/source can be null and missing scores are not zero. Expand dates around midnight if needed; raw counts can differ from wake-date summary counts. Use this instead of query_daily_activity for sleep. Pagination affects sessions/count only; main_sessions, metrics and quality still describe the full date range, so keep ranges narrow. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum records per page (1-5000); count describes this page only. | |
| offset | No | Zero-based position; pass pagination.next_offset unchanged with the same filters. | |
| end_date | Yes | Inclusive last calendar date, YYYY-MM-DD; must be on or after start_date. | |
| start_date | Yes | Inclusive first calendar date, YYYY-MM-DD; must be on or before end_date. Uses stored calendar dates, not caller timezone conversion. | |
| include_naps | No | Include naps in raw sessions (default true); main-sleep summary always excludes naps. |