Google Health API 有了 CLI:ghealth 是專為 Fitbit 資料設計的開源工具
重點摘要
Google Health API 是 Fitbit Web API 的官方後繼者,它鎖定 Google Health API v4,並讓開發者遷移至 Google OAuth 2.0。現在,一款名為 ghealth 的開源 CLI 命令列工具將該 API 包裝起來,適用於終端機與 AI 代理。該工具是單一的 Go 二進位檔,採用 Apache 2.0 授權。它將 40 種經過驗證的資料類型以結構化 JSON 形式呈現,讓你能將睡眠、心率與步數資料直接導入代理的上下文。什麼是 ghealth?ghealth 是 Google Health API v4 的包裝工具。你可以透過 go build -o ghealth . 從原始碼建置,產出一個自包含的二進位檔。該工具明確以代理為優先,每個指令都會回傳形狀穩定的簡化 JSON。此外,它還提供確定性錯誤碼、--dry-run 旗標與 --raw 旗標。
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-cliLanguageGo, single binaryAnyGoNode.jsAuthYour own OAuth client, PKCE S256Google OAuth 2.0Your own OAuth clientYour own OAuth clientAgent outputSimplified JSON, exit codes, SKILL.mdRaw JSON / gRPCPredictable JSONStable --json envelopeData types40 verified against live APIFull v4 surfaceTracks documented v4 surfaceSubset of typesOfficial 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.
Related
相關文章

收費之後,他們會從“豆包一下”改回“百度一下”嗎?
文章指出,某服務的市佔率第一並非純靠實力,而是依賴大量市場投入。在收費政策實施後,用戶可能從使用「豆包一下」改回「百度一下」。這反映了市場投入與用戶選擇之間的關係。

Claude Sonnet 5 發佈了,但中國開發者可能用不上:一場“斷供”後的國產編程模型突圍戰
Claude Sonnet 5 發佈,性能強大,但中國開發者因斷供可能無法使用,面臨不穩定的選擇。這促使國產編程模型抓住機會,在遷移窗口期加速突圍。中國開發者正轉向本土替代方案,以應對國際模型供應中斷的挑戰。

世界模型來了因果技術標杆!具身大腦真要長腦子了
這篇消息聚焦「世界模型來了因果技術標杆!具身大腦真要長腦子了」。目前來源未提供完整摘要。 從 AI 情報角度來看,這類內容值得關注其背後的技術進展、產品落地、產業競爭與後續市場影響。

葡萄牙發佈首個歐洲葡語開源大語言模型 AMALIA
這篇消息聚焦「葡萄牙發佈首個歐洲葡語開源大語言模型 AMALIA」。原始導語提到:AMALIA 模型由來自葡萄牙多家學術機構的 60 餘位研究人員歷時 18 個月開發而成,目前提供具備多模態能力的 9B 版本,後續還將新增 22B 版本。 從 AI 情報角度來看,這類內容值得關注其背後的技術進展、產品落地、產業競爭與後續市場影響。
孫天祥入職百度出任基礎模型研發部負責人,並進入模型委員會
孫天祥加入百度任基礎模型研發部負責人,進入模型委員會。百度已將大模型研發拆分為基礎模型部與應用模型部,前者專註文心基礎模型攻堅。此舉強化組織與人才佈局,加速技術迭代。
國產大模型再迎“重磅炸彈”:Kimi K3 傳本月發佈,參數規模直指 2.5 萬億
月之暗面確認,其最新大模型 Kimi K3 將於本月發佈,參數規模高達 2.5 萬億,效能大幅超越 DeepSeek V4 Pro 的 1 萬億參數。這款國產大模型性能顯著提升,進一步加劇了 AI 領域的競爭。