API access to Intervals.icu

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

If you got a 429 then you did hit a rate limit. Just slow down the calls a bit. But I am not seeing any 429s in the logs? Validation errors will return a 422. What error did you get?

Yes it is. Use this endpoint: POST /api/v1/athlete/{id}/events

Include these in the payload:

"file_contents_base64": "string", // fit file contents
"filename": "string", // workout.fit or whatever

Along with the date etc…

Thanks for this very quick reply.

I have to apologize. In so many situations, the issue was sitting in front of the screen. With too much refactoring I introduced a check too much. Could solve it in the meantime. Stuff works.

The set of APIs exposed from ICU is pretty amazing. Really! Thanks.

Background: I am not that happy when changing the HR-Zones, that all historical LTHR could not be simply kept. For this reason a script does the job to correct them.
image

3 Likes

Limited I mean, ZWO doesn’t support target range, which I like to see in my workouts.

Beautiful, thank you

I agree with this – @david, could you chime in?

I assume that it’s like this because FTP and Threshold Pace should change much more often than LTHR, but I think that it should be kept for previous activities if there’s a need to Re-analyze (e.g. to compute a new field).

I did some tests and LTHR is changed when you do Actions → Update zones under the ride timeline chart or use the activity list view to do the same.

(edit 2023-01-06: I must have been half asleep when I tested this before and said it didn’t change LTHR)

1 Like

Is that the same behavior for Re-analyze?

Also, does that mean that you’re not able to change the LTHR for an activity like you can with FTP/Threshold Pace?