API access to Intervals.icu

If you just want to play with the API with your own data you can use your own API key (found near the bottom of the /settings page) with basic auth (username API_KEY):

For OAuth you need to send me some stuff:

Hi! Is there an endpoint to retrieve the data displayed in the fitness chart? I would like to analyse the calculated data from this chart and can only seem to find endpoints which display the raw data containing the activities. (such as https://intervals.icu/api/v1/athlete/{athleteId}/activities.csv)

Kind regards!

if you’re looking for FORM/FIT/FATIGUE etc… you can get it from the wellness endpoint

https://intervals.icu/api/v1/athlete/(athleteId)/wellness?oldest=xxx&newest=yyy

2 Likes

I’m looking for a way to get just the “id” (date) and “comments” field as a response but can’t get it to work. I either have a complete Wellness record or an error on everything I tried.
Can’t get it right on Swagger or in my curl command. Tried with the line found higher in this thread: GET /api/v1/athlete/{id}/wellness?cols=id, comments but it returns a full wellness record.
Would appreciate if someone can tell me if this can be done and how.
I’m trying to partially automate my Kubios HRV results by OCR-ing my phone screen and pasting the OCR text in the comments. Then a batch file retrieves the comments field, interprets and sends back a PUT with the extracted results.

I’m getting everything too…

EDIT: Found out…

curl -u API_KEY:xxxxxxxxxxxxxxxx https://intervals.icu/api/v1/athlete/{id}/wellness.csv?oldest=2022-10-01&newest=2022-10-06&cols=restingHR,comments,atl,ctl

where the available columns are:

date,weight,restingHR,hrv,hrvSDNN,readiness,menstrualPhase,menstrualPhasePredicted,kcalConsumed,sleepSecs,sleepScore,sleepQuality,avgSleepingHR,soreness,fatigue,stress,mood,motivation,spO2,systolic,diastolic,hydration,hydrationVolume,bloodGlucose,lactate,bodyFat,abdomen,comments,injury,baevskySI,vo2max,ctl,atl,rampRate,ctlLoad,atlLoad,Ride_eftp,Run_eftp

NOTE: Date is NOT an available column. It’s default and will always be there.

1 Like

Can’t see what I’m doing wrong but still get errors. Underneath line in a batch file running in Windwos 10 command line.
curl -u API_KEY:{key} https://intervals.icu/api/v1/athlete/{id}/wellness.csv?oldest=2022-10-06&newest=2022-10-07&cols=comments -o direct.txt.new

‘newest’ is not recognized as an internal or external command,
operable program or batch file.
‘cols’ is not recognized as an internal or external command,
operable program or batch file.

sorry about that… You’re missing the aprostophe…

curl -u API_KEY:xxxxxxxxxxxxxxxx 'https://intervals.icu/api/v1/athlete/{id}/wellness.csv?oldest=2022-10-01&newest=2022-10-06&cols=restingHR,comments,atl,ctl

try that… w/ the ’ before http and at the end…

For some reason, I seem to always get 2 spaces before and 1 after the ampersand (&). That’s what is causing my problem. Following link is what I see in the command line error.

oh… not sure about that… I’m using curl from a Mac’s terminal

perhaps you can encode the ampersand?

Brief Introduction to URL Encoding.

Got it:
For Windows cmd line you need to escape the & by a ^& and use no quotes, single or double.
This one finally gives me what I’m after, written to a csv file

curl -u API_KEY:{key} https://intervals.icu/api/v1/athlete/{id}/wellness.csv?oldest=2022-09-30^&newest=2022-10-07^&cols=comments -o direct.csv

2 Likes

Some more info on using cURL from command line or batch file in Windows:

  • Windows requires a ^ at the end of each line iso of the \ (or type everything on one line without line breaks but that’s difficult to read)
  • double-quotes " instead of single-quotes ’ (except within json brackets {})
  • and within the json data, all the double-quotes must be escaped with \ (example {\“ctl\”: xx}
  • & in url must be escaped with ^ (^&)

Haven’t found out yet how to return comment strings with é è à s².

Example for a working GET in cURL sending the result to csv file in the same location as the batch file:

curl -u API_KEY:yourAPIKEY ^
     https://intervals.icu/api/v1/athlete/YOURATHLETEID/wellness.csv?oldest=2022-09-30^&newest=2022-10-10^&cols=weight,hrv,restingHR ^
     -o APIcurl.csv

And a PUT statement

curl -X PUT https://intervals.icu/api/v1/athlete/YOURATHLETEID/wellness/2022-10-09 ^
 -H "Content-Type: application/json" ^
 -H "accept: */*" ^
 -u "API_KEY:your**strong text**APIKEY" ^
 -d "{ \"id\": \"string\", \"diastolic\": 74, \"systolic\": 115}"
2 Likes

Hi! I’m trying to add my athletes to myself (being their coach) through the api but I cannot find an endpoint to perform this action. Is this possible through the api and if so, what endpoint should I use?

kind regards!

Another question: I’m trying to access https://intervals.icu/api/v1/athletes to see all the athletes associated with my account, but I get an access denied. Is there any way to get a list of all the athletes that are being coached by me?

You can’t add athletes to yourself via the API. This needs to be authorised by the athlete.

I have updated this endpoint so it works for API_KEY calls. Previously it was only for whitelabel apps.

2 Likes

Hi, I have been trying to pull the second by second fit file data from the API into a R Script using the url: https://intervals.icu/api/v1/activity/{ID}/fit-file.
The call is running successfully, however the data coming through is in a ‘raw’ format (maybe a binary file), do you know how I could pull the fit file data through?
Thanks

Are you sure that’s not how the fit file looks? You will need a parser/decoder to make them legible.

I’ve briefly played with the package FITfileR when I was looking for gearing but didn’t have time to play for long

You could try this endpoint to get the activity streams instead of a raw fit file which you have to parse:

GET /api/v1/activity/{id}/streams{ext}?types=time,watts,distance,heartrate,altitude,epoc,velocity_smooth,left_right_balance,cadence

You can choose ext=.csv or blank to get JSON data.

If you’re using R try this GitHub - Johne3112/parseFIT This is an extract from a larger piece of code but should work. Apologies its messy and uncommented!! If you call the line at the bottom you shoud get back a list of dataframes containing everything in the FIT file. This uses the java code provided by Garmin to convert a FIT file to CSV, the R code then just parses that CSV.

The record dataframe is the one that give you second by second data for the activity.

1 Like

This is working, thank you! Is there a way of extracting the speed, longitude and latitude using this too?

Just did the classic check of looking at the network pulls and seems there is a map API that can produce lat lon

/api/v1/activity/{id}/map

Worth inspecting the network activity to see what other types you can pull, they will basically align to the charts you have. velocity_smooth should do the trick, just need to convert units (think they’re m/s)

Then filter for ‘Fetch/XHR’

1 Like