WHOOP Central
Access sleep, recovery, strain, and workout data from WHOOP via the v2 API.
Quick Commands
CODEBLOCK0
Data Available
| Metric | Data Points |
|---|
| Recovery | Score (0-100%), HRV, resting HR, SpO2, skin temp |
| Sleep |
Duration, stages (REM/deep/light), efficiency, performance |
|
Strain | Daily strain (0-21), calories, avg/max HR |
|
Workouts | Activity type, duration, strain, calories, HR |
Recovery Score Guide
- - 💚 67-100% Green - Ready to perform
- 💛 34-66% Yellow - Moderate readiness
- ❤️ 0-33% Red - Focus on recovery
Setup
0. Requirements
- - Node.js 18+ (this repo uses ESM)
- INLINECODE0 (only needed for the optional
auth.js flow when using https://localhost; Postman auth does not need it)
1. Create WHOOP Developer App
- 1. Go to https://developer.whoop.com/
- Sign in with your WHOOP account
- Create a new App
- Add these Redirect URIs (exact match; no extra trailing slashes):
- Postman browser callback (recommended auth path):
https://oauth.pstmn.io/v1/browser-callback
- Optional local callback (only used by
auth.js):
https://localhost:3000/callback
You can keep both registered at the same time.
- 5. Copy the Client ID and Client Secret
Team note: this skill does not ship any client credentials. Each user can create their own WHOOP app,
or (if you trust each other) a team can share one app's client_id/client_secret and let multiple WHOOP
accounts authorize it.
2. Save Credentials (recommended: interactive)
Run:
node src/setup.js
This writes
~/.clawdbot/whoop/credentials.json (and optionally
token.json if you paste tokens).
3. Authenticate (Recommended: Postman)
Postman is the most reliable bootstrap for many accounts because WHOOP may block browser-like traffic
to the OAuth endpoints (or behave differently depending on headers).
Postman checklist (don’t skip these):
- - WHOOP dashboard Redirect URIs include:
-
https://oauth.pstmn.io/v1/browser-callback
- - Postman OAuth settings:
- Scopes include
offline (or you won’t get a
refresh_token)
- Client Authentication is
Send client credentials in body (
client_secret_post)
1) In WHOOP dashboard, ensure you registered the Postman callback Redirect URI:
CODEBLOCK4
2) In Postman:
- - Create an Environment and set variables:
-
ClientId = your WHOOP client id
-
ClientSecret = your WHOOP client secret
- - Open the WHOOP API collection (or any request), then open the Authorization tab:
- Type: OAuth 2.0
- Add auth data to: Request Headers
- Grant Type: Authorization Code
- Callback URL: check
Authorize using browser
- Auth URL:
https://api.prod.whoop.com/oauth/oauth2/auth
- Access Token URL:
https://api.prod.whoop.com/oauth/oauth2/token
- Client ID:
{{ClientId}}
- Client Secret:
{{ClientSecret}}
- Scope (space-delimited): include
offline plus any read scopes you need, e.g.:
offline read:profile read:sleep read:recovery read:workout read:cycles read:body_measurement
- State: any 8+ chars (e.g.
loomingState)
- Client Authentication:
Send client credentials in body
3) Click "Get New Access Token", sign in to WHOOP, and click "Grant".
4) In Postman’s "Manage Access Tokens" modal:
- - Click "Use Token" (so requests work)
- IMPORTANT: copy and save both:
-
access_token
-
refresh_token
Postman often does not retain the refresh token for you later.
5) Save tokens to ~/.clawdbot/whoop/token.json:
- - Use
token.example.json as a template - Set:
-
obtained_at to current time in milliseconds
-
redirect_uri to:
CODEBLOCK8
6) Verify (and test refresh):
CODEBLOCK9
4. Optional: Authenticate via auth.js (may fail on some accounts)
If you prefer a fully local OAuth loop (and WHOOP allows it), you can use auth.js.
Pre-req: add this redirect URI in WHOOP dashboard:
CODEBLOCK10
Run:
CODEBLOCK11
If you need to do it from a phone/remote device:
CODEBLOCK12
Note: for localhost HTTPS, the script generates a self-signed cert and your browser will show a TLS warning.
You must proceed past the warning so the redirect can complete.
4. Verify It Works
CODEBLOCK13
Troubleshooting
Browser shows NotAuthorizedException before the login page
This is a WHOOP-side block on browser User-Agents hitting
api.prod.whoop.com OAuth endpoints.
- - Use the updated
node src/auth.js which bootstraps the login URL and sends your browser directly to id.whoop.com. - If you still see it, try
node src/auth.js --manual and open the printed URL.
"redirect_uri not whitelisted"
- 1. Go to https://developer.whoop.com/
- Edit your app
- Ensure this EXACT URI is in Redirect URIs:
https://oauth.pstmn.io/v1/browser-callback
If you're using
auth.js locally, also add:
https://localhost:3000/callback
- 4. Save and try again
Token Expired
Tokens auto-refresh on demand (no cron needed). If issues persist:
CODEBLOCK16
"Authorization was not valid"
This usually means your access token is stale/invalidated (common if you re-auth or refresh tokens elsewhere; WHOOP refresh tokens rotate).
- - Re-run
node src/auth.js, or - Copy the latest
access_token + refresh_token from Postman into ~/.clawdbot/whoop/token.json and update obtained_at.
Auth from Phone/Remote Device
Use manual mode:
node src/auth.js --manual
Open the URL on any device, authorize, then copy the code from the callback URL.
error=request_forbidden / "The request is not allowed"
This is WHOOP rejecting the authorization request after login/consent. Common causes:
- - Redirect URI policy (WHOOP docs only mention
https:// or whoop:// redirect URIs) - App/account restrictions (membership/approval/test-user restrictions)
- Scope restrictions (try requesting fewer scopes)
If you suspect redirect URI policy, use an HTTPS tunnel:
CODEBLOCK18
If you suspect scope restrictions, try a minimal scope set:
CODEBLOCK19
If your WHOOP Redirect URL is https://localhost:3000/callback
This changes how the local callback server must run: it must be HTTPS (not HTTP).
The script supports this. Run:
WHOOP_REDIRECT_URI=https://localhost:3000/callback node src/auth.js
It will generate a self-signed cert locally and your browser will likely show a warning for
https://localhost.
Proceed past the warning so the redirect can complete.
JSON Output (for tooling)
These commands support:
- -
--json (single JSON blob) - INLINECODE43 (one JSON object per line; useful for piping)
- INLINECODE44 (where supported)
- Time filters (where supported):
--days N, --since 7d / 12h, --start ISO, INLINECODE49
CODEBLOCK21
API Notes
- - Uses WHOOP Developer API v2
- OAuth 2.0 authentication with refresh tokens
- Scopes: offline, read:recovery, read:sleep, read:workout, read:cycles, read:profile
- Token auto-refreshes when expired
技能名称: whoop
详细描述:
WHOOP Central
通过v2 API访问WHOOP的睡眠、恢复、运动负荷和锻炼数据。
快速命令
bash
1) 一次性设置(写入 ~/.clawdbot/whoop/credentials.json)
node src/setup.js
2) 推荐:通过Postman获取令牌(参见认证部分),然后验证
node src/verify.js
node src/verify.js --refresh
快速概览(包含最近一次锻炼)
node src/today.js
每日摘要(所有指标)
node src/summary.js
单项指标
node src/recovery.js
node src/sleep.js
node src/strain.js
node src/workouts.js
批量导入到 ~/clawd/health/logs/whoop/*
node src/import-historical.js
可用数据
| 指标 | 数据点 |
|---|
| 恢复 | 评分(0-100%)、HRV、静息心率、血氧饱和度、皮肤温度 |
| 睡眠 |
时长、阶段(REM/深睡/浅睡)、效率、表现 |
|
运动负荷 | 每日负荷(0-21)、卡路里、平均/最大心率 |
|
锻炼 | 活动类型、时长、负荷、卡路里、心率 |
恢复评分指南
- - 💚 67-100% 绿色 - 已准备好表现
- 💛 34-66% 黄色 - 中等准备状态
- ❤️ 0-33% 红色 - 专注于恢复
设置
0. 前提条件
- - Node.js 18+(本仓库使用ESM)
- openssl(仅在通过https://localhost使用可选的auth.js流程时需要;Postman认证不需要)
1. 创建WHOOP开发者应用
- 1. 访问 https://developer.whoop.com/
- 使用您的WHOOP账户登录
- 创建一个新应用
- 添加以下重定向URI(精确匹配;末尾无多余斜杠):
- Postman浏览器回调(推荐认证路径):
https://oauth.pstmn.io/v1/browser-callback
- 可选本地回调(仅由auth.js使用):
https://localhost:3000/callback
您可以同时注册这两个URI。
- 5. 复制客户端ID和客户端密钥
团队说明:此技能不附带任何客户端凭据。每个用户可以创建自己的WHOOP应用,
或者(如果互相信任)一个团队可以共享一个应用的clientid/clientsecret,并让多个WHOOP
账户授权它。
2. 保存凭据(推荐:交互式)
运行:
bash
node src/setup.js
这将写入~/.clawdbot/whoop/credentials.json(如果粘贴令牌,还可选写入token.json)。
3. 认证(推荐:Postman)
对于多个账户,Postman是最可靠的引导方式,因为WHOOP可能会阻止类似浏览器的流量
访问OAuth端点(或根据标头表现出不同行为)。
Postman检查清单(不要跳过这些):
- https://oauth.pstmn.io/v1/browser-callback
- 范围包括offline(否则您将无法获得refresh_token)
- 客户端认证为
在请求体中发送客户端凭据(client
secretpost)
1) 在WHOOP仪表板中,确保您已注册Postman回调重定向URI:
text
https://oauth.pstmn.io/v1/browser-callback
2) 在Postman中:
- ClientId = 您的WHOOP客户端ID
- ClientSecret = 您的WHOOP客户端密钥
- - 打开WHOOP API集合(或任何请求),然后打开授权选项卡:
- 类型:OAuth 2.0
- 添加认证数据到:请求标头
- 授权类型:授权码
- 回调URL:勾选
使用浏览器授权
- 认证URL:
https://api.prod.whoop.com/oauth/oauth2/auth
- 访问令牌URL:
https://api.prod.whoop.com/oauth/oauth2/token
- 客户端ID:{{ClientId}}
- 客户端密钥:{{ClientSecret}}
- 范围(空格分隔):包括offline以及您需要的任何读取范围,例如:
offline read:profile read:sleep read:recovery read:workout read:cycles read:body_measurement
- 状态:任意8个以上字符(例如loomingState)
- 客户端认证:在请求体中发送客户端凭据
3) 点击获取新的访问令牌,登录WHOOP,然后点击授权。
4) 在Postman的管理访问令牌模态框中:
- - 点击使用令牌(以便请求正常工作)
- 重要:复制并保存以下两者:
- access_token
- refresh_token
Postman通常不会为您保留刷新令牌。
5) 将令牌保存到~/.clawdbot/whoop/token.json:
- - 使用token.example.json作为模板
- 设置:
- obtained_at 为当前时间的毫秒数
- redirect_uri 为:
https://oauth.pstmn.io/v1/browser-callback
6) 验证(并测试刷新):
bash
node src/verify.js
node src/verify.js --refresh
4. 可选:通过auth.js认证(在某些账户上可能失败)
如果您更喜欢完全本地的OAuth循环(且WHOOP允许),您可以使用auth.js。
前提条件:在WHOOP仪表板中添加此重定向URI:
text
https://localhost:3000/callback
运行:
bash
WHOOPREDIRECTURI=https://localhost:3000/callback node src/auth.js
如果需要从手机/远程设备执行:
bash
WHOOPREDIRECTURI=https://localhost:3000/callback node src/auth.js --manual
注意:对于本地主机HTTPS,脚本会生成自签名证书,您的浏览器将显示TLS警告。
您必须继续通过警告,以便重定向能够完成。
4. 验证是否正常工作
bash
node src/verify.js
node src/summary.js
故障排除
浏览器在登录页面之前显示NotAuthorizedException
这是WHOOP端对浏览器用户代理访问api.prod.whoop.com OAuth端点的阻止。
- - 使用更新的node src/auth.js,它会引导登录URL并将您的浏览器直接发送到id.whoop.com。
- 如果仍然看到此错误,请尝试node src/auth.js --manual并打开打印的URL。
redirect_uri not whitelisted(重定向URI未列入白名单)
- 1. 访问 https://developer.whoop.com/
- 编辑您的应用
- 确保此精确URI在重定向URI中:
https://oauth.pstmn.io/v1/browser-callback
如果您在本地使用auth.js,也请添加:
https://localhost:3000/callback
- 4. 保存并重试
令牌过期
令牌按需自动刷新(无需cron)。如果问题持续存在:
bash
rm ~/.clawdbot/whoop/token.json
node src/auth.js
Authorization was not valid(授权无效)
这通常意味着您的访问令牌已过期/失效(如果您在其他地方重新认证或刷新令牌,这很常见;WHOOP刷新令牌会轮换)。
- - 重新运行node src/auth.js,或
- 将最新的accesstoken + refreshtoken从Postman复制到~/.clawdbot/whoop/token.json并更新obtained_at。
从手机/远程设备认证
使用手动模式:
bash
node src/auth.js --manual
在任何设备上打开URL,授权,然后从回调URL复制代码。
error=request_forbidden / The request is not allowed(请求不允许)
这是WHOOP在登录/同意后拒绝授权请求。常见原因:
- - 重定向URI策略(WHOOP文档只提到https://或whoop://重定向URI)
- 应用/账户限制(会员/审批/测试用户限制)
- 范围限制(尝试请求更少的范围)
如果您怀疑是重定向URI策略,请使用HTTPS隧道:
bash
1) 获取一个转发到localhost:3000的公共HTTPS URL(示例)
ngrok http 3000
#