WHOOP API
Retrieve and analyze fitness data from WHOOP wearables via the official REST API.
Usage Snippet
CODEBLOCK0
Prerequisites
- - Python 3.7+
- INLINECODE0 library: INLINECODE1
(or run
bash scripts/install.sh)
Quick Start
1. Register Application
- - Go to https://developer.whoop.com
- Create a new app and note your
client_id and INLINECODE4 - Set redirect URI (e.g.,
http://localhost:8080/callback)
2. Save Credentials
CODEBLOCK1
- - Open the authorization URL in browser
- User grants permissions → redirected with code
- Exchange code for tokens via INLINECODE6
4. Fetch Data
All scripts are run from the skill root directory:
CODEBLOCK2
Core Data Types
Recovery
- - Recovery Score (0-100): Readiness for strain
- HRV (RMSSD): Heart rate variability in milliseconds
- Resting Heart Rate: Morning baseline HR
- SPO2: Blood oxygen percentage
- Skin Temperature: Deviation from baseline in °C
Sleep
- - Performance %: How well you slept vs. your sleep need
- Duration: Total time in bed and per stage (REM, SWS, light, awake)
- Efficiency %: Time asleep / time in bed
- Consistency %: How consistent your sleep schedule is
- Respiratory Rate: Breaths per minute
- Sleep Needed/Debt: Baseline need and accumulated debt
Cycle (Daily Strain)
- - Strain Score: Cardiovascular load (0-21 scale)
- Kilojoules: Energy expenditure
- Average/Max Heart Rate: Daily HR metrics
Workout
- - Strain: Activity-specific strain score
- Sport: Activity type (running, cycling, etc.)
- Heart Rate Zones: Time spent in each of 6 zones
- Distance/Altitude: GPS metrics (if available)
API Endpoints
Base URL: INLINECODE7
See references/api-reference.md for full endpoint documentation with response schemas.
User Profile:
- -
GET /v1/user/profile/basic — Name, email - INLINECODE9 — Height, weight, max HR
Recovery:
- -
GET /v1/recovery — All recovery data (paginated) - INLINECODE11 — Recovery for specific cycle
Sleep:
- -
GET /v1/sleep — All sleep records (paginated) - INLINECODE13 — Specific sleep by ID
- INLINECODE14 — Sleep for specific cycle
Cycle:
- -
GET /v1/cycle — All physiological cycles (paginated) - INLINECODE16 — Specific cycle by ID
Workout:
- -
GET /v1/workout — All workouts (paginated) - INLINECODE18 — Specific workout by ID
All collection endpoints support start, end (ISO 8601), limit (max 25), and nextToken (pagination cursor).
Required OAuth Scopes
- -
read:profile — User name and email - INLINECODE24 — Height, weight, max HR
- INLINECODE25 — Recovery scores and HRV
- INLINECODE26 — Sleep metrics and stages
- INLINECODE27 — Daily strain data
- INLINECODE28 — Activity and workout data
Scripts
scripts/whoop_client.py
Core API client. Features:
- - OAuth token storage and auto-refresh
- Token expiry tracking (proactive refresh)
- Rate limit handling (429 with retry)
- Automatic pagination iterators (
iter_recovery, iter_sleep, iter_cycles, iter_workouts)
scripts/get_recovery.py
CODEBLOCK3
scripts/get_sleep.py
CODEBLOCK4
scripts/get_workouts.py
CODEBLOCK5
scripts/get_profile.py
CODEBLOCK6
scripts/install.sh
CODEBLOCK7
Troubleshooting
"ModuleNotFoundError: No module named 'requests'"
Install dependencies:
pip3 install requests or INLINECODE40
"Credentials not found at ~/.whoop/credentials.json"
Create the file with your OAuth client
id and clientsecret (see Quick Start step 2).
"Not authenticated"
Complete the OAuth authorization flow (see
references/oauth.md).
"401 Unauthorized" after token refresh fails
Your refresh token has expired. Re-authorize from the authorization URL.
"429 Too Many Requests"
Rate limit hit. The client automatically retries after the
Retry-After period.
Empty results
Check your date range — use
--days 7 or wider range. Ensure your OAuth scopes include the data type you're requesting.
References
技能名称: whoop
详细描述:
WHOOP API
通过官方REST API从WHOOP可穿戴设备检索和分析健身数据。
使用示例
bash
安装(如果使用Clawdhub)
clawdhub install whoop-tracker
从技能根目录运行:
python3 scripts/get_recovery.py --today
python3 scripts/get_sleep.py --last
python3 scripts/get_workouts.py --days 7
python3 scripts/get_profile.py
前提条件
- - Python 3.7+
- requests库:pip3 install requests
(或运行 bash scripts/install.sh)
快速开始
1. 注册应用
- - 访问 https://developer.whoop.com
- 创建新应用并记录您的 clientid 和 clientsecret
- 设置重定向URI(例如 http://localhost:8080/callback)
2. 保存凭证
bash
mkdir -p ~/.whoop
cat > ~/.whoop/credentials.json <
3. 授权(完整指南请参阅 references/oauth.md)
- - 在浏览器中打开授权URL
- 用户授予权限 → 通过代码重定向
- 通过 WhoopClient.authenticate(code, redirect_uri) 用代码交换令牌
4. 获取数据
所有脚本均从技能根目录运行:
bash
今日恢复
python3 scripts/get_recovery.py --today
昨晚睡眠
python3 scripts/get_sleep.py --last
近期锻炼
python3 scripts/get_workouts.py --days 7
用户资料
python3 scripts/get_profile.py
核心数据类型
恢复
- - 恢复评分(0-100):承受压力的准备程度
- 心率变异性(RMSSD):以毫秒为单位的心率变异性
- 静息心率:早晨基线心率
- 血氧饱和度:血氧百分比
- 皮肤温度:与基线的偏差(摄氏度)
睡眠
- - 表现百分比:实际睡眠质量与睡眠需求的对比
- 持续时间:总卧床时间及各阶段时长(快速眼动、深睡、浅睡、清醒)
- 效率百分比:睡眠时间/卧床时间
- 一致性百分比:睡眠时间表的规律程度
- 呼吸频率:每分钟呼吸次数
- 所需/睡眠负债:基线需求与累积负债
周期(每日压力)
- - 压力评分:心血管负荷(0-21分制)
- 千焦:能量消耗
- 平均/最大心率:每日心率指标
锻炼
- - 压力:特定活动的压力评分
- 运动类型:活动类型(跑步、骑行等)
- 心率区间:在6个区间中各花费的时间
- 距离/海拔:GPS指标(如有)
API端点
基础URL:https://api.prod.whoop.com
完整端点文档及响应模式请参阅 references/api-reference.md。
用户资料:
- - GET /v1/user/profile/basic — 姓名、邮箱
- GET /v1/user/body_measurement — 身高、体重、最大心率
恢复:
- - GET /v1/recovery — 所有恢复数据(分页)
- GET /v1/cycle/{cycleId}/recovery — 特定周期的恢复数据
睡眠:
- - GET /v1/sleep — 所有睡眠记录(分页)
- GET /v1/sleep/{sleepId} — 按ID查询特定睡眠
- GET /v1/cycle/{cycleId}/sleep — 特定周期的睡眠数据
周期:
- - GET /v1/cycle — 所有生理周期(分页)
- GET /v1/cycle/{cycleId} — 按ID查询特定周期
锻炼:
- - GET /v1/workout — 所有锻炼记录(分页)
- GET /v1/workout/{workoutId} — 按ID查询特定锻炼
所有集合端点均支持 start、end(ISO 8601格式)、limit(最大25)和 nextToken(分页游标)。
所需OAuth作用域
- - read:profile — 用户姓名和邮箱
- read:body_measurement — 身高、体重、最大心率
- read:recovery — 恢复评分和心率变异性
- read:sleep — 睡眠指标和阶段
- read:cycles — 每日压力数据
- read:workout — 活动和锻炼数据
脚本
scripts/whoop_client.py
核心API客户端。功能:
- - OAuth令牌存储和自动刷新
- 令牌过期跟踪(主动刷新)
- 速率限制处理(429状态码自动重试)
- 自动分页迭代器(iterrecovery、itersleep、itercycles、iterworkouts)
scripts/get_recovery.py
bash
python3 scripts/get_recovery.py --today # 今日恢复
python3 scripts/get_recovery.py --days 7 # 过去一周
python3 scripts/get_recovery.py --start 2026-01-20 # 从指定日期开始
python3 scripts/get_recovery.py --json # 原始JSON输出
scripts/get_sleep.py
bash
python3 scripts/get_sleep.py --last # 昨晚
python3 scripts/get_sleep.py --days 7 # 过去一周
python3 scripts/get_sleep.py --json # 原始JSON输出
scripts/get_workouts.py
bash
python3 scripts/get_workouts.py --days 7 # 过去一周
python3 scripts/get_workouts.py --sport running # 按运动类型筛选
python3 scripts/get_workouts.py --json # 原始JSON输出
scripts/get_profile.py
bash
python3 scripts/get_profile.py # 资料+身体测量数据
python3 scripts/get_profile.py --json # 原始JSON输出
scripts/install.sh
bash
bash scripts/install.sh # 安装pip依赖+设置指南
故障排除
ModuleNotFoundError: No module named requests
安装依赖:pip3 install requests 或 bash scripts/install.sh
Credentials not found at ~/.whoop/credentials.json
使用您的OAuth客户端ID和客户端密钥创建该文件(参见快速开始步骤2)。
Not authenticated
完成OAuth授权流程(参见 references/oauth.md)。
令牌刷新失败后出现401 Unauthorized
您的刷新令牌已过期。请从授权URL重新授权。
429 Too Many Requests
达到速率限制。客户端会在Retry-After周期后自动重试。
结果为空
检查您的日期范围——使用 --days 7 或更宽的范围。确保您的OAuth作用域包含您请求的数据类型。
参考资料