Garmin Connect Health Data Skill
Fetch comprehensive health & fitness data from Garmin Connect for your AI agent.
Data Coverage
| Category | Fields |
|---|
| Activity | Steps, distance, calories (active + BMR), floors, intensity minutes |
| Heart Rate |
Min/max/resting heart rate |
|
Sleep | Duration, score, deep/light/REM/awake breakdown, stress during sleep |
|
HRV | Last night avg, 5min peak, weekly avg, status (balanced/unbalanced), baseline |
|
Body Battery | Current level, daily min/max |
|
SpO2 | Average and minimum blood oxygen |
|
Respiration | Waking and sleep breathing rate |
|
Stress | Average/max, rest/low/medium/high duration breakdown |
|
Training Status | Overreaching/Highly Active/Productive/Maintaining/Recovery/Detraining + acute/chronic load ratio |
|
Training Readiness | Score (0-100) |
|
Fitness Metrics | VO2 Max, fitness age, endurance score, hill score |
|
Race Predictions | 5K/10K/Half/Marathon predicted times |
|
Weight/Body Comp | Weight (kg), body fat %, BMI (requires Garmin Index scale) |
|
Hydration | Intake (ml) vs goal |
|
Activities | Individual workouts with HR, duration, calories, elevation, training effect |
|
Weekly Summary | Total/avg steps for the week |
Setup
1. Install dependency
CODEBLOCK0
2. Set credentials (choose one method)
Option A -- Environment variables:
CODEBLOCK1
Option B -- CLI args:
CODEBLOCK2
Option C -- macOS Keychain:
CODEBLOCK3
Option D -- Credentials file:
CODEBLOCK4
3. Set region (China accounts only)
If your Garmin account was registered in China, add this to your shell profile (~/.zshrc / ~/.bashrc) once:
CODEBLOCK5
This tells the skill to use connect.garmin.com.cn instead of the global endpoint -- more reliable for mainland China IPs and prevents 429 rate-limit errors. Skip this step if you have a global Garmin account.
4. First run
First login may require MFA verification. You'll be prompted to enter a code sent to your email.
5. Use with OpenClaw
Ask your AI agent:
- - "Show my health data"
- "How did I sleep last night?"
- "What's my HRV?"
- "Am I overtraining?"
Usage
CODEBLOCK6
Data Storage
- -
~/.garmin_health/YYYY-MM-DD.json -- Daily snapshots - INLINECODE4 -- Most recent fetch
- INLINECODE5 -- OAuth token cache
Override with env vars:
- -
GARMIN_DATA_DIR -- Change data directory - INLINECODE7 -- Change token cache directory
- INLINECODE8 -- Use Garmin Connect CN endpoint (set once in shell profile)
Supported Languages
All labels and output in English. JSON field names are English by design.
Security & Privacy
- - Your credentials only -- this skill authenticates with Garmin Connect using your own account credentials. No credentials are shared with or stored by this skill.
- Local storage only -- all fetched health data is saved as JSON files on your own machine. No data is sent to any third party.
- Token caching -- after first login, an OAuth token is cached locally (
~/.garminconnect/). Subsequent runs reuse this token and do not re-send your password. - Recommended auth -- use macOS Keychain or environment variables rather than
--password CLI flag to avoid password exposure in shell history. - Official API only -- all requests go directly to
connect.garmin.com (or connect.garmin.com.cn for CN accounts). No proxies or intermediaries.
Requirements
- - Python 3.10+
- INLINECODE13 library
- A Garmin Connect account
- Device: Any Garmin watch/fitness tracker synced to Garmin Connect
Garmin Connect 健康数据技能
为您的AI智能体从Garmin Connect获取全面的健康与健身数据。
数据覆盖范围
| 类别 | 字段 |
|---|
| 活动 | 步数、距离、卡路里(活动消耗+基础代谢)、楼层数、高强度活动分钟数 |
| 心率 |
最低/最高/静息心率 |
|
睡眠 | 时长、评分、深睡/浅睡/快速眼动/清醒细分、睡眠期间压力 |
|
心率变异性 | 昨晚平均值、5分钟峰值、周平均值、状态(平衡/不平衡)、基线值 |
|
身体电量 | 当前水平、每日最低/最高值 |
|
血氧饱和度 | 平均血氧和最低血氧 |
|
呼吸 | 清醒和睡眠呼吸频率 |
|
压力 | 平均/最高压力、休息/低/中/高压力时长细分 |
|
训练状态 | 过度训练/高度活跃/高效/维持/恢复/停训 + 急性/慢性负荷比 |
|
训练准备度 | 评分(0-100) |
|
体能指标 | 最大摄氧量、体能年龄、耐力评分、爬坡评分 |
|
比赛预测 | 5公里/10公里/半程马拉松/全程马拉松预测时间 |
|
体重/身体成分 | 体重(公斤)、体脂率%、身体质量指数(需Garmin Index智能秤) |
|
水分摄入 | 摄入量(毫升)vs 目标量 |
|
活动记录 | 包含心率、时长、卡路里、海拔、训练效果的单次锻炼数据 |
|
周度总结 | 每周总步数/平均步数 |
设置步骤
1. 安装依赖
bash
pip install garminconnect
2. 设置凭据(选择一种方式)
选项A -- 环境变量:
bash
export GARMIN_EMAIL=you@example.com
export GARMIN_PASSWORD=yourpassword
选项B -- 命令行参数:
bash
python3 garmin_health.py --email you@example.com --password yourpassword
选项C -- macOS钥匙串:
bash
security add-generic-password -a you@example.com -s garmin_connect -w yourpassword
选项D -- 凭据文件:
bash
echo -e email=you@example.com\npassword=yourpassword > ~/.garmin_credentials
chmod 600 ~/.garmin_credentials
3. 设置区域(仅限中国账户)
如果您的Garmin账户在中国注册,请在您的shell配置文件(~/.zshrc / ~/.bashrc)中添加以下内容一次:
bash
export GARMINISCN=true
这将使技能使用connect.garmin.com.cn而非全球端点——对于中国大陆IP更可靠,并可防止429速率限制错误。如果您拥有全球Garmin账户,请跳过此步骤。
4. 首次运行
首次登录可能需要多因素认证验证。系统会提示您输入发送到邮箱的验证码。
5. 与OpenClaw配合使用
向您的AI智能体提问:
- - 显示我的健康数据
- 我昨晚睡得怎么样?
- 我的心率变异性是多少?
- 我是否训练过度?
使用方法
bash
获取今日数据(默认)
python3 garmin_health.py
获取特定日期数据
python3 garmin_health.py --date 2026-03-16
显示最新缓存数据
python3 garmin_health.py --show
使用Garmin Connect中国端点(中国账户/中国大陆IP)
python3 garmin_health.py --cn
使用凭据
python3 garmin_health.py --email you@example.com --password pass
数据存储
- - ~/.garminhealth/YYYY-MM-DD.json -- 每日快照
- ~/.garminhealth/latest.json -- 最近一次获取的数据
- ~/.garminconnect/ -- OAuth令牌缓存
通过环境变量覆盖:
- - GARMINDATADIR -- 更改数据目录
- GARMINTOKENSTORE -- 更改令牌缓存目录
- GARMINIS_CN=true -- 使用Garmin Connect中国端点(在shell配置文件中设置一次)
支持的语言
所有标签和输出均为英文。JSON字段名称设计为英文。
安全与隐私
- - 仅使用您的凭据 -- 此技能使用您自己的账户凭据向Garmin Connect进行身份验证。此技能不会共享或存储任何凭据。
- 仅本地存储 -- 所有获取的健康数据以JSON文件形式保存在您自己的机器上。不会向任何第三方发送数据。
- 令牌缓存 -- 首次登录后,OAuth令牌会缓存在本地(~/.garminconnect/)。后续运行会重复使用此令牌,不会重新发送您的密码。
- 推荐认证方式 -- 使用macOS钥匙串或环境变量,而非--password命令行标志,以避免密码在shell历史记录中暴露。
- 仅使用官方API -- 所有请求直接发送至connect.garmin.com(或中国账户的connect.garmin.com.cn)。不涉及任何代理或中间服务器。
系统要求
- - Python 3.10+
- garminconnect库
- Garmin Connect账户
- 设备:任何已同步至Garmin Connect的Garmin手表/健身追踪器