Code Header

Export your Strava Data to Excel

Strava Header Export

Many cyclists synchronise their cycling data with Strava. This enables you to monitor your performance, compare yourself to other riders and analyze the data. But sometimes you want to get your activities out of the system. This little guide shows you how to export a full year of activities via the Strava API and transform the data into a handy excel sheet.

UPDATE: I have also created a web tool, which you can use to export your Strava activities and download it as an Excel file. Click here.

Before you can start using the API, you need to create a Strava API application. Go to , create your dummy app and upload any logo you want. Afterwards the "My API Application" page should look like this:

Strava API Settings

From this site you need your Client ID and Client Secret . This key pair allows you to generate a new Access Token , which enables you to download your private data via the API. Copy the key pair and save it temporarily.

To run the script that calls the Strava API, you are going to need python (download it here). Once the language is installed, add the python packages pandas, openpyxl and stravalib (a python library for interacting with version 3 of the Strava API) like this:

$ pip install pandas stravalib==0.9.4 openpyxl

As I said, we need to generate a new Access Token, since the current one from your profile has limited access to your account and is not sufficient for downloading your activities. This must be done in two steps. First, we create a URL, which we'll use in the browser to login into Strava. The following script will create the URL (download it here):

from stravalib.client import Client

client_id = 12345
client = Client()
url = client.authorization_url(client_id=client_id,

Replace the client_id and run the script ($ python ). Copy the URL, open it in your browser and login into Strava. Then you need to analyze the redirected URL. You need to get the code parameter out of it.

Code URL

This code together with the Client Secret will create your Access Token, which you then need to export to your Strava data.

I have written a little script that downloads every event from 2018 and stores measurements like altitude, heart rate, temperature or watts in an Excel file. Just replace your app credentials (code, client_id and client_secret) in the script and run it. You can download the script here. It will take several minutes until its finished (depending on the number of your activities).

from stravalib.client import Client
import pandas as pd

client = Client()
code = ''
client_id = 12345
client_secret = ''

year = 2018
resolution = 'high'
types = ['time', 'altitude', 'heartrate', 'temp', 'distance', 'watts']

access_token = client.exchange_code_for_token(client_id=client_id,

client = Client(access_token=access_token)
df_overview = pd.DataFrame()
activities = dict()

for activity in client.get_activities(after='{}-01-01T00:00:00Z'.format(str(year)),
%t%%t%%t%%t%%t%%t%%t%%t%before='{}-01-01T00:00:00Z'.format(str(year + 1))):
%t%streams = client.get_activity_streams(,
%t%for key, value in streams.items():
%t%%t%streams[key] =

%t%df_overview = df_overview.append(pd.DataFrame([{
%t%%t%'Date': activity.start_date,
%t%%t%'Moving Time [min]': int(activity.moving_time.seconds / 60),
%t%%t%'Distance [km]': round(activity.distance.num / 1000, 1),
%t%%t%'Measurements': list(streams.keys())
%t%}], index=[]))

%t%activities[] = pd.DataFrame(streams)

writer = pd.ExcelWriter('strava_export_{}.xlsx'.format(str(year)), engine='openpyxl')
df_overview.to_excel(writer, "Overview")

for activity_id, df in activities.items():
%t%df.to_excel(writer, ' '.join([str(df_overview.loc[activity_id]['Date'].date()),

After the download is done, you should see an Excel file in your current directory. You can download an example of my activities in 2018 here.

What is next....

Since I have the raw data of my activities on hand, I can now start analyzing it. I have something in mind like training a neural network on the results of one week and compare the outcome with another week. Like that I would be able to track my fitness level over time.

Until then, feel free to share your thoughts and comments.

blog comments powered by Disqus