API access to Intervals.icu

Many thanks @Andrii_Magalich for sharing this, really low effort way in to having a play with this excellent API.

In case of interest or helps anyone else, here’s a link to the doc I built based on what you shared:

Main thing the sheet is for is to suggest what your next activity could be to achieve a user specified Form value - in the sheet imaginatively called “Next Activity”. Also recreates the fitness/fatigue chart.

To make it work take a copy, then your details (user number and API key) simply need to be entered in the red cells near the top of the sheet called "Daily Record’, which also has the button to manually trigger pulling data from intervals.

3 Likes

You’re welcome!

Is there a way to pull the compliance to plan % over the API? and what are the rules for colouring this. Using the API more and more now to integrate with our Pro Cycling Team Hub image

Unfortunately that is currently done client side so its not in the API. Would be nice if it was though.

There is a field on activity “paired_event_id” that is the ID of the paired workout if any. Pairing is done automatically if the workout matches the activity closely enough (sport and load/time) and can also be done manually (drag and drop). So you might be able to use that.

The colours are as follows:

if (p >= 80 && p <= 120) return "good"
if (p >= 50 && p <= 150) return "poor"
return "bad"

.good {  color: #2ca02c; }
.poor {  color: #ff7f0e; }
.bad {  color: #d62728; }

I will see what I can do about getting compliance into the API. It’s a bit complicated and a big advantage of doing it “client side” on demand is that it is always up to date. I would need to store compliance for the week on the wellness record for the Sunday or something.

1 Like

Thanks David. Not a problem I can pull both the event and activity and do the comparison.

Makes sense to keep it client side as you say.

Cheers

John

Just after the key ‘current’ values for an athlete’s fitness, fatigue, form and eFTP. Am I right in thinking that these are not available from the wellness endpoint?

I have looked at the summary endpoint but this returns data for multiple athletes and is proving a nightmare to parse in my app.

Thanks

You can get CTL, ATL, eFTP etc from the wellness endpoint GET /api/v1/athlete/{id}/wellness?cols=ctl,atl,rampRate,ctlLoad,atlLoad,eftp

https://intervals.icu/api/v1/docs/swagger-ui/index.html#/wellness-controller/listWellnessRecords

1 Like

Great. I was thinking these were something else :man_facepalming:

what does athlete tags mean here? Is there any way to only bring back info for yourself from the summary endpoint?

Those are the tags as attached to athletes on the /athletes page. I just added a special one “self”. If you use that only your own data will be returned.

Thank you - is the ‘self’ tag auto applied to all users, so my code will work for everyone?

Yes if you use tags=self then only the calling athletes data is returned. So this will be the athlete for the bearer token for oauth or the athlete for the API key.

1 Like

Perfect, exactly what I was after. Thanks

I changed it a little bit. Now if you do tags=self then the data for the athlete id in the path is returned.

1 Like

I have a question. I am trying to pull the future events on the athlete calendar with an API. I get all the training plan data that I need but I am missing average power, normalised power and variability index. Is it possible to get at least variability index of a calendar event with API and if it is how?

Thank you

I have added those fields to the workout_doc object. Note that they will only show up on newly created or edited calendar events.

Thank you very much. I am aware of that.

Hi David - I suspect I know the answer to this but I’ll ask anyway :slight_smile:

Is it possible to pull the stream data, e.g. time, power, id, date, for multiple activities at once if a start and end date is passed?

Thanks

John

Not currently but I could add that. Would be a very big payload!

Yeah at the moment I’d loop through multiple athletes to get activities for the last 30 days then loop through each activity to pull the stream data. I only need time, HR and power.

Not sure which is the most efficient way of doing this.