I have added REST JSON endpoints for calendar access. If you have a clever way of generating training plans you can now get those into Intervals.icu easily.
GET /api/v1/athlete/{id}/calendars
List all calendars
GET /api/v1/athlete/{id}/events
List all calendar events. Requires parameters oldest
and newest
in yyyy-MM-dd format (local dates i.e. no timezone). The range may be expanded if oldest and/or newest fall inside a multiday event to include the whole event. Only events from enabled calendars are returned. Supports optional calendar_id parameter to filter for events for a particular calendar.
GET /api/v1/athlete/{id}/events/{eventId}
Fetch an event by id.
GET /api/v1/athlete/{id}/events/{eventId}/download{ext}
Download a planned workout in .zwo, .mrc or .erg format.
POST /api/v1/athlete/{id}/events
Create event and return it.
PUT /api/v1/athlete/{id}/events/{eventId}
Update event and return it.
DELETE /api/v1/athlete/{id}/events/{eventId}
Delete the event.
Example POST payload to create a workout (note that the dates cannot have time i.e. must end with T00:00:00
and the athlete needs to be yourself or someone you are coaching):
{
"start_date_local": "2020-05-01T00:00:00",
"icu_training_load": 120,
"category": "WORKOUT",
"name": "Outdoor ride at last!",
"description": "Lockdown finally over, just go ride around all over the place!",
"type": "Ride",
"moving_time": 7200
}
Response:
{
"id": 127,
"start_date_local": "2020-05-01T00:00:00",
"icu_training_load": 120,
"icu_atl": 18.852789,
"icu_ctl": 39.18664,
"calendar_id": 1,
"uid": "fcb69e1a-934e-47ac-a5f1-a207830466f2",
"category": "WORKOUT",
"end_date_local": "2020-05-02T00:00:00",
"name": "Outdoor ride at last!",
"description": "Lockdown finally over, just go ride around all over the place!",
"type": "Ride",
"color": null,
"moving_time": 7200,
"icu_ftp": null,
"atl_days": null,
"ctl_days": null,
"updated": "2020-04-13T14:58:50.314+0000"
}
Note that the future fitness parameters (after the workout) for that date have been calculated.
If anyone is looking at the athlete’s calendar or fitness chart they will see any changes immediately.
Update 22 April 2021:
- The workout description is now parsed. This means that workouts created or updated via the API have training load calculated and get “time in zones” and so on. This also applies to workouts synced from an external calendar.
- You can now create/update workouts from zwo, mrc and erg files.
POST /api/v1/athlete/{id}/events
{
"category": "WORKOUT",
"start_date_local": "2021-04-29T00:00:00",
"type": "Ride",
"filename": "4x8m.zwo",
"file_contents": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<workout_file>..."
}
Response:
{
"id": 610062,
"icu_training_load": 116,
...
"name": "4x8m VO2 Max",
"description": "These are horribly nasty.\nCategory: Horrible\n\n- 20m 60% 90-100rpm\n\nMain set 4x\n- 8m 110%\n- 8m 50%\n\n- 10m 60%\n",
...
"workout_doc": {
"steps": [
{
"power": {"units": "%ftp", "value": 60},
"cadence": {"end": 100, "start": 90, "units": "rpm"}, "duration": 1200
}, ...
],
"duration": 5640,
"zoneTimes": [1920, 1800, 0, 0, 1920, 0, 0, 0],
"hrZoneTimes": [1920, 1800, 0, 0, 1920, 0, 0, 0]
},
"icu_intensity": 86.04798
}