API access to Intervals.icu

For the Swagger docs: I have added at least a summary to almost every endpoint and many more now have schema info.

2 Likes

Hi,
I would like to create a training plan and import to the plan workout files (zwo format) which I have locally. How can I do that?
I can do that on UI, but can’t find any API which can import the file straight into the training plan.
There is /api/v1/athlete/{id}/folders/{folderId}/import-workout but seems it can’t assign workout on particular day in the training plan.

You can use this endpoint:

POST /api/v1/athlete/{id}/workouts

Create a new workout in a folder in the athlete’s workout library. The folder_id is the plan. Put the zwo in “file_contents”. Use “day” to specify the day relative to the start of the plan.

This is one of the ones I am trying to sort out the schema for so the Swagger docs aren’t great.

Perfect, works nicely, thank you.

1 Like

Wondering if someone can help me figure out where I can get the details for OAuth flow. For now Basic auth works well for me, but I wanted to try Oauth once as the app I am connecting the API to has just API key in the inputs for basic auth. So I think that won’t work unless we have username there which doesn’t have any provision to do so.

The OAuth info is here:

1 Like

thanks David.

Hi I have two questions

– Is there anyway to filter the events for a given date range to only return rides? Or must I filter the API response?

– If I run the GET /api/v1/athlete/{id}/events/{eventId}/download{ext} endpoint that gives me exactly what I’m looking for, however is there a way to pull more than one eventId at a time, or need I design a method to first get a list of the eventId’s I’m interested in and then loop through the same api endpoint for each eventId and store it’s result?

Currently you need to filter the returned events yourself. You should try using this endpoint with the “ext” parameter: get /api/v1/athlete/-id-/events

  • ext: Convert workouts to this format (zwo, mrc, erg or fit) and add workout_filename and workout_file_base64 to workout object

Then you don’t have to download each one individually.

1 Like

Hey Andrii ! In your script work , Still works? I have trouble for pull Wellness data.

I’m new to intervals.icu and checking things out. I love that there’s an API, but I can’t make any requests due to 500-status errors, {“status”:500,“error”:“java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at 48”}

I believe (per [1]) that this may have something to do with the server-side base64 decoding (or perhaps encoding on my end) of the basic auth string in the authorization header.

I tried the “try” button on Intervals.icu API docs as well as the suggested CURL command. Both fail (same error) with the base64 string generated by the API docs system.

I also tried encoding the basic auth string myself with Node (Buffer.from('username:password').toString('base64')) and then making a CURL request, but still the same issue.

Am I doing something wrong in the encoding?

[1] java - Input byte array has incorrect ending byte at 40 - Stack Overflow

I found the solution in this other post I created: Can't make any API requests due to 500 error - input byte array has incorrect ending byte - #3 by stefcameron

It turns out ZWO format is pretty limited. I’m thinking to import workouts by using FIT files.
Is it possible to import and plan FIT workout the same as ZWO with just one REST request?

Hi @david, could we add the following fields to the wellness endpoints? Body Mass Index (BMI), and Active and Resting Energy.

All of those are already created and shared by other users. Click on the looking glass at the bottom of the wellness fields dialog and add them to your profile
You can immediately acces them through the API for reading and writing.

Thanks @MedTechCD , I did see those, but I didn’t know adding them would allow API read and write access, as they’re not currently part of the schema. They’re pretty common, should be added by default, so apps like HealthFit can update them automatically?

‘Automatically’ is doomed to fail if you have different sources.
The reason is that the field names are not standardized. HealthFit may use B.M.I. while Garmin or others may use BodyMassIndex or similar. You will always need a mapper between the source and the destination.

Example: if HealthFit uses B.M.I., the mapper for HealthFit has to make a connection to the correct field in Intervals that may be named BMI. The mapper for Garmin would then need to link BodyMassIndex to the same BMI field.

Intervals is very versatile and tries to connect with any other platform that has a way of exporting data. Be it file-based, API based, connection initiated by the sending or requesting platform… etc

1 Like

Sure, yeah. If there’s no standard naming convention for health/wellness metrics, then the source that decides to integrate with intervals will need to perform the mapping before updating the data via the API. But, isn’t this already happening for the existing fields in the schema, though? I’m not sure I understand why adding BMI, ActiveEnergy, and RestingEnergy would change any of that.

When you said “You can immediately access them through the API for reading and writing.”, I suspect that’s only for the athlete that has decided to add that particular field not all athletes, correct? If so, then how do you convince sources that decide to integrate with intervals to make the appropriate changes on their side to update it. If I were them, I’d only do it if that field was in the schema for all the athletes.

due to the extensive configurability of intervals the the number of users who either don’t use the pre-defined fields (and create their own private versions) this will come as a challenge to any software developer to support. (This is also the case for Garmin’s Connect IQ Developer fields where developers has free rein to name Power as Power1, Power2, myPower, MyAwesomePower etc… and then users in Intervals.icu will need to do the mapping themselves to pick up these fields)

Having said that, I do believe that a software developer can do their own mapping to a defined intervals.icu field and update that.

I believe Marco (HRV4Training) has previously stated that he should have decided to only integrate with dropbox due to this situation.

1 Like

Hello David,

I am not that sure if I ran into a rate limit today. I am running a gscript to update the LTHR with specific values. Are there any limitation to consider?

many thanks,
Johannes