API access to Intervals.icu

Hmm not sure what to do about these. Activity.icu_sync_date is a java.util.Date which has millisecond precision. Activity.pace_load_type is a reference to an enum and allows nulls.

Hello David,

how to get Bearer token for other users from their username and password input with API calls?

Or is it possible to generate API key for user from their username and password input? I can get userID from API call but can not get to api key or bearer token.

For OAuth, you would need to contact david directly and he will get you set-up. (You can also search the forum for the oAuth thread)

Hi david,

You know if its possible to send via push the weight data to garmin, when we put the weight via manual or from the icu API. For the moment not appear on garmin.

Many Thanks!

As far as I know you can’t push anything to Garmin Connect other then workouts.

2 Likes

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