Hevy CLI
CLI for the Hevy workout tracking API. Query workouts, routines, exercises, and track progress.
Setup
Requires Hevy Pro subscription for API access.
- 1. Get API key from https://hevy.com/settings?developer
- Set environment variable: INLINECODE0
Commands
Status
CODEBLOCK0
Workouts
CODEBLOCK1
Routines
CODEBLOCK2
Exercises
CODEBLOCK3
Exercise History
CODEBLOCK4
Creating Routines
CODEBLOCK5
⚠️ Duplicate Prevention: create-exercise checks if an exercise with the same name already exists and will error if found. Use --force to create anyway (not recommended).
Routine JSON format:
CODEBLOCK6
Other
CODEBLOCK7
Usage Examples
User asks "What did I do at the gym?"
CODEBLOCK8
User asks "Show me my last chest workout"
CODEBLOCK9
User asks "How am I progressing on bench press?"
CODEBLOCK10
User asks "What routines do I have?"
CODEBLOCK11
User asks "Find leg exercises"
CODEBLOCK12
User asks "Create a push day routine"
CODEBLOCK13
Notes
- - Duplicate Prevention:
create-exercise checks for existing exercises with the same name before creating. Use --force to override (not recommended). - API Limitations: Hevy API does NOT support deleting or editing exercise templates - only creating. Delete exercises manually in the app.
- API Rate Limits: Be mindful when fetching all data (--all flag)
- Weights: Defaults to lbs, use --kg for kilograms
- Pagination: Most commands auto-paginate, but limit flags help reduce API calls
- IDs: Workout/routine/exercise IDs are UUIDs, shown in detailed views
API Reference
Full API docs: https://api.hevyapp.com/docs/
Available Endpoints
- -
GET /v1/workouts - List workouts (paginated) - INLINECODE6 - Get single workout
- INLINECODE7 - Total workout count
- INLINECODE8 - List routines
- INLINECODE9 - Get single routine
- INLINECODE10 - List exercises
- INLINECODE11 - Get single exercise
- INLINECODE12 - Exercise history
- INLINECODE13 - List folders
Write Operations (supported but use carefully)
- -
POST /v1/workouts - Create workout - INLINECODE15 - Update workout
- INLINECODE16 - Create routine
- INLINECODE17 - Update routine
- INLINECODE18 - Create custom exercise
- INLINECODE19 - Create folder
The CLI focuses on read operations. Write operations are available via the API client for programmatic use.
Hevy CLI
Hevy 锻炼追踪 API 的命令行工具。可查询锻炼记录、训练计划、动作库并追踪进度。
环境配置
使用 API 需要 Hevy Pro 订阅。
- 1. 从 https://hevy.com/settings?developer 获取 API 密钥
- 设置环境变量:export HEVYAPIKEY=your-key
命令
状态
bash
检查配置和连接
hevy status
锻炼记录
bash
列出最近的锻炼记录(默认5条)
hevy workouts
hevy workouts --limit 10
获取所有锻炼记录
hevy workouts --all
显示详细锻炼记录
hevy workout
JSON 输出
hevy workouts --json
hevy workout --json
以公斤显示重量(默认为磅)
hevy workouts --kg
训练计划
bash
列出所有训练计划
hevy routines
显示详细训练计划
hevy routine
JSON 输出
hevy routines --json
动作库
bash
列出所有动作模板
hevy exercises
按名称搜索
hevy exercises --search bench press
按肌肉群筛选
hevy exercises --muscle chest
仅显示自定义动作
hevy exercises --custom
JSON 输出
hevy exercises --json
动作历史
bash
显示特定动作的历史记录
hevy history
hevy history --limit 50
JSON 输出
hevy history --json
创建训练计划
bash
从 JSON 创建训练计划(标准输入)
echo {routine: {...}} | hevy create-routine
从文件创建训练计划
hevy create-routine --file routine.json
创建训练计划文件夹
hevy create-folder Push Pull Legs
更新现有训练计划
echo {routine: {...}} | hevy update-routine
创建自定义动作(会先检查重复项!)
hevy create-exercise --title My Exercise --muscle chest --type weight_reps
即使存在重复也强制创建
hevy create-exercise --title My Exercise --muscle chest --force
⚠️ 重复预防: create-exercise 会检查是否存在同名动作,如果找到则会报错。使用 --force 可强制创建(不推荐)。
训练计划 JSON 格式:
json
{
routine: {
title: Push Day 💪,
folder_id: null,
notes: Chest, shoulders, triceps,
exercises: [
{
exercisetemplateid: 79D0BB3A,
notes: Focus on form,
rest_seconds: 90,
sets: [
{ type: warmup, weight_kg: 20, reps: 15 },
{ type: normal, weight_kg: 60, reps: 8 }
]
}
]
}
}
其他
bash
总锻炼次数
hevy count
列出训练计划文件夹
hevy folders
使用示例
用户询问我在健身房做了什么?
bash
hevy workouts
用户询问显示我上次的胸部训练
bash
hevy workouts --limit 10 # 查找相关锻炼 ID
hevy workout # 获取详细信息
用户询问我在卧推上的进步如何?
bash
hevy exercises --search bench press # 获取动作模板 ID
hevy history # 查看进展
用户询问我有哪些训练计划?
bash
hevy routines
hevy routine # 查看详情
用户询问查找腿部动作
bash
hevy exercises --muscle quadriceps
hevy exercises --muscle hamstrings
hevy exercises --muscle glutes
用户询问创建一个推日训练计划
bash
1. 查找动作 ID
hevy exercises --search bench press
hevy exercises --search shoulder press
2. 使用这些 ID 创建训练计划 JSON 并通过管道传给 create-routine
注意事项
- - 重复预防: create-exercise 在创建前会检查是否存在同名动作。使用 --force 可覆盖(不推荐)。
- API 限制: Hevy API 不支持删除或编辑动作模板——仅支持创建。请在应用中手动删除动作。
- API 速率限制: 获取所有数据时请注意(--all 标志)
- 重量单位: 默认为磅,使用 --kg 切换为公斤
- 分页: 大多数命令会自动分页,但限制标志有助于减少 API 调用
- ID: 锻炼/训练计划/动作 ID 为 UUID,在详细视图中显示
API 参考
完整 API 文档:https://api.hevyapp.com/docs/
可用端点
- - GET /v1/workouts - 列出锻炼记录(分页)
- GET /v1/workouts/{id} - 获取单个锻炼记录
- GET /v1/workouts/count - 总锻炼次数
- GET /v1/routines - 列出训练计划
- GET /v1/routines/{id} - 获取单个训练计划
- GET /v1/exercisetemplates - 列出动作
- GET /v1/exercisetemplates/{id} - 获取单个动作
- GET /v1/exercisehistory/{id} - 动作历史记录
- GET /v1/routinefolders - 列出文件夹
写入操作(支持但请谨慎使用)
- - POST /v1/workouts - 创建锻炼记录
- PUT /v1/workouts/{id} - 更新锻炼记录
- POST /v1/routines - 创建训练计划
- PUT /v1/routines/{id} - 更新训练计划
- POST /v1/exercisetemplates - 创建自定义动作
- POST /v1/routinefolders - 创建文件夹
CLI 主要专注于读取操作。写入操作可通过 API 客户端进行编程使用。