当前位置: 首页 > Skill >

Google Health

Google Health

Google Health

从任意代理读取您的 Google 健康数据,列出每种 Google 健康数据类型(心率、静息心率、睡眠、步数、距离、体重等)的数据点。

1.0.8 2026.11.20 955
获取Skill文件查看使用说明
作 者:江安 许可证: 更新时间:2026.11.20
本文目录展开

Google Health — read-only data extractor

Read your Google Health data from any agent. This is a generic, read-only client for the Google Health v4 API: it authenticates, pulls data points for any data type, and prints JSON. It does no filtering, merging, or interpretation — you get the data and parse whatever you care about. Single static binary — no Python or other runtime.

⚠️ Read-only. It requests only read-only Google Health scopes and never writes your health data.

🔒 Privacy — sensitive health data leaves on stdout. Every data list, rollup daily, sessions, and api get prints your personal health information (heart rate, sleep, weight, exercise, blood oxygen, profile, …) to stdout as JSON. In an agent or pipeline, stdout may be logged, summarized, persisted, or transmitted to other tools, model providers, or third parties. Treat this output as sensitive PII: only run it in contexts you trust to handle health data, and do not persist or forward it unless you intend to. The tool never sends your data anywhere itself (it only talks to Google's API over HTTPS) — what happens to stdout is the caller's responsibility. Every data-emitting command also prints a one-line privacy notice to stderr at run time as an execution-time reminder (it stays on stderr, never on the JSON stdout).

🧭 Data minimization & consent. Request only the data types and the narrowest time window you actually need (--days/--date/--from/--to, not --all); prefer the typed data/rollup/sessions commands over api get; and don't persist or forward the output beyond the task at hand. Run this only against an account whose owner has knowingly consented to having their health data read by this agent — the one-time auth login is the owner consenting to read-only access for the tool, not consent for a downstream agent to collect, retain, or transmit that data more broadly.

🩺 doctor prints local environment metadata. The doctor JSON includes your token-cache and config file paths, the configured account (user), and the API base URL — local filesystem layout and account identifiers rather than health data, but still local environment metadata that an agent or pipeline may log, forward, or persist. It exists to diagnose your own setup; treat its output like any other local path/account detail and don't paste it into untrusted contexts.

Setup (one time)

Unlike a simple email/password tool, Google Health uses OAuth, so first-time setup needs a human in a browser once. After that it runs headless (the token auto-refreshes).

  1. Install the binary:
    # A) Download a release for your OS/arch and put it on PATH:
    #    https://github.com/stozo04/google-health-cli/releases
    # B) Or with Go (1.25+):
    go install github.com/stozo04/google-health-cli/cmd/google-health-cli@latest
    
  2. Create a Google Cloud OAuth client (Desktop app, read-only Health scopes, ~10 min, no fees). Full walkthrough: the repo's OAUTH_SETUP.md.
  3. Provide the client via GOOGLE_HEALTH_CLIENT_ID / GOOGLE_HEALTH_CLIENT_SECRET (or a config.json with those keys in the working directory).
  4. Authorize once (opens a browser, asks a human to consent to read-only access):
    google-health-cli auth login
    google-health-cli doctor        # expect "tokenValid": true
    
    The token is cached 0600 and auto-refreshed; every later run is headless.

Credentials

Variable Required Notes
GOOGLE_HEALTH_CLIENT_ID ✓ OAuth client ID (Desktop app)
GOOGLE_HEALTH_CLIENT_SECRET ✓ OAuth client secret
GOOGLE_HEALTH_CONFIG — Path to a config.json holding the above instead
GOOGLE_HEALTH_TOKEN_CACHE — Override the cached-token path
GOOGLE_HEALTH_BASE_URL — Override the API base URL

config.json (gitignored) is an alternative to the env vars:

{
  "client_id": "PASTE_CLIENT_ID",
  "client_secret": "PASTE_CLIENT_SECRET"
}

🔑 Protect your credentials. The OAuth client_id/client_secret and the cached token are sensitive secrets stored on disk in plaintext (config.json / token.json, written 0600). They're gitignored — keep it that way: never commit them, copy them into a shared folder, back them up to an untrusted location, or paste them into logs or chat. Rotate the OAuth client (and run auth logout) if one may have leaked.

Commands

Discover the data types

google-health-cli types list                 # all types ( * = supports list )
google-health-cli types describe heart-rate   # one type's record shape, scope, time field

Read data points (the core)

google-health-cli data list heart-rate --days 1        # last 1 day
google-health-cli data list sleep --days 14             # last 14 days
google-health-cli data list daily-resting-heart-rate --days 30
google-health-cli data list steps --date 2026-06-16     # one civil day
google-health-cli data list weight --from 2026-01-01T00:00:00Z --to 2026-07-01T00:00:00Z
google-health-cli data list distance --all              # everything, no time filter

stdout is always a JSON array of the raw data points (verbatim from the API); a one-line count goes to stderr. Window flags (precedence: --all > --from/--to > --date/--days): --date today|yesterday|YYYY-MM-DD, --days N (default 7), --from/--to (RFC3339, together), --all (no filter).

Example (data list daily-resting-heart-rate):

[
  {
    "dataSource": { "platform": "FITBIT", "device": { "displayName": "Google Pixel Watch 4 (45mm)" } },
    "dailyRestingHeartRate": { "date": { "year": 2026, "month": 6, "day": 17 }, "beatsPerMinute": "78" }
  }
]

A few types are roll-up/reconcile-only and can't be listed (types list marks listable ones with *); read those with rollup daily <type> instead (below). One type — daily-heart-rate-zones — supports neither list nor rollup daily; it is reachable only via the api get escape hatch.

Daily roll-ups (server-side totals)

google-health-cli rollup daily steps --days 7           # one reconciled total per civil day
google-health-cli rollup daily active-minutes --days 7   # a roll-up-only type (no `data list`)

rollup daily <type> returns the API's daily roll-up rows — one value per civil (local) calendar day — instead of the raw per-minute/per-sample points data list returns. It's the cheap way to get daily totals (e.g. a steps total per day rather than a per-minute dump) and the only way to read the roll-up-only types that have no list op (active-minutes, total-calories, floors, calories-in-heart-rate-zone, time-in-heart-rate-zone). stdout is a JSON array of the raw roll-up rows; an N <type> daily rollup(s) count goes to stderr. Each value is reconciled across data sources (and excludes off-wrist intervals), so it is not a naive sum of data list points. Window flags mirror data list minus --all (the range is required).

[
  {
    "civilStartTime": { "date": { "year": 2026, "month": 6, "day": 16 }, "time": {} },
    "civilEndTime":   { "date": { "year": 2026, "month": 6, "day": 17 }, "time": {} },
    "steps": { "countSum": "8000" }
  }
]

Parsed exercise sessions (convenience)

google-health-cli sessions --days 14 --json    # flattened exercise rows
google-health-cli sessions --raw               # raw exercise data points
[
  { "date": "2026-06-16", "exercise_type": "ELLIPTICAL", "duration_min": 35,
    "avg_hr": 130, "calories": 236, "platform": "FITBIT" }
]

sessions returns all exercise types (no filtering); the caller keeps what it wants.

Raw read-only API access

google-health-cli api get /v4/users/me/profile     # GET any read-only v4 path
google-health-cli api get /v4/users/me/settings

⚠️ Sensitive endpoints — broader than the typed metrics. api get can read any read-only v4 path, including users/me/profile and users/me/settings — account, identity, and settings data that the typed commands don't surface. Its responses are personal data printed to stdout, so the same Privacy caution above applies, and the broad reach makes over-collection easy. It stays GET-only (no path can write or delete) and is constrained to the read-only v4 surface (/v4/...): a non-v4/ path, an absolute URL, or a .. traversal — literal or percent-encoded (%2e%2e, ..%2f) — is rejected (exit 64) before any request is made. Still, prefer the typed data/rollup/sessions commands and reach for api get only when you need an endpoint they don't model.

Full command reference

Command What it does --json
auth login | logout | status OAuth login (one-time browser), token mgmt status
doctor Config + token validity; reports configFound/clientIdLoaded and exits non-zero (78) when no config / no client_id is found, else 2 if not authed always
types list | describe <type> Inspect the data-type catalog (no network) ✓
data list <type> List data points for a type (always JSON) n/a (always)
rollup daily <type> Server-side daily totals, reconciled per civil day n/a (always)
sessions [--days N] [--raw] Parsed exercise sessions (convenience) ✓
api get <path> Raw read-only GET of any v4 path n/a
config show | path Inspect resolved config (client_secret masked) show
version Build metadata (also --version) ✓
completion <shell> Shell completion (bash/zsh/fish/powershell) —

Conventions

  • stdout is parseable; human hints, counts, and logs go to stderr, never interleaved.
  • Exit codes: 0 success, 2 auth/API failure (incl. doctor when unauthenticated), 64 usage error (incl. an expired token with no OAuth client credentials to refresh it), 78 config error. An expired token plus an undiscoverable/credential-less config fails fast with an actionable message — not the cryptic oauth2 "Could not determine client ID" error.
  • Read-only: six read-only googlehealth.*.readonly scopes; no write operations exist.
  • Secrets: config.json and the token cache are gitignored — never commit them.
  • Time-filter formats are handled for you per data type (civil wall-clock, RFC3339 instant, or date-only); a --date/--days window always covers your local calendar days. If a type rejects server-side filtering, re-run with --all.

See the repo's AGENTS.md for the exact --json shapes and exit-code contract.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,035
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,019
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,014
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,014
Skill 文件
  • SKILL.md
    • Google Health — read-only data extractor
    • Setup (one time)
    • Credentials
    • Commands
      • Discover the data types
      • Read data points (the core)
      • Daily roll-ups (server-side totals)
      • Parsed exercise sessions (convenience)
      • Raw read-only API access
    • Full command reference
    • Conventions
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期