API access to Intervals.icu

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.

Thanks it works. I hadn’t ticked the right box when making the oauth connection.

1 Like

Hi @david,

Thanks for your work, I can’t believe I’m only just finding out about your work and developments now, it’s awesome!

I’m trying to build a meal planner (based in google sheets for now) that uses future planned workouts (synced from trainer road and other future planned workouts I add to the callender) and their expected calories to build into my current model. At the moment I do a week at a time and manually input the daily exercise calories for the week ahead. I’m wanting to do it automatically and indefinitely into the future.

I’ve got a little experience with API’s. Is it possible to retrieve calorie data by date?

If so what is API end point for this?

Thanks again for your work.

Cheers,

Johno

You can get the kCal consumed from past activities but I don’t think they are available for future planned workouts.
You may be able to find something here:
https://intervals.icu/api/v1/docs/swagger-ui/index.html#/

Tx. You can’t get expected calories from the API directly. However planned workouts using power do have a joules field which you could use assuming a given efficiency.

You can list events via the API: Swagger UI

I’m trying to manually add some activities through the API, but not all data is going through.
This is what I’m sending to the API:

{
"start_date_local": "2018-02-18T00:00:00", 
"type": "Run", 
"name": "Run", 
"distance": 5200.0, 
"moving_time": 1980, 
"calories": 460, 
"average_heartrate": 144, 
"max_heartrate": 175, 
"description": ""
}

The activity is added and the moving time is correct, but heart rate, calories and distance data is missing. Any ideas how to fix that?

I got the distance working when I added "icu_distance": 5200.0, but still no calories or heart rate…