API access to Intervals.icu

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

seems like you’re using the right fields…

Ooh sorry I didn’t implement all the fields for manual activities. I have just added:

coasting_time
max_speed
calories
average_heartrate
max_heartrate
total_elevation_gain
icu_rpe
feel

Also you can now use distance instead of icu_distance.

1 Like

Is possible to upload directly the .fit file from android app ?
I have Ipbike app and I have the possibility to add an OpenFitApi.
I add a intervals.icu with
User id : API_KEY
Pass: my api key
Site : intervals.icu/api/v1/athlete/xxxxxx/activities

but return ERROR 308 PERMANENT REDIRECT

THANKS

Yes it is possible. Here is an example with curl:

curl -u API_KEY:xxx -F "file=@my_activity.fit" "https://intervals.icu/api/v1/athlete/2049151/activities"

The content type needs to be multipart/form-data. The -F switch to curl sets that.

1 Like

Nothing to do @david …with my app I tried but dont works…

Does the curl version work?

User is your userid found on the settins page.pas ord is API_KEY

No David

User id is API_KEY…password api key

Your screenshot is not showing what you’re saying.
image

Here’s a working curl (both api-key and id are bogus)
curl.exe -u API_KEY:1t3r49tm3482s2u3h3tyhunof https://intervals.icu/api/v1/athlete/i40857/activities?oldest=2022-11-15^&newest=2023-10-14 -o activities.json

Where API_KEY is the password, 1t3r49tm3482s2u3h3tyhunof is the api-key found on the Intervals settings page and i40857 is the intervals user-id.

User id : api-key on the settings page
pass API_KEY
Site: replace xxxxxx with your athlete id

2 Likes

Thanks but don’t works .
No problem…I upload msnually the fit file
Thanks

I tried searching for this OpenFitApi but didn’t really find much info about what it is and how it works.

Would you be willing to clarify? TX

also, i think i’ve responded to you in another thread. You can consider using Dropbox.

I wrote to developer…I am in the same situation as you.
With my app I can send the workout by attaching it to the email directly to my shared folder with intervals.icu in dropbox

This is how I do it using R where:

ath_id is the athlete intervals ID
fn is the full file path name for the FIT file on my PC
auth is ‘Bearer XXXXX’ where XXXX is the athlete API token

url = sprintf(“https://intervals.icu/api/v1/athlete/%s/activities”, ath_id)

body = list(
file = httr::upload_file(fn, type = “file”)
)

httr::POST(url, add_headers(‘Authorization’ = auth),
body = body,
encode = ‘multipart’)

1 Like

Hi, first of all, thank you for this amazing tool!
Second, I wanted to ask if there are endpoints to upload planned workouts to a specific day in the calendar. I managed to download all my planned workouts from TP as fit files. I can also drag and drop them into my folder but putting them into my calendar one by one seems tedious. I was wondering if there is a way to automatically add planned workouts to the calendar using the API.

1 Like

You need to use this endpoint:

POST /v1/athlete/{id}/events
{
    "start_date_local": "2023-11-08T00:00:00",
    "category": "WORKOUT",
    "type": "Ride",
    "filename": "workout_1234.fit",
    "file_contents_base64": "...base 64 encoded fit file data .. "
}

There is also a file_contents for text file formats (zwo, mrc, erg). Intervals.icu will calculate the load, duration etc…

Hi David, thank you for the quick reply. I was able to get my script to work! :slight_smile:

1 Like

Hi!

Do you know if there’s a way to see all the possible activity types?

Thanks!

Here they are (but I do add new ones from time to time): Server side data model for scripts