|

The Google Health API Got a CLI: ghealth is an Open-Source Tool for Your Fitbit Air Data

The Google Health API is the official successor to the Fitbit Web API. It targets the Google Health API v4 and strikes builders onto Google OAuth 2.0. Now an open-source CLI command-line instrument referred to as ghealth wraps that API for terminals and AI brokers.

The instrument is a single Go binary below the Apache 2.0 license. It exposes 40 verified knowledge sorts as structured JSON. That design helps you to pipe sleep, coronary heart charge, and step knowledge into an agent’s context.

What is ghealth?

ghealth is a wrapper over the Google Health API v4. You construct it from supply with go construct -o ghealth .. It ships as one self-contained binary.

The instrument is explicitly agent-first. Every command returns simplified JSON with a steady form. It additionally gives deterministic exit codes, a --dry-run flag, and a --raw flag.

The repository ships two Agent Skills as SKILL.md recordsdata. One covers auth, setup, and world flags. The different paperwork all 40 knowledge sorts, operations, patterns, and gotchas. Agents set up them with npx abilities add.

The CLI lives below the Google-Health-API GitHub group. That group additionally hosts long-standing Fitbit open-source repositories.

The Data Surface: 40 Verified Types

The 40 sorts cowl most Fitbit and Pixel Watch indicators. Examples embrace steps, heart-rate, sleep, weight, oxygen-saturation, and heart-rate-variability. Clinical sorts like electrocardiogram require the ecg.readonly scope.

Each sort helps a subset of operations. Common ones are listing, rollup, daily-rollup, and reconcile. Writable sorts (train, sleep, weight, body-fat, top) add create, replace, and delete.

The reconcile operation merges overlapping knowledge factors from a number of sources. That mirrors the Reconciled Stream within the v4 API.

Sleep is a good instance for sample evaluation. The default listing returns a abstract. Adding --detail returns stage-by-stage knowledge (awake, deep, REM). That helps you see patterns week over week.

Setup: What Actually Happens

Setup runs by way of one command: ghealth setup. A wizard walks you thru the GCP mission and OAuth. You create a Desktop-type OAuth consumer within the Google Cloud Console.

You carry your personal OAuth credentials. The instrument holds no shared key. Files are written below ~/.config/ghealth/ with file mode 0600. Tokens refresh mechanically.

All Google Health API scopes are labeled as Restricted. Google requires a privateness and safety overview for manufacturing entry. For private use, you authorize your personal mission towards your personal account. The API returns knowledge from Fitbit, Pixel Watch, and linked third-party sources.

The headless circulation makes use of PKCE with an S256 problem. It additionally validates a random state parameter on completion.

Hands-On: Commands and Output

Reading knowledge is constant throughout sorts. Every learn returns an object with rows below dataPoints.

# Recent coronary heart charge readings
ghealth knowledge heart-rate listing --from right now --limit 10

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

# Sleep phases for the final 5 nights
ghealth knowledge sleep listing --limit 5 --detail

Step totals return aggregated JSON:

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

Output is simplified by default. Use --raw for the unique API response. Use --format csv or --format desk for different shapes. The -o flag writes a file and prints a schema preview.

Pagination is lossless. A big listing returns a subsequentPageToken. You go it again with --page-token to fetch the following web page.

Use Cases With Examples

  • Feed sleep patterns into an agent: Pull a number of nights with --detail. Pipe the JSON into a Claude Code or Codex session. Ask the agent to summarize deep-sleep traits over the week.
  • Load exercises into pandas: Run ghealth knowledge train export-tcx --id <id> --output trip.csv --as csv. Each row is one trackpoint with coronary heart charge and GPS. Then run pd.read_csv on the file.
  • Build a resting heart-rate view: Query daily-resting-heart-rate over 30 days. Emit CSV with --format csv. Chart it in a pocket book or a dashboard.

How ghealth Compares

The desk beneath units ghealth towards the uncooked API and two different CLIs. The different two CLIs each self-identify as unofficial.

Attribute ghealth (this CLI) Google Health API v4 (direct REST) rudrankriyam/Google-Health-CLI googlehealth-cli (npm)
Install git clone + go construct None; name HTTP/gRPC your self Build from Go supply npm i -g googlehealth-cli
Language Go, single binary Any Go Node.js
Auth Your personal OAuth consumer, PKCE S256 Google OAuth 2.0 Your personal OAuth consumer Your personal OAuth consumer
Agent output Simplified JSON, exit codes, SKILL.md Raw JSON / gRPC Predictable JSON Stable --json envelope
Data sorts 40 verified towards stay API Full v4 floor Tracks documented v4 floor Subset of sorts
Official standing No; neighborhood, in Google-Health-API org Yes; Google No; states unofficial No; states unaffiliated

For uncooked management, the direct REST API is the bottom reality. For terminal and agent use, ghealth reduces auth and formatting boilerplate.

Interactive Explainer


Check out the Repo. Also, be happy to observe us on Twitter and don’t neglect to hitch our 150k+ML SubReddit and Subscribe to our Newsletter. Wait! are you on telegram? now you can join us on telegram as well.

Need to associate with us for selling your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar and so forth.? Connect with us

The submit The Google Health API Got a CLI: ghealth is an Open-Source Tool for Your Fitbit Air Data appeared first on MarkTechPost.

Similar Posts