Intervals.icu API Skill
Comprehensive guide for interacting with the intervals.icu API to manage athlete training data, activities, workouts, and calendar events.
Authentication
API Key Method
Get your Athlete ID and API Key from intervals.icu settings page.
CODEBLOCK0
Bearer Token Method (OAuth)
CODEBLOCK1
Base URL: INLINECODE0
Date Format: ISO-8601 (e.g., 2024-01-15 or 2024-01-15T10:30:00)
Core Concepts
Athlete ID
Your unique identifier in Intervals.icu. Used in all API endpoints as {id} path parameter.
Activities vs Events
- - Activities: Completed workouts with actual data (GPS, power, HR). Retrieved from INLINECODE4
- Events: Planned workouts on your calendar. Retrieved from INLINECODE5
Data Fields
Activities and events can return different fields. Use the fields query parameter to include/exclude specific data points for more efficient queries.
Getting Activities (Completed Workouts)
List Activities for Date Range
Retrieve all activities between two dates, sorted newest to oldest.
CODEBLOCK2
Combine Activities with External Data
Use fields parameter to combine activity data with contextual information:
CODEBLOCK3
Get Single Activity with Full Details
CODEBLOCK4
Export Activity Streams (CSV or JSON)
CODEBLOCK5
Calendar & Planned Workouts
List Calendar Events (Planned Workouts)
Retrieve planned workouts, notes, and training targets from your calendar.
CODEBLOCK6
Get Single Event Details
CODEBLOCK7
Download Planned Workout File
Export planned workouts in various formats for your training device.
CODEBLOCK8
Creating & Writing Data
Create Manual Activity
Add a manually-logged activity to your training history.
CODEBLOCK9
Create Multiple Activities (Bulk)
CODEBLOCK10
Create Planned Workout (Event on Calendar)
Add a scheduled workout to your calendar for future training.
CODEBLOCK11
Create Multiple Events (Bulk)
CODEBLOCK12
Create Training Target (Goal for Date)
Set a specific training target for a date.
CODEBLOCK13
Updating Data
Update Activity
Modify an existing completed activity.
CODEBLOCK14
Update Planned Workout (Event)
Modify a scheduled event on your calendar.
CODEBLOCK15
Update Multiple Events (Date Range)
CODEBLOCK16
Wellness & Recovery Data
Get Wellness Records
Track sleep, fatigue, resting HR, and other wellness metrics.
CODEBLOCK17
Update Wellness Record
Log wellness data for a specific date.
CODEBLOCK18
Bulk Update Wellness Records
CODEBLOCK19
Sport Settings & Zones
Get Sport Settings
Retrieve power zones, HR zones, and FTP settings for a sport.
CODEBLOCK20
Update Sport Settings
Modify power zones, FTP, or HR zones.
CODEBLOCK21
Common Use Cases
Workflow: Sync Training Data with External System
CODEBLOCK22
Workflow: Create Weekly Training Plan
CODEBLOCK23
Workflow: Analyze Week Data
CODEBLOCK24
Important Notes
Rate Limiting
Be respectful with API calls. Don't hammer the API with rapid successive requests.
Field Selection
Use the fields parameter to request only the data you need. This improves performance and reduces payload size.
Date Formats
Always use ISO-8601 format: YYYY-MM-DD or INLINECODE10
Upsert Parameter
When creating events, use upsertOnUid=true to update existing events with matching UIDs instead of creating duplicates.
External IDs
Use external_id when syncing data from other systems to avoid duplicates on re-sync.
Forum Discussion
For more detailed API information, see: API Access Forum Post
Response Status Codes
- - 200: Success
- 201: Created successfully (activities, events)
- 400: Bad request (invalid parameters)
- 401: Unauthorized (invalid API key or token)
- 404: Not found (invalid IDs)
- 429: Rate limited (too many requests)
- 500: Server error
Check response headers for error details and rate limit information.
Intervals.icu API 技能
与 intervals.icu API 交互以管理运动员训练数据、活动、训练和日历事件的综合指南。
身份验证
API 密钥方法
从 intervals.icu 设置页面 获取您的运动员 ID 和 API 密钥。
bash
使用 API 密钥标头
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID
Bearer 令牌方法 (OAuth)
bash
使用 Bearer 令牌
curl -H Authorization: Bearer YOUR
ACCESSTOKEN \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID
基础 URL: https://intervals.icu/api/v1
日期格式: ISO-8601 (例如 2024-01-15 或 2024-01-15T10:30:00)
核心概念
运动员 ID
您在 Intervals.icu 中的唯一标识符。在所有 API 端点中用作 {id} 路径参数。
活动与事件
- - 活动: 已完成训练,包含实际数据(GPS、功率、心率)。通过 /athlete/{id}/activities 获取
- 事件: 日历上的计划训练。通过 /athlete/{id}/events 获取
数据字段
活动和事件可返回不同字段。使用 fields 查询参数包含/排除特定数据点,以实现更高效的查询。
获取活动(已完成训练)
按日期范围列出活动
检索两个日期之间的所有活动,按从新到旧排序。
bash
基本活动列表
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&newest=2024-01-31
带限制
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&limit=10
仅特定字段(更高效)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&fields=id,name,start
datelocal,type,distance,moving
time,icutraining_load
针对特定活动类型(骑行、跑步、游泳等)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&newest=2024-01-31 | jq .[] | select(.type == Ride)
结合活动与外部数据
使用 fields 参数将活动数据与上下文信息结合:
bash
功率、心率和负荷数据
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&fields=name,icu
weightedavg
watts,averageheartrate,icu
trainingload,icu
atl,icuctl
包含疲劳和体能指标
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&fields=id,name,type,icu
trainingload,icu
atl,icuctl,perceived_exertion
结合功率区间和区间时间
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&fields=id,name,distance,moving
time,icuzone
times,icuweighted
avgwatts
心率区间 + 强度数据
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/activities?oldest=2024-01-01&fields=id,name,type,average
heartrate,maxheartrate,icu
hrzone_times,trimp
获取单个活动完整详情
bash
按 ID 获取活动及所有数据
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/activity/ACTIVITY_ID
获取活动及分段
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/activity/ACTIVITY_ID?intervals=true
导出活动数据流(CSV 或 JSON)
bash
以 JSON 格式获取活动数据流
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/activity/ACTIVITY_ID/streams.json
以 CSV 格式获取活动数据流(包含时间、功率、心率、踏频等)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/activity/ACTIVITY_ID/streams.csv \
--output activity_streams.csv
获取特定数据流类型
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/activity/ACTIVITY
ID/streams.json?types=watts,heartrate,cadence
日历与计划训练
列出日历事件(计划训练)
从日历中检索计划训练、备注和训练目标。
bash
获取日期范围内的所有事件
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events?oldest=2024-02-01&newest=2024-02-29
获取特定字段
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events?oldest=2024-02-01&newest=2024-02-29&fields=id,name,category,start
datelocal,description
按类别筛选(WORKOUT、NOTE、TARGET、FITNESS_DAYS 等)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events?oldest=2024-02-01&category=WORKOUT
获取日期范围内的训练目标
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events?oldest=2024-02-01&category=TARGET
获取单个事件详情
bash
获取特定计划训练
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events/EVENT_ID
下载计划训练文件
以多种格式导出计划训练,用于您的训练设备。
bash
下载为 .zwo 格式(Zwift 格式)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events/EVENT_ID/download.zwo \
--output workout.zwo
下载为 .mrc 格式(TrainerRoad 格式)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events/EVENT_ID/download.mrc \
--output workout.mrc
下载为 .erg 格式(Wahoo 格式)
curl -H Authorization: ApiKey API
KEY:YOURAPI_KEY \
https://intervals.icu/api/v1/athlete/YOUR
ATHLETEID/events/EVENT_ID/download.erg \
--output workout.erg
下载为 .fit 格式(Garmin