API access to Intervals.icu

Tx. I have fixed this for deploy Friday AM (GMT+2). Rows with no hrrc data were shifted over. Sorry about that.

Hi David;

Top work as always - is there a way to get headline stats for any of the riders you coach?

Ross

You mean for all of them at once or an individual athlete? What stats are you looking for?

Hi David,
Thanks for coming back to me -
I’m thinking an endpoint like /coach/overview
which would return the data found on this part of the screen
image

Assume it would be like
athletes: {
id : { fitneess: X , fatigue: X, Form: X, Weight: X, last7day: { load: x, hours: float },
id : { fitneess: X , fatigue: X, Form: X, Weight: X, last7day: { load: x, hours: float },
repeats for all coached riders
}

Something like the CSV link on that page? I have just added that to the API (will deploy Tues AM GMT+2):

GET /api/v1/athlete/{id}/athlete-summary{ext}?start=yyyy-MM-dd&end=yyyy-MM-dd

  • Calculates totals by week
  • Fitness, fatigue and form are as of the last activity completed in the week which may not be the last day of the week
  • ext is .csv for CSV output and JSON otherwise
  • tags Optional comma separated list of athlete tags to only return those athletes

Note that the format of this is going to change. I still need to change ‘byCategory’ to bySport and include time in zones for power, HR and pace separately etc…

2 Likes

Hi -
How do I go about pulling planned activities for only today? eg: Today’s workout much like TP’s workout of the day

I tried to use this URL
https://intervals.icu/api/v1/athlete/{id}/events?oldest=2021-09-07&newest=2021-09-07

I placed 2 workouts, one on sept6 and sept7, I would like to get the activityID for only sept7 (which is today)

I can only get it to work if I put tomorrow’s date.
eg:
https://intervals.icu/api/v1/athlete/{id}/events?oldest=2021-09-08&newest=2021-09-08

@David could you please let me know what I’m doing wrong? Appreciate it. Thanks

I have fixed this. It would have worked if you included a time in newest e.g. 2021-09-07T23:59:59. The server now does that automatically.

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?