API access to Intervals.icu

Nice one! I tried all morning to connect but to no avail until I stumbled on this post:)

1 Like

Hi, I’m begginer in this things but I’m trying get data from my specific workout and I’m getting this error:
{“status”:500,“error”:“org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type ‘java.lang.String’ to required type ‘int’; nested exception is java.lang.NumberFormatException: For input string: "13632114836"”}%

This is what I type in terminal:
curl -X GET “https://intervals.icu/api/v1/athlete/i235611/workouts/13632114836
-H ‘accept: /’ -u “API_KEY:xxxxx”

Do you have some ideas?

I beleive you’re usigthe wrong endpoint

https://intervals.icu/api/v1/docs/swagger-ui/index.html

/api/v1/activity/{id} <<< should be this one i believe

or are you trying to get the FIT file?
also take a look here

1 Like

Hello, I’m new to using APIs to access data and would like to be able to automate bringing the Gear table into Google Sheets. I tried =IMPORTDATA(“https://intervals.icu/api/athlete//gear.csv”,“,”) but that didn’t work. I know I will need to pass the API key, but I don’t know if there is a way to do it in the URL. I’m open to other ways of doing it. Can anyone help?

Thanks!

IMPORTDATA will not work that simple way you think.

You need an google AppsScript doing the job for you. Downloading the CSV, parsing to tabular format, pushing finally to the table,… as far as I can remember @William_Barnes shared an link with an example you can adjust.

Are the weekly load / duration / distance targets per sport exposed through API at all?

I think so, I am pretty sure as I am getting it. See Note 2 in thread below

tho i forgot where I found it

Yes they are through the list calendar events endpoint: GET /api/v1/athlete/{id}/events

You can specify category=TARGET to get only the targets.

Is this api function still valid? I trying to write a script to update my FTP in intervals with my TP from Xert, but I’m getting a 403 error back. I’ve double checked by atheleid and api key and both are correct.

Error 403 means access denied. Do you have the user API_KEY and as password you actual api key? Do you use basic auth not bearer?

2 Likes

I just did this with my API key and it worked:

curl -XPUT -u API_KEY:xxx 'https://intervals.icu/api/v1/athlete/0/sport-settings/Ride' \
    -d '{ "ftp": 300 }' -H "Content-Type: application/json"

You can usually use 0 instead of the athlete ID like I did here.

Hi,
I would like to ask to add an REST API endpoint to find activities in selected bounding box?
Smth like: /athlete/{id}/activities?bounds=-54,10.11,-50.95,11.10 and it will return activites (just id will be enough actually) within this box.

Unfortunately I can’t do that at the moment. I neglected to store the start or end point on activity and the GPS data is in offline storage and not searchable. I am going to add the start and end point to the activity but it will take a very long time to get that updated from the GPS data.

Is it possible to add pagination for GET /api/v1/athlete/{id}/activities with page size and offset? Current limit works, but doesn’t give any information how much more data you have.

I left that out because it is much more efficient to query that data using the oldest and newest parameters. So rather page by month or 3 months.

I figured out that I can do this for activities with routes. Will try get it done soon.

1 Like

I am trying to send feedback comments to an Intervals.icu activity but they are not reaching the platform. I share my implementation and would appreciate any hints.

  1. Endpoint and authentication
    Method: POST
    URL:
    https://intervals.icu/api/v1/activity/{activity_id}/messages
    Headers:
    http
    Authorisation: Basic <base64(‘API_KEY:{tu_api_key}’)>
    Content type: application/json
    Payload (JSON):

{ ‘message’: ‘Your feedback comment here’ }
2) Python integration class

import base64
import requests

IntervalsAPI class:
def init(self, athlete_id, api_key):
self.base_url = ‘https://intervals.icu
auth_str = f ‘API_KEY:{api_key}’
self.headers = {
‘Authorization": f “Basic {base64.b64encode(auth_str.encode()).decode()}”,
‘Content-Type": ’application/json’
}

def post_activity_comment(self, activity_id, comment):
    url = f"{self.base_url}/api/v1/activity/{activity_id}/messages’
    payload = {‘message’: comment}
    resp = requests.post(url, headers=self.headers, json=payload)
    print(resp.status_code, resp.text) # To debug
    resp.raise_for_status()
    return resp.json()
  1. Call from Streamlit

if st.button(‘Post feedback’):
response = intervals_api.post_activity_feedback(
activity_details[‘id’],
st.session_state.athlete_feedback
)
if isinstance(response, dict) and ‘error’ in response:
st.error(f ‘Error posting: {response[’error‘]}’)
else:
st.success("Comment posted successfully.

You need to use ‘content’ in the payload and not ‘message’. Here is a example with curl:

curl -XPOST -u API_KEY:xxx 'https://intervals.icu/api/v1/activity/i75453212/messages' \
    -d '{ "content": "Hello!" }' -H "Content-Type: application/json"
1 Like

Thx David

(post deleted by author)

Hi David,

I’m using the Intervals.icu API and can successfully pull activities data using Basic Auth with “API_KEY” as the username and my API key as the password.

However, when I try to access either the /daily endpoint or any wellness data endpoints, I consistently receive a 403 Forbidden error:

{“status”:403,“error”:“Access denied”}

I have wellness data visible in my account (HRV, sleep, weight, etc.) and I’ve already tried:

Deleting and regenerating my API key.

Verifying my API key works for the activities endpoint.

Using the correct Basic Auth format (auth = (“API_KEY”, api_key)).

Could you please confirm whether wellness data API access is enabled for my account or if any further permission changes are needed?

Many thanks!