Add intraday export; simplify OAuth scope - #4
Merged
Conversation
Adds `withings-export intraday` for minute-level samples (HR, HRV rmssd/sdnn1, SpO2, steps, distance) from `/v2/measure?action= getintradayactivity`. Withings caps each request to a 24h window, so the command chunks automatically from `--since` to now. This is the real data stream for accounts whose only live source is an Apple Watch via HealthKit: Withings stores the raw samples but does not compute a sleep summary from them, which is why `sleep` returns empty for recent dates on such accounts. Also simplifies the OAuth scope: drops `user.sleepevents` (per Withings docs, that grant is webhook-only — Notify endpoints for bed-in/bed-out — and unrelated to sleep data retrieval, which is already covered by `user.activity`). Adds `user.info` so device listing works if we expose it later. Users will need to re-run `auth login` to consent to the adjusted scope set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
withings-export intradaysubcommand exports minute-level samples (HR, HRV rmssd/sdnn1, SpO2, steps, distance) from/v2/measure?action=getintradayactivity. Withings caps each call at a 24h window, so the command chunks from--sinceto now automatically. Default window is 1d; CSV or--jsonoutput.user.sleepevents(per Withings docs it is webhook-only — Notify endpoints for bed-in/bed-out — and not involved in sleep data retrieval, which is already covered byuser.activity). Addsuser.infoso device listing is available for later use.Why
For accounts whose only live data source is an Apple Watch via HealthKit, Withings stores the raw minute-level signal but never computes a sleep summary from it — so
sleepcorrectly returns empty for recent dates even though Health Mate renders a derived sleep view. Intraday is the actual data stream; exposing it lets users get sleep-adjacent data (overnight HR/HRV/SpO2 curves) and build their own analyses.Test plan
go build ./...cleango vet ./...cleanauth logincompletes with the new scope set and writes a valid tokenintraday --since 6dreturns 7,109 samples across 6 days (HR 6,488; SpO2 113; HRV 68; steps/distance 391; calories 338)measurements --since 2d,activity --since 3d,workouts --since 3d,sleep --since 2013-07-01(1,745 historical nights) all still workBreaking
auth loginafter upgrading to re-consent to the adjusted scope list.🤖 Generated with Claude Code