API access to Intervals.icu

Just in case others come across this Python snippet, it can be simplified even more since requests supports basic auth credentials with the auth argument. Getting your athlete summary can be done in Python like this:

import requests

intervals_id = 'xxx'
intervals_api_key = 'xxx'

url = 'https://intervals.icu/api/v1/athlete/' + intervals_id
response = requests.get(url, auth=('API_KEY', intervals_api_key))
print(response.json())

Note also the use of .json() on the response object. Requests gives you this helper which will automatically convert the JSON response into a dictionary for you.

4 Likes