API access to Intervals.icu

The gear data is available:

GET /api/v1/athlete/{id}/gear{ext}

The ext bit can be empty for JSON or .csv for CSV download. You can also edit etc… Have a look at the endpoints used by Intervals.icu and just add in the /v1/ bit.

I need some help please, to be able to import wellness data, per athlete, into my Excel file(s) that has their annual training plan linked to the data.

I am using the Get Data from Web option in Excel, but lack a few things to get it to work.
Web tutorials indicate there should be an authorisation option to choose from; this is all I have.

I have entered the API key and login details in the Data Source Settings.

What a I doing wrong? Some easy how-to would be greatly appeciated.
If I can get this working, it would prevent me having to manually download data, and copy and paste for each athlete’s ATP.

Are you using Basic Auth or OAuth?

this from 2018 tho:
https://social.technet.microsoft.com/Forums/ie/en-US/f3099495-eba9-4600-85c5-131257564c82/get-data-from-web-with-authentication-connection-error?forum=excel

he newer experience uses Power Query for retrieving the web page. Specifically the From Web experience is using the M function Web.Page. Web.Page uses IE to read the webpage, and IE does not give the ability to compartmentalize cookies, which could present a security risk of leaked cookies. To prevent the security risk Basic Auth and OAuth are prohibited with Web.Page.

Or are you using Power Query?

What should I be using?

typically, Basic Auth means you can only access your own acc. I presume you have all your athletes’s user/pass or somehow they are linked under you as “coach” and interval’s access scope allows you (as coach) to access them all.

I would also presume that you don’t have OAuth (you need to specifically request for it).

In any case, I am not sure how to use Power Query nor the connector within excel. (Have not tried it before)

You should use basic auth with username API_KEY and password your API key from the /settings page. This will let you get at everything you can see when logged in so it will work for athletes you follow. I am not familiar with the Microsoft tools you are using.

@app4g The oauth bearer tokens are more restrictive and only allow access to the specific athlete and authed scopes

1 Like

Thanks @app4g and @david

I’m basically trying to import the wellness.csv file into an excel sheet, like a normal web query.
The problem is getting passed the authorisation step.

The URL is the wellness hyperlink:
https://intervals.icu/api/athlete/{my id}/wellness.csv

Access Web content allows me to enter API_KEY and my API key in the credentials settings.
Not sure if Privacy level makes a difference.

However, when I try connect it gives the error
image

Aha you have to use /api/v1/athlete/… and not /api/athlete/…

Basically most calls the Intervals.icu app makes are part of the API but you need to add that /v1/ bit.

1 Like

BINGO!

Thanks David, it works

2 Likes

Just found out about the API. Is there a how-to document that hold all the different calls available?

Hi, @david

Facing an issue in posting workout using the https://intervals.icu/api/v1/athlete/{{athlere_id}}/events/ API to the calendar using JSON format.

In the workout_doc.steps object if I change the units from %ftp to ftp it still takes %ftp.

{ "steps": [{ "duration": 600, "power": { "value": 63, "units": "ftp" } }] }
behaves like
{ "steps": [{ "duration": 600, "power": { "value": 63, "units": "%ftp" } }] }

That’s because there isn’t all that much validation and “ftp” isn’t valid so it falls back to the default which is “%ftp”.

It is probably better to send in formatted text in the description field rather than the steps. For some workouts (e.g. those using distance and soon zones) Intervals.icu may re-parse the description and ignore the steps.

Only this thread and the one about OAuth. I hope to get a doc site up soon. Most calls made by the Intervals.icu web app are also in the API. Just change /api/blah to /api/v1/bla.

I’m trying to use the Wellness endpoint to access the atl / ctl data but I’m running into a slightly strange bug. Everything works well using basic authentication and the API_KEY, but I’m getting a 403 “Access Denied” error when using the Bearer Token obtained from the OAuth log in. I’ve verified the token is correct on the Activities endpoint which works fine.

I’m using this URL: https://intervals.icu/api/v1/athlete/i20992/wellness
With the header: Authorization: Bearer XXX

Maybe I’ve screwed something up, but do you have any ideas @david

Did you check if you have the right / all the access granted?
I had this issue once, everything works w/ basic but oAuth doesn’t cos oAuth has diff access levels.

The app need to have WELLNESS:READ scope for the athlete to get at wellness data. Your app only has ACTIVITY:READ for that athlete.

The API_KEY auth works differently granting access to everything the athlete can get at.

@David @app4g Thanks both.I knew it would be something stupid. Apologies

1 Like

Hey @david, thank you for such an amazing product and this API. Is there any way to update profile info such as name, email, avatar etc?

I can send there “name” and server even answers 200 code, but name seems unchanged

Currently you can only update name, email and some other personal settings if you are calling using the API key for the athlete being modified. You can’t update these using a bearer token from OAuth. I could change this for name and profile pic?

I’m using API key for request above. I didn’t know that there is a possibility to authorize user with OAuth :slight_smile:
Can I use bearer token to update weight and resting HR as well?

Yes you can. You need WELLNESS:WRITE scope.