API access to Intervals.icu

TQ! I could have sworn that I saw in a post somewhere that it was just the date w/o the time included as well.

in any case, Appreciate the help.

Hi @david

I was testing my app’s abiity to get the workouts for Today(WOD). Same like previous, i only have workouts on Sept6 and Sept7 (workoutname is same as the date to make it easier to understand)

Is the following expected given that you have indicated that the “server now does this automatically”?

In any case, knowing how the API expects the date, it’s no issue for me to do the “T23:59:59” (Which I am doing now and works)

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-05&newest=2021-09-05
No workouts

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-06&newest=2021-09-06
WorkoutName:Sept6

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-07&newest=2021-09-07
WorkoutName:Sept6

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-08&newest=2021-09-08
WorkoutName:Sept7

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-09&newest=2021-09-09
No Workout

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-05T00:00:00&newest=2021-09-05T23:59:59
No Workouts

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-06T00:00:00&newest=2021-09-06T23:59:59
WorkoutName:Sept6

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-07T00:00:00&newest=2021-09-07T23:59:59
WorkoutName:Sept7

intervals.icu/api/v1/athlete/{ID}/events?oldest=2021-09-08T00:00:00&newest=2021-09-08T23:59:59
No Workout

Looks like I have a few bugs to fix if you don’t supply time with the date.

Thanks @david no issues here as the format is now known.
Don’t worry about fixing it.

1 Like

feature request:

It would be great to have the GET /api/v1/activity/{id} endpoint accept several {id}s. My use case is retrieving all activities from /api/v1/athlete/{athleteID}/activities.csv then running them through a classifier to get the activities I want more details for, and I feel grimy calling the GET /api/v1/activity/{id} endpoint in a loop.

Thanks for considering this idea!

1 Like

I added: GET /api/v1/athlete/{athleteID}/activities/{id1},{id2},.. which returns a JSON array of activities.

Add ?intervals=true to include the interval data.

The activities are streamed back one per line so you can parse them one at a time if you like:

[
{"id": "i2132160", "start_date_local": "2021-10-02T08:07:53",..},
{"id": "i2155441", "start_date_local": "2021-10-05T06:53:52",...}]

@david Where would one get the data for
eFTP / FTP and Weight?

I found that I can get eFTP/FTP and Weight from Actual Activities (https://intervals.icu/api/v1/athlete/(athleteId)/activities) endpoint. But for Planned Workouts, These are not populated.

Am I supposed to get these from the wellness endpoint?
Actually, is there an endpoint for getting user preferences? I’m missing things like UserWeight / Power Zones (i’m parsing the workout_doc to get this), Metric vs Imperial units? Things like that?

Thanks…

For eFTP and FTP is probably ok to just use the athlete’s current settings for future workouts. For eFTP use the value from the most recent activity. For weight the most recent from the wellness endpoint should do.

You can do GET /api/v1/athlete/{id} to get most info about an athlete including settings for different sports.

Is there any shortcuts to get the most recent (updated) value from any of the endpoints? I really dont want to be parsing thru entire months of data to get eg: userWeight or RestingHR

eg: I just tried the wellness endpoint, if I don’t put in an oldest/newest parameter, it will push close to 2 months of data (could be from the day I signed up? not sure) and the (one) day which I put in my fake userWeight is on Oct-1 for eg. (The other days would be “null” which is correct)

I guess this would apply for eFTP as well.

I tested this and seems like I can get the most recent value from the

GET /api/v1/athlete/{id}

endpoint. Could you please confirm if this is true?

I realised that there are multiple FTP and eFTP involved.
There’s Activity FTP
There’s Settings FTP (which also has indoor FTP)

seems like Settings FTP is used to plan for workouts ( There’s also indoor FTP, but doesn’t seem to be used for workouts creation.)

how is activity FTP derived from?

i tested by purposely changing my settings FTP to 200w but activity FTP maintains at 150w

when I look at the weekly summary popup, it seems like it’s using the Activity FTP.
So my question is, to be in sync,

at the start of the week, when there’s NO Actual rides have taken place, where / which FTP is taken for the summary popup?

What is the API call to delete all planned workouts from x date to y date?

The most recent weight and resting HR in wellness is copied to the athlete and visible in /settings. When resting HR or weight is needed for a new day (new activity has come in) then the value from the athlete (/settings) is used but flagged as temporary. If wellness is updated then new new weight and resting HR are copied forward over whatever temporary values already exist.

It’s all a bit complicated and took ages to get right.

I think eFTP and FTP in the week info popup are taken from the most recent activity even if in a previous week.

When an activity is first analysed it is assigned an FTP from whatever has been configured in /settings for the sport. If it is an indoor activity then it gets the indoor FTP. If you edit the FTP on your most recent activity it will also update the one stored on the athlete (/settings). But the reverse is not true. Once an activity gets an FTP that stays unless it is edited.

1 Like

DELETE /api/v1/athlete/{id}/events

Params:

  • oldest: yyyy-MM-dd
  • newest: yyyy-MM-dd, optional leave out to delete all events from oldest
  • category: Comma separated list of event categories to delete e.g. WORKOUT,NOTE,RACE_A etc.
1 Like

OK. Thanks. I’m pulliing a PER week data, so I guess if there isn’t an eFTP, i’ll have to

  1. put in NA first
  2. when I get an eFTP, for the week, I’ll store it somewhere
  3. update the Latest eFTP from any latest acitivity from the pulled week and then update the store (and use it moving forward)

for FTP, I agree w/ your approach of using the latest FTP from an (edited or not) activity and then applying it to settings. (This denotes that this would be the athlete’s latest FTP moving forward or “from this day on”).

However, shouln’t it also be true for the reverse, from a “from this point on” perspective? If I update my settings page FTP, it should also reflect in future activities - Next Day (not today if an activity has already been executed for today.)

agree

BTW, I read somwehere that the “Time in zones” are not broken down to Ride / Run / swim /Others and basically combined via the “same zone” numbers? Hence I do not / will not need to separate them like I’m doing for eg: ComplianceDist [Run:10%, Ride, 20%] etc… Correct?

Yes the week info popup combines them all. You can still get time in zones totals for specify activity types on the /totals page.

I am planning to add fitness, fatigue, form, eFTP and related fields to the wellness records. This will make it very much easier to get this data from the API or in CSV download.

2 Likes

Hi. Is there a way with API to get 1m, 5m, 20m, 60m effort for each individual ride?
Thanks

1 Like

Unfortunately not. I need to make the power curve for an activity available through the API. Also an endpoint to pull just specific durations from all activities matching a filter would be nice. I have had this on the todo list for a long time for the front-end, will add the API endpoints when I get it done.

1 Like

Hello.

I always have “JSON parse error” when I try to POST a workout. Could you, please, put a more detailed payload example of this?

Thank you!

Which endpoint are you POSTing to? Have you set the content type to application/json?

For example:

POST https://intervals.icu/api/v1/athlete/3495782/events

{“category”: “WORKOUT”, “start_date_local”: “2021-11-04T00:00:00”, “type”: “Ride”, “filename”: “TEST.zwo”, “file_contents”: “<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<workout_file>joseTESTDescr</workout_file>”}

Hello,

Nice API for this one :slight_smile:

I will develop a little android mobile app to post wellness data to intervals.icu

1 Like