query_metric_series
Build a dated trend for steps, distance, active calories, or weight over an inclusive YYYY-MM-DD range, with day, week, or month grouping from locally cached Mi Fitness records.
Instructions
Build a dated trend for steps (count), distance_m (meters), active_kcal (kcal), or weight_kg (kg) over an inclusive YYYY-MM-DD range. Returns data.metric and data.series [{date, value}], sorted ascending, without filling missing dates. Activity uses daily totals; weight uses the latest stored measurement per day. granularity=day returns these daily values; week groups from Monday, month from the first day. aggregation (default sum) applies only to week/month daily values; latest selects the last available day. Prefer avg or latest for weight. For raw body readings use query_body_measurements; heart-rate samples use query_heart_rate; one workout uses query_workout_series. 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. | |
| metric | Yes | Metric and output units: steps=count, distance_m=meters, active_kcal=kcal, weight_kg=kg. | |
| 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. | |
| aggregation | No | Reducer over daily values in week/month buckets; ignored for day. latest means last available date; avg excludes missing days. Prefer avg/latest for weight. | sum |
| granularity | No | day returns daily values; week groups by Monday; month by first day. Missing days are not zero-filled. | day |