API access to Intervals.icu

Sorry but I didn’t know where else to go to ask this question.

I came to Intervals from an Apple Numbers workbook that I used for 5 years after giving up on other apps.

I am hoping to mimic my wellness data entry form on Google and link to Intervals via the API to upload my daily wellness info. Is this possible? It would save me from entering twice every day.

The best option would be the ability to re-arrange the wellness data entry order so that it matches my data. This would make entry much easier and get me to my goal of having all data in one place. So far, your app is the closest thing to my spreadsheet.:v:t3:

If you can build your own tool, there shouldn’t be a problem sending the data over the API.
I do that from an Excell file and use curl to send JSON formatted data to the API.
Here is an example of such a JSON string that is preformatted in Excell. A macro with a curl command takes the string as an argument and sends it to Intervals API.

" {"id": "2023-11-18", "systolic": 131, "diastolic": 78, "sleepSecs": 31860, "sleepQuality": 2, "readiness": 62, "restingHR": 56, "hrv": 24, "hrvSDNN": 23.35, "baevskySI": 16.02, "stress": 3, "SleepingHRrange": "55 - 72", "AwakeTime": 2040, "REMSleep": 6900, "LightSleep": 19980, "DeepSleep": 4980, "HRduringBP": 59, "PNSIndex": 0.26, "SNSIndex": 0.33, "MeanRR": 1080.45, "PoincareSD1": 16.77, "PoincareSD2": 28.14, "RespRate": 14.68, "LFPower": 244.86, "HFPower": 138.66, "LFPowerNorm": 63.84, "HFPowerNorm": 36.15,"RatioLFHF": 1.77, "comments": " "} "

Depending on your knowledge/willingness to learn the use of API, curl and their respective syntaxes, this can be considered easy/complex/impossible…

I can’t for example give you an exact curl command or JSON string that will work on your system because the curl syntax is different in between Windows and iOS. But it shouldn’t be that hard to get it right if you Google curl manual for iOS…

2 Likes

Thank you for the help. I tried to the GET info provided but received an error. Will keep trying.:v:t3:

You can use this to get wellness data:

GET https://intervals.icu/api/v1/athlete/2049151/wellness?oldest=2023-11-08&newest=2023-11-11

To update wellness do a put to the date:

PUT https://intervals.icu/api/v1/athlete/2049151/wellness/2023-05-16
{
  "weight": 74.5
}

Thank you. Will try this later today. Now I’m trying to figure out why my workout didn’t merge with my planned.

Hi @david, I am working with the following endpoints (activities and events):

  • https://intervals.icu/api/v1/athlete/XXXX/activities?oldest=2023-11-13&newest=2023-10-26 and
  • https://intervals.icu/api/v1/athlete/XXXX/events?oldest=2023-11-13&newest=2023-11-26&ext=json&powerRange=0&hrRange=0&paceRange=0&locale=%2A&resolve=true

the activities endpoint returns the dates in the following format:

start_date_local: '2023-11-18T20:26:08',
start_date: '2023-11-18T19:26:08Z',

the events endpoint returns the dates in the following format:

start_date_local: '2023-11-25T09:00:00',
end_date_local: '2023-11-25T10:00:00',

I am having issues trying to do date comparisons for the events case, as dates come in a local time, instead of using “Z time” or “Zulu Time”, would it be possible to update the API to also return the start_date and the end_date in a standardised Z time?

As temporally workaround, should I need to fetch the timezone from the http://intervals.icu/api/v1/athlete/XXXX endpoint?

…but it seems to be a bit of an awful patch for it :frowning:

Thanks in advance

You should be able to just use the _local dates for comparisons between activities and events. Note that events don’t have time (i.e. time is T00:00:00) if no time has been captured.

Hey @david, you are right about the comparisons, but I think there might be another issue which is how the end_date_local is stored in those cases where the time is not selected, and the default T00:00:00 is applied.

If you check this example, the “Sick” event is added to the calendar from “2023-11-23” to “2023-12-01” (3 days), but fetching the events endpoint from the API, it returns this data:

  "category": "SICK",
  "start_date_local": "2023-11-29T00:00:00",
  "end_date_local": "2023-12-02T00:00:00",

As you can see end_date_local is registering the date as 02 of December (2023-12-02T00:00:00), when probably it should be 2023-12-01T23:59:59 to make sure that events is not populated or adjusted to the day 02.

If on the other hand, this is an expected behavior, then I will deal with them locally :slight_smile:

Thanks for the awesome API and platform

All day events always to to the next day, at least in RFC5545. So an end timestamp of 2023-12-02T00:00:00 for an event lasting the whole 1st of December sounds right to me.

2 Likes

Tx. I decided to make end dates for events exclusive. Thats why it is 2023-12-02T00:00:00 instead of 2023-12-01T23:59:59.

1 Like

Hi @david . I’m trying to use https://intervals.icu/api/v1/athlete/{id}/athletes to get a list of coached athletes and the athlete tags in powerquery/powerbi. ‘Shared folders’ appears in the data table which i believe its where the ‘icu_tags’ is found. However the shared folders is empty… any ideas on this please? I want the call to return at least athlete id + the associated tags shown on intervals.

Thanks

I just tried that myself and icu_tags and icu_notes are returned in the top level object for each athlete:

    "icu_tags": [
        "Coaching",
        "MTB",
        "Fast",
        "Roadie"
    ],
    "icu_notes": "Best cycling wife ever!",

Note that you can only call that endpoint with your API key, not a bearer token for an app.

Okay, I tried this and didn’t get it to work for me. Me for sure.

Is it possible to do from Dropbox? I am an Apple guy and trying to use Google sheets is a pain to me. Don’t think that I can send it from Apple. I don’t mind manual but I signed up for EF coaching and they use T’sP so now I am doing double entry.

BTW I created a Google sheet version of my Numbers data and tried to use the Intervals PUT you supplied me with no luck. Is this where? Sorry to be so much trouble.


For updating wellness data you can actually just use the CSV download/upload from the UI:

So just to be sure, I downloaded the CSV and if I fill in today’s data and upload it will populate?

Sorry, I measure twice and cut once.

Yes, it will.

Just make sure your formatting is compatible, eg. date format is yyyy-mm-dd

1 Like

I went through this Swagger UI.

But as there are no descriptions against each action in the documentation, I assumed few things. But I am not pretty sure about them.

Can I create a workout in the library using this API?

This is the reference for the location I am referring to that option. Not adding workouts on athletes calendar but rather creating workouts.

Yes you can. Use this endpoint:

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

You can see what to send by adding a workout in the app and looking at the network call. I need to spend some time sorting out those API docs.

You do not need to supply “workout_doc”.

1 Like

thanks David. I will try this. Appreciate it brother.

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

2 Likes