介绍
# Hevy CLI
用于 Hevy 健身追踪 API 的命令行界面。查询训练、计划、动作并跟踪进度。
## 安装设置
需要 Hevy Pro 订阅才能访问 API。
1. 从 https://hevy.com/settings?developer 获取 API 密钥 2. 设置环境变量:`export HEVY_API_KEY="your-key"`
## 命令
### 状态
```bash # Check configuration and connection hevy status ```
### 训练
```bash # List recent workouts (default 5) hevy workouts hevy workouts --limit 10
# Fetch all workouts hevy workouts --all
# Show detailed workout hevy workout <workout-id>
# JSON output hevy workouts --json hevy workout <id> --json
# Show weights in kg (default is lbs) hevy workouts --kg ```
### 计划
```bash # List all routines hevy routines
# Show detailed routine hevy routine <routine-id>
# JSON output hevy routines --json ```
### 动作
```bash # List all exercise templates hevy exercises
# Search by name hevy exercises --search "bench press"
# Filter by muscle group hevy exercises --muscle chest
# Show only custom exercises hevy exercises --custom
# JSON output hevy exercises --json ```
### 动作历史
```bash # Show history for specific exercise hevy history <exercise-template-id> hevy history <exercise-template-id> --limit 50
# JSON output hevy history <exercise-template-id> --json ```
### 创建计划
```bash # Create routine from JSON (stdin) echo '{"routine": {...}}' | hevy create-routine
# Create routine from file hevy create-routine --file routine.json
# Create a routine folder hevy create-folder "Push Pull Legs"
# Update existing routine echo '{"routine": {...}}' | hevy update-routine <routine-id>
# Create custom exercise (checks for duplicates first!) hevy create-exercise --title "My Exercise" --muscle chest --type weight_reps
# Force create even if duplicate exists 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": [ { "exercise_template_id": "79D0BB3A", "notes": "Focus on form", "rest_seconds": 90, "sets": [ { "type": "warmup", "weight_kg": 20, "reps": 15 }, { "type": "normal", "weight_kg": 60, "reps": 8 } ] } ] } } ```
### 其他
```bash # Total workout count hevy count
# List routine folders hevy folders ```
## 使用示例
**用户问“我在健身房做了什么?”** ```bash hevy workouts ```
**用户问“给我看看我上一次胸部训练”** ```bash hevy workouts --limit 10 # Find relevant workout ID hevy workout <id> # Get details ```
**用户问“我卧推进展如何?”** ```bash hevy exercises --search "bench press" # Get exercise template ID hevy history <exercise-id> # View progression ```
**用户问“我有哪些计划?”** ```bash hevy routines hevy routine <id> # For details ```
**用户问“查找腿部动作”** ```bash hevy exercises --muscle quadriceps hevy exercises --muscle hamstrings hevy exercises --muscle glutes ```
**用户问“创建一个推日计划”** ```bash # 1. Find exercise IDs hevy exercises --search "bench press" hevy exercises --search "shoulder press" # 2. Create routine JSON with those IDs and pipe to create-routine ```
## 注意事项
- **重复预防:** `create-exercise` 在创建前会检查是否存在同名动作。使用 `--force` 覆盖(不推荐)。 - **API 限制:** Hevy API 不支持删除或编辑动作模板——仅支持创建。请在应用中手动删除动作。 - **API 速率限制:** 获取所有数据(--all 标志)时请注意限制 - **重量单位:** 默认为磅,使用 --kg 切换为千克 - **分页:** 大多数命令会自动分页,但使用 limit 标志有助于减少 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/exercise_templates` - 列出动作 - `GET /v1/exercise_templates/{id}` - 获取单个动作 - `GET /v1/exercise_history/{id}` - 动作历史 - `GET /v1/routine_folders` - 列出文件夹
### 写操作(支持但请谨慎使用) - `POST /v1/workouts` - 创建训练 - `PUT /v1/workouts/{id}` - 更新训练 - `POST /v1/routines` - 创建计划 - `PUT /v1/routines/{id}` - 更新计划 - `POST /v1/exercise_templates` - 创建自定义动作 - `POST /v1/routine_folders` - 创建文件夹
该 CLI 主要专注于读操作。写操作可通过 API 客户端用于程序化调用。