AI Sparks

Google Health API Get CLI: ghealth is an open source tool for your Fitbit Air data

I Google Health API You are an official supporter of the Fitbit Web API. Targets Google Health API v4 and moves developers to Google OAuth 2.0. Now an open source CLI command line tool called ghealth it wraps that API for AI terminals and agents.

The tool is a single Go binary under the Apache 2.0 license. It exposes 40 validated data types as structured JSON. That design allows you to pipe sleep, heartbeat, and step data into the agent context.

What is ghealth?

ghealth wraps on top of Google Health API v4. You build from source with go build -o ghealth .. It ships as a single self-contained binary.

The tool is an agent first and foremost. Every command returns a simplified JSON with a stable format. It also provides prescribed exit codes, a --dry-run flag, and a --raw the flag.

The endpoint sends two Agent Skills as SKILL.md files. One includes auth, setup, and global flags. Some document all 40 data types, functions, patterns, and gotchas. Agents install them with npx skills add.

The CLI resides under the Google-Health-API GitHub Organization. That organization also hosts Fitbit’s long-standing open source repositories.

Data Area: 40 Certified Types

40 models cover most Fitbit and Pixel Watch signals. Examples include steps, heart-rate, sleep, weight, oxygen-saturationagain heart-rate-variability. Clinical forms such as electrocardiogram require i ecg.readonly width.

Each type supports a subset of functionality. Common ones exist list, rollup, daily-rollupagain reconcile. Writable types (exercise, sleep, weight, body-fat, height) added create, updateagain delete.

I reconcile performance combines overlapping data points from multiple sources. That includes the Reconciled Stream in the v4 API.

Sleep is a good example of pattern analysis. Default list returns a summary. In addition --detail returns phase-by-phase data (awake, deep, REM). That helps you see patterns from week to week.

The Setup: What Really Happens

Setup works with one command: ghealth setup. The wizard takes you through the GCP and OAuth project. You create a Desktop type OAuth client in the Google Cloud Console.

You supply your own OAuth credentials. The device does not hold the shared key. The files are listed below ~/.config/ghealth/ with file mode 0600. Tokens are automatically renewed.

All Google Health API programs are classified as restricted. Google requires a privacy and security update to reach production. For personal use, you authorize your project through your account. The API returns data from Fitbit, Pixel Watch, and third-party connected sources.

Headless streaming uses PKCE and S256 challenge. It also ensures randomness state parameter in completion.

Hands-On: Instructions and Outputs

Learning data is consistent across formats. Everything read returns an object with lines underneath dataPoints.

# Recent heart rate readings
ghealth data heart-rate list --from today --limit 10

# Daily step totals for a week
ghealth data steps daily-rollup --from 2026-03-22 --to 2026-03-29

# Sleep stages for the last five nights
ghealth data sleep list --limit 5 --detail

Complete steps to return the compiled JSON:

{
  "dataPoints": [
    {"date": "2026-03-28", "countSum": "9037"},
    {"date": "2026-03-27", "countSum": "2408"}
  ]
}

The output is simplified automatically. Use it --raw with the first API response. Use it --format csv or --format table in some cases. I -o flag writes the file and prints a preview of the schema.

Splitting pages is not lost. It’s big list he returns a nextPageToken. He passed it along --page-token download the next page.

Use Cases with examples

  • Enter sleep patterns and make an agent: Pull several nights with --detail. Enter the JSON into a Claude Code or Codex session. Ask an agent to summarize deep sleep trends during the week.
  • Download exercise for pandas: Run ghealth data exercise export-tcx --id --output ride.csv --as csv. Each line is a tracking point with heart rate and GPS. Then run pd.read_csv in the file.
  • Create an impression of a resting heart rate: Question daily-resting-heart-rate more than 30 days. Export CSV with --format csv. Chart in a notebook or on a dashboard.

How ghealth compares

The table below sets ghealth against the raw API and two other CLIs. The other two CLIs both identify themselves as illegal.

Attribute ghealth (this CLI) Google Health API v4 (direct REST) rudrankriyam/Google-Health-CLI googlehealth-cli (npm)
Enter git clone + go build Nothing; call HTTP/gRPC yourself Build from Go source npm i -g googlehealth-cli
Language Go, binary one Anywhere Go away Node.js
Auth Your OAuth client, PKCE S256 Google OAuth 2.0 Your OAuth client Your OAuth client
Agent output Simplified JSON, exit codes, SKILL.md Raw JSON / gRPC Predictable JSON It is stable --json an envelope
Data types 40 verified against the live API Full version of v4 Tracks recorded on top of v4 A subset of species
Legal status No; community, at Google-Health-API org Yes; Google No; it is illegal No; non-aligned states

For raw control, a straightforward REST API is the basic truth. Using the terminal and agent, ghealth reduces auth and formatting boilerplate.

Interactive Descriptor