Skip to content

Add intraday export; simplify OAuth scope - #4

Merged
DTTerastar merged 1 commit into
mainfrom
feat/intraday-export
Apr 20, 2026
Merged

Add intraday export; simplify OAuth scope#4
DTTerastar merged 1 commit into
mainfrom
feat/intraday-export

Conversation

@DTTerastar

Copy link
Copy Markdown
Contributor

Summary

  • New withings-export intraday subcommand 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 --since to now automatically. Default window is 1d; CSV or --json output.
  • Simplifies OAuth scope: drops 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 by user.activity). Adds user.info so 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 sleep correctly 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 ./... clean
  • go vet ./... clean
  • auth login completes with the new scope set and writes a valid token
  • intraday --since 6d returns 7,109 samples across 6 days (HR 6,488; SpO2 113; HRV 68; steps/distance 391; calories 338)
  • Existing commands unchanged: measurements --since 2d, activity --since 3d, workouts --since 3d, sleep --since 2013-07-01 (1,745 historical nights) all still work

Breaking

  • Users must re-run auth login after upgrading to re-consent to the adjusted scope list.

🤖 Generated with Claude Code

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>
@DTTerastar
DTTerastar merged commit 75f8d3f into main Apr 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant