API Key doesn't work with Python

Hello,

I am trying to access my own Intervals.icu data through the public API.

I generated a new API key in Settings → Developer Settings.

I am using:

Both Python requests and curl return HTTP 401 Unauthorized.

I have regenerated the API key and checked the authentication format.

Could you help me identify why my API key is being rejected?

Thank you.

The issue is the username. You have it backwards.

The username must be the literal string API_KEY, and the password is your personal key. You wrote “Username: API_KEY” and “Password: my personal API key”, which sounds right, but the 401 suggests the actual request isn’t using that format.

In Python requests, you need Basic Auth, not Bearer:

python

import requests

API_KEY = "your_personal_key_here"
ATHLETE_ID = "0"

url = f"https://intervals.icu/api/v1/athlete/{ATHLETE_ID}"
response = requests.get(url, auth=("API_KEY", API_KEY))

The key detail: auth=("API_KEY", API_KEY) means the username is literally the string "API_KEY" (not your athlete ID, not a variable), and the password is your actual key from Settings .

If you’re still getting 401 after that, double-check you haven’t accidentally set a Bearer header somewhere else in your code, since that will override Basic Auth .

Please Show an example, you can black out part of the API key.
Usually it has nothing to do with the script language