Extract cycling workout data from Strava, analyse the performance using Strava API.
uv venv .venv
source .venv/bin/activate
uv syncuv sync --extra dev
make style # Format code with ruff
make check_code_quality # Lint code with ruffmake build
make runCheck out the Streamlit app for workout analysis & performance management.
cd app/
streamlit run app.pyAfter clicking login, you will be redirected to the Strava login page. After logging in, you will be redirected back to the app.
- Power Zones by Strava
- Power Zones by Pro Cycling Coaching
- Strava Guide: Features to Take Your Training to The Next Level
- TSS, IF, NP
- TSS by Peaksware
- CTL by Peaksware
- A blog about CTL and ATL
- More indepth CTL and ATL analysis
- A blog about CTL, ATL, and TSB in Chinese
- Strava API Developer Guide
We require authentication via OAuth 2.0 to request data about any athlete.Authentication
-
Redirect the user to the Strava authorization page with the following parameters:
client_id: Your Strava API client IDredirect_uri: The URL to redirect to after authorization. Must be within the callback domain specified by the application. localhost and 127.0.0.1 are white-listed.response_type: Set to "code"scope: The permissions you want to request (e.g., "read,activity:read")approval_prompt=force: (optional) Forces the user to approve each time
Example:
https://www.strava.com/oauth/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REDIRECT_URI&approval_prompt=force&scope=read,activity:read
-
After user approval, Strava redirects the user back to your specified
redirect_uriwith an authorization code in the URL query string:https://yourapp.com/callback?code=AUTHORIZATION_CODE&scope=accepted_scopes
-
The backend exchanges the authorization code for tokens:
- Make a POST request to the Strava token endpoint with the following parameters:
client_id: Your Strava API client IDclient_secret: Your Strava API client secretcode: The authorization code received in step 2grant_type: Set to "authorization_code"
Example:
curl -X POST https://www.strava.com/oauth/token \ -d "client_id=YOUR_CLIENT_ID" \ -d "client_secret=YOUR_CLIENT_SECRET" \ -d "code=AUTHORIZATION_CODE" \ -d "grant_type=authorization_code"
- Make a POST request to the Strava token endpoint with the following parameters:
-
Strava responds with an access token and a refresh token:
Strava's response includes JSON containing:
access_token(short-lived)refresh_token(used to obtain new access tokens)- User information (e.g., athlete ID).
Using st.set_page_config does not immediately set the title and page icon; for a fraction of a second, you will still see Streamlit's default logo and title. To avoid this, you need to patch the index.html file in the Streamlit source code.
The index.html file is located at <python-env>/lib/<python-version>/site-packages/streamlit/static.


