Google Health API に CLI ツール「ghealth」登場:Fitbit データを AI エージェントへ
Google Health API v4 の公式後継である Fitbit Web API を、CLI ツール「ghealth」がラップし、AI エージェントによるヘルスデータ処理を可能にするオープンソース実装が登場した。
キーポイント
エージェント特化型 CLI ツールの登場
Go で書かれた単一バイナリ「ghealth」が、Google Health API v4 をラップし、AI エージェントやターミナルからのデータアクセスを可能にする。
構造化された 40 種類のデータタイプ
歩数、心拍数、睡眠など主要なヘルスデータを 40 種類サポートし、安定した JSON 形式で出力することでエージェントのコンテキストへのパイプライン化を容易にする。
自動化とセキュリティの実装
OAuth 2.0 と PKCE プロトコルを活用し、自動トークン更新やドライラン機能を提供しながら、個人利用におけるプライバシー保護を実現している。
多様な出力形式とファイル保存機能
デフォルトでは簡略化された JSON が返されますが、--raw で生レスポンスを、--format csv/table で他の形式を取得でき、-o フラグでファイルを直接保存できます。
大規模データへの完全なページネーション対応
大量のリスト取得時に nextPageToken が返され、--page-token を使用して次のページを順次フェッチできるため、データ漏れなく取得可能です。
影響分析・編集コメントを表示
影響分析
このツールは、ヘルスケアデータと AI エージェントを接続するための標準的なインターフェースを提供し、自律型ヘルスケアアプリケーションやパーソナルトレーナー AI の開発を劇的に加速させる可能性があります。特に、構造化された JSON 出力と安定した API 設計により、複雑な認証処理なしで即座にプロトタイプ開発が可能になる点は、業界全体の実用化スピードを高める重要な一歩です。
編集コメント
開発者が手動で API を叩く手間を省き、AI エージェントが健康データを自律的に処理できる環境を整えた点で、ヘルスケア分野の AI 実装における重要なインフラ整備と言えます。
Google Health API は、Fitbit Web API の公式後継者です。これは Google Health API v4 を対象としており、開発者を Google OAuth 2.0 へと移行させます。現在、ターミナルや AI エージェント向けにこの API をラップするオープンソースの CLI コマンドラインツール「ghealth」が登場しました。
本ツールは Apache 2.0 ライセンスの下で提供される単一の Go バイナリです。40 の検証済みデータタイプを構造化 JSON として公開します。この設計により、睡眠、心拍数、歩数のデータをエージェントのコンテキストにパイプラインで流し込むことが可能になります。
ghealth とは何か?
ghealth は Google Health API v4 上のラッパーです。ソースコードから go build -o ghealth .. コマンドでビルドします。1 つの自己完結型バイナリとして配布されます。
本ツールは明示的にエージェントファーストに設計されています。すべてのコマンドは、安定した形状を持つ簡略化された JSON を返します。また、決定論的な終了コード、--dry-run フラグ、および --raw フラグも提供しています。
リポジトリには 2 つの Agent Skills が SKILL.md ファイルとして同梱されています。1 つ目は認証、セットアップ、グローバルフラグをカバーするものであり、もう 1 つ目はすべての 40 のデータタイプ、操作、パターン、および注意点を文書化したものです。エージェントは npx skills add コマンドでこれらをインストールします。
CLI は Google-Health-API GitHub オrganization に存在します。この組織はまた、長年運営されている Fitbit のオープンソースリポジトリもホストしています。
データサーフェス:40 件の検証済みタイプ
40 のタイプは、Fitbit および Pixel Watch のシグナルのほとんどを網羅しています。例としては、歩数、心拍数、睡眠、体重、酸素飽和度、および心拍変動があります。心電図などの臨床データタイプには、ecg.readonly スコープが必要です。
各タイプは操作のサブセットをサポートしています。一般的な操作には、list(一覧表示)、rollup(集計)、daily-rollup(日次集計)、reconcile(照合)があります。書き込み可能なタイプ(exercise(運動)、sleep(睡眠)、weight(体重)、body-fat(体脂肪率)、height(身長))では、create(作成)、update(更新)、delete(削除)が追加されます。
reconcile 操作は、複数のソースからの重複するデータポイントを統合します。これは v4 API の Reconciled Stream に相当します。
睡眠データはパターン分析の好例です。デフォルトの list コマンドでは要約情報が返されますが、--detail オプションを指定すると、段階ごとの詳細データ(覚醒、深部睡眠、REM 睡眠)が取得できます。これにより、週ごとのパターンを把握しやすくなります。
セットアップ:実際に行われること
セットアップは単一のコマンド ghealth setup で実行されます。ウィザードが GCP プロジェクトと OAuth の設定を案内します。Google Cloud Console で Desktop タイプの OAuth クライアントを作成する必要があります。
OAuth 認証情報はユーザー自身が用意します。このツールは共有キーを保持しません。ファイルは ~/.config/ghealth/ ディレクトリに、権限モード 0600 で書き込まれます。トークンは自動的に更新されます。
Google Health API のすべてのスコープは「Restricted(制限付き)」に分類されています。本番環境でのアクセスには、プライバシーおよびセキュリティ審査が Google によって要求されます。個人利用の場合、ユーザーは自身のアカウントに対して自身のプロジェクトを認証します。この API は Fitbit、Pixel Watch、および接続されたサードパーティソースからのデータを返します。
ヘッドレスフローでは、PKCE(Proof Key for Code Exchange)方式の S256 チャレンジが使用され、完了時にランダムな state パラメータも検証されます。
実践:コマンドと出力
データ読み取りはタイプを問わず一貫しています。すべての読み取り操作は、dataPoints フィールドに rows を含むオブジェクトを返します。
Copy CodeCopiedUse a different Browser
最近の心拍数データ
ghealth data heart-rate list --from today --limit 10
1 週間の歩数合計
ghealth data steps daily-rollup --from 2026-03-22 --to 2026-03-29
過去 5 晩の睡眠ステージ
ghealth data sleep list --limit 5 --detail
歩数の結果は集約された JSON 形式で返されます:
Copy CodeCopiedUse a different Browser
{
"dataPoints": [
{"date": "2026-03-28", "countSum": "9037"},
{"date": "2026-03-27", "countSum": "2408"}
]
}
出力はデフォルトで簡略化されます。元の API レスポンスを取得するには --raw を使用してください。また、--format csv または --format table を指定することで、他の形式(CSV やテーブル)での出力も可能です。-o フラグを使用するとファイルに書き出し、スキーマのプレビューも表示されます。
ページネーションは完全なデータ保持を前提としています。大量のリストを取得する場合は nextPageToken が返されます。このトークンを --page-token として渡すことで、次のページのデータを取得できます。
使用例と具体案
睡眠パターンをエージェントに読み込ませる: --detail オプションで数晩分のデータを取得し、その JSON を Claude Code や Codex のセッションにパイプします。エージェントに対して、1 週間の深い睡眠の傾向を要約するよう指示してください。
ワークアウトデータを pandas に読み込む: ghealth data exercise export-tcx --id [ID] --output ride.csv --as csv コマンドを実行します。各行は心拍数と GPS データを含む 1 つのトラックポイントです。その後、pd.read_csv でファイルを読み込みます。
安静時心拍数のビューを構築する: 30 日間の daily-resting-heart-rate をクエリし、--format csv で CSV 形式で出力します。ノートブックやダッシュボードでグラフ化してください。
ghealth の比較
以下の表は、ghealth を生 API および他の 2 つの CLI と比較したものです。他の 2 つの CLI はどちらも公式ではないことを自ら明記しています。
ghealth(この CLI)Google Health API v4(直接 REST)rudrankriyam/Google-Health-CLI googlehealth-cli (npm)
インストール方法
git clone + go build 不要;HTTP/gRPC を自分で呼び出す Go ソースからビルド npm i -g googlehealth-cli
言語 Go、単一バイナリ Any(任意の言語)Go Node.js
認証 自分の OAuth クライアント、PKCE S256 Google OAuth 2.0 自分の OAuth クライアント 自分の OAuth クライアント
エージェント出力 簡略化された JSON、終了コード、SKILL.md 生 JSON / gRPC 予測可能な JSON 安定した --json エンベロープ
データ型 40 種類がライブ API で検証済み v4 の全表面をカバー ドキュメント化された v4 表面の一部 タイプのサブセット
公式ステータス いいえ;コミュニティ、Google-Health-API オrg 内 Yes; Google はいえ;非公式と表明 いいえ;無関係と表明
生制御が必要な場合は、直接 REST API が真実の基準です。ターミナルやエージェントの使用においては、ghealth は認証とフォーマットのボイラープレート(定型コード)を削減します。
インタラクティブな解説器
(function(){
var f = document.getElementById('mtp-ghealth-iframe');
window.addEventListener('message', function(e){
if(e && e.data && e.data.type === 'ghealth-resize' && e.data.height){
f.style.height = e.data.height + 'px';
}
});
})();
リポジトリをチェックしてください。また、Twitter でフォローすることも歓迎しますし、150,000 人以上の ML サブレディットに参加したり、ニュースレターを購読することを忘れないでください。待ってください!Telegram を使っていますか?今なら Telegram でも私たちに参加できます。
GitHub リポジトリや Hugging Face ページ、製品リリース、ウェビナーなどのプロモーションのためにパートナーシップを結ぶ必要がある場合は、ご連絡ください
The post The Google Health API Got a CLI: ghealth is an Open-Source Tool for Your Fitbit Air Data appeared first on MarkTechPost.
この投稿「Google Health API に CLI が登場:ghealth はあなたの Fitbit Air データのためのオープンソースツール」は、MarkTechPost で最初に公開されました。
原文を表示
The Google Health API is the official successor to the Fitbit Web API. It targets the Google Health API v4 and moves developers onto Google OAuth 2.0. Now an open-source CLI command-line tool called ghealth wraps that API for terminals and AI agents.
The tool is a single Go binary under the Apache 2.0 license. It exposes 40 verified data types as structured JSON. That design lets you pipe sleep, heart rate, and step data into an agent’s context.
What is ghealth?
ghealth is a wrapper over the Google Health API v4. You build it from source with go build -o ghealth .. It ships as one self-contained binary.
The tool is explicitly agent-first. Every command returns simplified JSON with a stable shape. It also provides deterministic exit codes, a --dry-run flag, and a --raw flag.
The repository ships two Agent Skills as SKILL.md files. One covers auth, setup, and global flags. The other documents all 40 data types, operations, patterns, and gotchas. Agents install them with npx skills add.
The CLI lives under the Google-Health-API GitHub organization. That organization also hosts long-standing Fitbit open-source repositories.
The Data Surface: 40 Verified Types
The 40 types cover most Fitbit and Pixel Watch signals. Examples include steps, heart-rate, sleep, weight, oxygen-saturation, and heart-rate-variability. Clinical types like electrocardiogram require the ecg.readonly scope.
Each type supports a subset of operations. Common ones are list, rollup, daily-rollup, and reconcile. Writable types (exercise, sleep, weight, body-fat, height) add create, update, and delete.
The reconcile operation merges overlapping data points from multiple sources. That mirrors the Reconciled Stream in the v4 API.
Sleep is a good example for pattern analysis. The default list returns a summary. Adding --detail returns stage-by-stage data (awake, deep, REM). That helps you spot patterns week over week.
Setup: What Actually Happens
Setup runs through one command: ghealth setup. A wizard walks you through the GCP project and OAuth. You create a Desktop-type OAuth client in the Google Cloud Console.
You bring your own OAuth credentials. The tool holds no shared key. Files are written under ~/.config/ghealth/ with file mode 0600. Tokens refresh automatically.
All Google Health API scopes are classified as Restricted. Google requires a privacy and security review for production access. For personal use, you authorize your own project against your own account. The API returns data from Fitbit, Pixel Watch, and connected third-party sources.
The headless flow uses PKCE with an S256 challenge. It also validates a random state parameter on completion.
Hands-On: Commands and Output
Reading data is consistent across types. Every read returns an object with rows under dataPoints.
Copy CodeCopiedUse a different Browser
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
Step totals return aggregated JSON:
Copy CodeCopiedUse a different Browser
{
"dataPoints": [
{"date": "2026-03-28", "countSum": "9037"},
{"date": "2026-03-27", "countSum": "2408"}
]
}
Output is simplified by default. Use --raw for the original API response. Use --format csv or --format table for other shapes. The -o flag writes a file and prints a schema preview.
Pagination is lossless. A large list returns a nextPageToken. You pass it back with --page-token to fetch the next page.
Use Cases With Examples
Feed sleep patterns into an agent: Pull several nights with --detail. Pipe the JSON into a Claude Code or Codex session. Ask the agent to summarize deep-sleep trends over the week.
Load workouts into pandas: Run ghealth data exercise export-tcx --id <id> --output ride.csv --as csv. Each row is one trackpoint with heart rate 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 notebook or a dashboard.
How ghealth Compares
The table below sets ghealth against the raw API and two other CLIs. The other two CLIs both self-identify as unofficial.
Attributeghealth (this CLI)Google Health API v4 (direct REST)rudrankriyam/Google-Health-CLIgooglehealth-cli (npm)
Installgit clone + go buildNone; call HTTP/gRPC yourselfBuild from Go sourcenpm i -g googlehealth-cli
LanguageGo, single binaryAnyGoNode.js
AuthYour own OAuth client, PKCE S256Google OAuth 2.0Your own OAuth clientYour own OAuth client
Agent outputSimplified JSON, exit codes, SKILL.mdRaw JSON / gRPCPredictable JSONStable --json envelope
Data types40 verified against live APIFull v4 surfaceTracks documented v4 surfaceSubset of types
Official statusNo; community, in Google-Health-API orgYes; GoogleNo; states unofficialNo; states unaffiliated
For raw control, the direct REST API is the ground truth. For terminal and agent use, ghealth reduces auth and formatting boilerplate.
Interactive Explainer
(function(){
var f = document.getElementById('mtp-ghealth-iframe');
window.addEventListener('message', function(e){
if(e && e.data && e.data.type === 'ghealth-resize' && e.data.height){
f.style.height = e.data.height + 'px';
}
});
})();
Check out the Repo. Also, feel free to follow us on Twitter and don’t forget to join 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 partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us
The post The Google Health API Got a CLI: ghealth is an Open-Source Tool for Your Fitbit Air Data appeared first on MarkTechPost.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み