Fitbit Air Export

A small, free Python script that copies your own Fitbit data (sleep, resting heart rate, heart rate variability, blood oxygen, steps, active minutes) from Google to plain files on your computer: one JSON file per day, plus a CSV and a Markdown table. It is for people who keep a journal or notes and want their numbers next to them.

What it does

Setup, once

  1. Sign in to the Google Health (Fitbit) app on your phone with your Google account.
  2. In the Google Cloud console, create a project and enable the Google Health API.
  3. Under Google Auth Platform: set up the consent screen (External), add yourself as a test user, and on Data Access add the scopes googlehealth.sleep.readonly, googlehealth.activity_and_fitness.readonly and googlehealth.health_metrics_and_measurements.readonly.
  4. Create an OAuth client of type Desktop app, download its JSON, and save it as ~/.google-health/client_secret.json.
  5. Run python fitbit_export.py auth and approve access in the browser.

While your Google project is in "Testing", Google expires the sign-in after 7 days, so you'd run auth again weekly. Publishing your own project removes that.

Daily use

python fitbit_export.py                 # last 3 days into ./fitbit-data
python fitbit_export.py --days 30       # backfill
python fitbit_export.py --out ~/notes/fitbit

Schedule it (Task Scheduler, cron, launchd) for an hour or two after you usually wake, once your phone has synced. It re-pulls the last three days each run, so a late sync fills itself in.

Links