Skip to main content
Published7 min read
By Brian C., US Navy veteran, CPAP user since 2023

Export Fitbit Data with the Google Health CLI

Pull your Fitbit sleep, heart rate, HRV, and SpO2 with Google's free command-line tool and import them into CPAP Clarity, no Takeout wait.

Reviewed by the CPAP Clarity editorial team. Last updated July 5, 2026.

Google Takeout is the usual way to get your Fitbit history out, but it does not work for everyone. If your Fitbit history goes back years, the export is enormous and slow to prepare. If your Google account uses Advanced Protection, every Takeout request is held for days or even weeks. Either way, you can be stuck waiting when all you wanted was last night's numbers.

There is a faster path. Google now publishes a free command-line tool called the Google Health CLI (its command is ghealth) that pulls your Fitbit and Pixel Watch data straight from the Google Health API in seconds. You run it on your own computer, it saves a few small files, and you drag those into CPAP Clarity the same way you would any export. This guide walks through it start to finish.

Medical disclaimer. Wearable readings are informational, not diagnostic. Fitbit sleep stages, HRV, heart rate, and SpO2 are wellness estimates, not clinical measurements. Do not change your CPAP therapy, medications, or lifestyle based on these numbers without talking to your sleep physician first.

Step 1: Install the Google Health CLI

The tool is free and open source, published by Google at github.com/Google-Health-API/google-health-cli (opens in new tab). It runs on Windows, Mac, and Linux, and it ships as a single program with no extra software to set up. Follow the install instructions on that page for your operating system.

You will use it from a terminal (Terminal on Mac, Command Prompt or PowerShell on Windows). If you have never opened a terminal before, do not worry, you only need to paste in a handful of lines.

Step 2: Connect It to Your Google Account

Run the one-time setup:

ghealth setup

This opens your browser and asks you to sign in with the Google account your Fitbit is on, then grant read access to your health data. This is Google's own sign-in, the same one you already use, and the permission it asks for is read-only. Nothing about your account password is ever shared with the tool or with CPAP Clarity.

Once setup finishes, the tool remembers your sign-in, so you only do this part once.

Step 3: Export Your Four Metrics

CPAP Clarity reads four channels from Fitbit: sleep, heart rate, heart rate variability, and blood oxygen. Run these four commands to save each one. Change the date after --from to the earliest night you want:

ghealth data sleep list --detail --from 2026-07-01 > ghealth_sleep_output.json
ghealth data heart-rate list --limit 500000 --from 2026-07-01 > ghealth_hr_output.json
ghealth data heart-rate-variability list --limit 500000 --from 2026-07-01 > ghealth_hrv_output.json
ghealth data oxygen-saturation list --limit 500000 --from 2026-07-01 > ghealth_spo2_output.json

Each line saves one file. The file names matter, so keep them exactly as written above (that is how CPAP Clarity recognizes a Google Health export). The --detail on the sleep line is what gives you the full stepped sleep-stage graph; leave it off and you still get the stage minutes, just not the graph. When the commands finish, you will have four files sitting together in one folder.

A tip if you want a whole stretch of nights at once: pick an earlier --from date. The tool returns every night in the range, not just one.

Step 4: Drop the Folder into CPAP Clarity

Put the four files in a single folder, then open CPAP Clarity and drag that folder onto the import area on the home page. It imports exactly like a normal Fitbit export. Your data is processed right in your browser and never leaves your device, the same privacy promise as every other import.

If you already have CPAP data loaded, your Fitbit nights line up with your therapy nights automatically by date, so you can see both streams together.

Step 5: What You Will See

Once it imports, each night shows the Fitbit signals your CPAP cannot measure:

  • Sleep stages. The stepped stage graph plus minutes of deep, light, and REM sleep and time awake (the graph needs the --detail flag above).
  • Overnight heart rate. Your average, low, and high heart rate across the sleep window.
  • Blood oxygen. Your average overnight SpO2 and your lowest reading of the night, with obvious sensor glitches filtered out. The average is cross-checked against what the Google Health app itself reports.

A couple of honest notes on what this export does not show. Fitbit's own sleep score and your resting heart rate are not offered by the Google Health tool, so those stay blank. Heart rate variability is held back too: the tool gives the raw readings, but Google computes its nightly HRV figure in a way that cannot be reproduced from them, and we would rather leave a number off than print one that disagrees with what your app shows you.

To understand what each of these numbers means alongside your therapy data, see using your Fitbit to see what CPAP misses.

Frequently Asked Questions

Do I still need Google Takeout?

No. This is a complete alternative for getting your Fitbit data in. If Takeout works fine for you, you can keep using it; CPAP Clarity reads both. The CLI simply skips the wait, which is the whole point for people stuck behind a slow or delayed Takeout.

Is my health data private?

Yes. The CLI pulls your data from Google to your own computer, and CPAP Clarity processes the files entirely in your browser. Your sleep and health data never touch our servers. See our data privacy page for the full explanation.

Why not just connect my Google account inside the website?

A website cannot read Google Health data directly without a heavy account-verification process, and we would rather not ask you to connect accounts at all. The CLI keeps you in control: you run it, you hold the sign-in, and only the small files you choose ever reach the app.

Which devices does this work with?

Any Fitbit or Pixel Watch whose data syncs to Google Health. The tool stamps your exact model on the data, so a Pixel Watch shows as a Pixel Watch.

My CPAP and Fitbit times are an hour apart during daylight saving. Why?

That usually means your CPAP machine's clock was never changed for daylight saving, while your watch follows it automatically. Your Fitbit times here are correct to your local time. There is a one-time fix built in: above the detailed night charts, turn on "CPAP clock ignores daylight saving" and the CPAP charts shift an hour on daylight-saving nights to line up with your watch, automatically, every season. It only changes what the charts show; your recorded data is never modified.

See Your Whole Night in One Place

Fitbit data is at its best next to your CPAP and oximeter data on one screen. Once your Fitbit nights are in, read all your sleep data in one place to see how the streams fit together, or browse the wearables that can flag sleep apnea. On a phone instead of a computer? Here is how to import on iPhone, iPad, or Android.

Import your Fitbit data now →

Related Guides

See what your SD card reveals

Drop in your ResMed data. No account, no uploads, no cost.

Analyze your data