API access to Intervals.icu

Just to add to app4g’s answer:

Thanks David for the complete and comprehensive answer. I was looking for completed activities.

Hi @david ,
I am thinking about creating Android widget that shows current Load/Fitness/Fatigue/Form and maybe some more stats on home screen.

For that I would need some kind of Auth flow for users ( similar to Strava ), is there an API for that, I couldn’t find anything like it in swagger

Thanks

search for oAuth

I did a search, and the only thing I see is o-auth-server-controller which returns all apps the user is authorized

2 Likes

Where can I see my weight in the GUI after changing it through the API?

Using the API I add my weight to wellness data like this:
URL = “https://intervals.icu/api/v1/athlete/{i99999}/wellness/{data[“id”]}’”
Where data[“id”] contains the date as you see in the json string, which I also parse as data:
{“weight”: 89.569, “id”: “2023-05-16”}

By doing this I get a 200 response. But where in the web interface of my profile can I find the new weight I added?

The weight shown on the home page in below screenshot, is not the weight I entered through the API. i would have expected it to show the API weight on May 16th in the calendar.

Should I do it differently?

You should see it there. Maybe the web app hasn’t refreshed? You could also click the day to open the wellness dialog. That refreshes data from the server. You can also do a GET to that url.

Doesn’t show a thing.

If, during testing, I do multiple updates, would that be an issue?

I’ll try the GET to see what is returned.

You need to click “Wellness Data” to open the dialog.

image

When I do a GET like this: “{icu_api}/wellness?oldest={oldestiso}&newest={newestiso}”
I received the following response, weight is None for the last few days. I’m passing weight as float. Is that correct?

Yes it is a float. I just did a call in Postman and it updated my weight and the web app immediately reflected the change:

So I am not sure why yours isn’t working. I had a look in the logs and don’t see your update call for your athlete id. Maybe you are updating a different athlete?

Here is my call:

Athlete 2049151 wellness updated by athlete 2049151 using API_KEY: {“id”:“2023-05-16”,“weight”:74.5}

Thank you for your time !!!

my url is: ‘https://intervals.icu/api/v1/athlete/i60268/wellness/2023-05-16
jsondata is: ‘{“weight”: 89.569, “id”: “2023-05-16”}’
the python code:

    response = requests.put(
        url,
        auth=HTTPBasicAuth("API_KEY", icu_api_key),
        json=jsondata,
        verify=False,
        timeout=10,
    )

response code is 200
and response.content is
b’{“id”:“2023-05-16”,“ctl”:62.95247,“atl”:79.31549,“rampRate”:1.1686516,“ctlLoad”:0.0,“atlLoad”:0.0,“sportInfo”:[{“type”:“Ride”,“eftp”:217.0}],“updated”:“2023-05-16T17:10:14.169+00:00”,“weight”:null,“restingHR”:45,“hrv”:null,“hrvSDNN”:null,“menstrualPhase”:null,“menstrualPhasePredicted”:null,“kcalConsumed”:null,“sleepSecs”:26460,“sleepScore”:null,“sleepQuality”:null,“avgSleepingHR”:null,“soreness”:null,“fatigue”:null,“stress”:null,“mood”:null,“motivation”:null,“injury”:null,“spO2”:null,“systolic”:null,“diastolic”:null,“hydration”:null,“hydrationVolume”:null,“readiness”:null,“baevskySI”:null,“bloodGlucose”:null,“lactate”:null,“bodyFat”:null,“abdomen”:null,“vo2max”:null,“comments”:null}’

I’m going to try with postman to see what I’m doing wrong…

Works through postman. Getting the results just like you said.

So I must be doing something wrong in my script. Diggin’ deeper :wink:

Fixed!!
Found my error. I was passing the json as string instead of .
Thank you for your help.

1 Like

Experimenting with posting a FIT file to intervals as a way of uploading old data. I’m trying the following (using R) but keep getting a 500 error code. Anyone have any ideas. Note the authorisation works as I use that for all kinds of other API interactions, it must be something I’m doing wrong with the POST command.

#post a fit file
url = sprintf(“https://intervals.icu/api/v1/athlete/%s/activities”,df_i$ath_id)
body = list(
file = “/Users/johnepeters/Documents/2407868516_ACTIVITY.fit”
)

fit = httr::POST(url, add_headers(‘Authorization’ = auth),body = body, encode = “json”)
fit$status_code

honestly not sure how to help as I’m using Swift and AlamoFire to do the upload as a Alamofire.upload(multipartFormData:{ multipartFormData in

You need to upload as ‘multipart/form-data’:

Thanks. Next time I need to RTFM. Although now I get a 403 error!

You need to have ACTIVITY:WRITE scope to upload activities. Maybe it is that? I will update the 403 message to indicate why it is a 403.