How to Export Strava Workout Data

If you’re a numbers geek AND a fitness geek like me, you’ve wanted to export Strava data. You’ve realized with dismay that Strava doesn’t have any kind of export function for the hard-earned workouts you’ve uploaded. Normally the lack of a feature like this wouldn’t cramp my style, but I really wanted to summarize my preparation for Cayuga Trails 50.

Training infographic (click for full details)

Going through workout-by-workout just wouldn’t cut it. I needed a spreadsheet I could sort, filter and enrich. The resulting poster was just as I’d hoped for! It turns out I’m also a technology geek, so I figured out how to export Strava data into a spreadsheet so I could get the numbers I needed for my poster. There are a few steps involved, but it’s not THAT hard. Grab a cold one and get your browser console ready, ’cause we’re going to go on a Strava data expedition!

Note: An astute reader pointed out that Strava already had an export feature. True! Go to profile settings and you’ll see “Download your data” in the right column. However, that downloads only a zip file of your owrkouts in GPX format. It doesn’t supply a single spreadsheet view with oodles of data, which is what I was after. True, Strava provides a developer API, but that’s a bit heavy-handed for a single query. All API-based plugins or add-ons that I tried while researching this post did not work for my use case; they either didn’t work at all, didn’t have all the columns I needed, or only exported a certain number of workouts.

Step 1: The Browser Console

Open up your browser console. I’m going to show you this in Chrome, which is how I’d do this, but if you use Firefox or (shudder) Internet Explorer, you can do this there, too. Right-click anywhere on the web page and click Inspect.

This will load the inspector at the bottom of your browser, looking something like this:

Frightened yet? Don’t be.

In the inspector, there are navigation options along the top. Click Network. Below that, you can filter network traffic by type. We’re looking for XHR, so click that. Now, any data request the browser makes back to the server will be summarized here. Who knew browsers could show you such cool stuff?

Step 2: Go to Strava’s My Activities Page

Go to Training > My Activities. You get a nice tabular view of your workouts, right? Unfortunately Strava will only let you see 20 activities at a time, but you can filter by sport type and search by keyword. If you want to use these filters before you export your data, so you get a subset of your workouts, now is the time to use them.

Your inspector should now look like this:

Step 3: Export Strava Data

Web pages can make a lot of requests in the background for data. In this case, we’re looking for one called training_activities. In the upper left corner, under that red dot, you can search for “training” and see just those requests, which is what we’re looking for.

Click the first request in the list. This is the request/response for the first 20 workouts in your list. On the right side, you can see a preview of the response for the data.

Above that data on the right side, click on “Response” to see the raw data.

Click anywhere in that raw data (that pretty red and blue text), hit Ctrl-A to select all of it, and then Ctrl-C to copy it to your clipboard. The data’s in what’s called JSON format, and we need to get it into another format so we can import it into the spreadsheet of our choice. Open a new tab (don’t leave the Strava tab, ’cause we have more work to do!) A quick Google search for “convert JSON to CSV” gives me a result of from convertcsv.com, which is exactly what I need. Paste the JSON text you copied into the text box on their page and click “Convert JSON to CSV”. From there, you can download the result, or if you’re a Microsoft person, you can also click JSON to Excel.

Now we can go back to our Strava tab, scroll to the bottom of the 20 workouts shown in the actual web page, and click the Next button to view the next set.

When you do this, you’ll see another XHR request in the inspector. This time, it’s requesting workouts 21-40, whereas the first time, it was workouts 1-20. It’d be easier if Strava let you change the results per page to something other than 20, but it doesn’t. Believe me: I checked. Now you’ll see another response below the first one.

Repeat the steps to copy the result and convert it from JSON to CSV or Excel. Keep on going, and your Network panel will look something like this, chock full of good data:

Once you’re finished, if you’ve gone the Excel route, it’s a matter of copy/pasting from each spreadsheet into a master spreadsheet. If you’ve done CSV, you can do the same in your text editor, grouping all the CSV files into one, or import each into your spreadsheet of choice and manipulating the data from there. If you’re a Windows user and feeling particularly brave, you can also follow Tom Nash’s instructions on combining CSV files automatically.

Conclusion

I can only hope that Murphy’s Law applies here, and after thoughtfully writing this post, Strava releases an update that’ll let you export Strava data natively. Until then, happy data mining, and happy running/cycling!

 

 

 

4 responses

  1. Your awesome work and effort in doing this and writing it so that a nube like me is able to follow your steps is greatly appreciated. Now I can statistic the sh*t out of all my workouts.

  2. Great idea! Expanding on it, here is an alternative solution for those too lazy to repeat the steps for every 20 activities.

    I noticed that in the second page, the training_activities URL finished by &page=2&per_page=20. Which made me think this could be scriptable (but only in the browser and session context). Googling a few ideas on how to do that made me learn that you can right click an XHR call in the browser inspector, then Copy / Copy as cURL. You can then paste the result in a bash window to download the JSON. So I created a quick shell script that looks like this:

    #!/bin/bash
    for pagenumber in {1..36}
    do
    [extra long curl command from above step, replacing page=2 by page=${pagenumber}] > res_$number.json
    done
    exit 0

    In that case, I wanted 36 pages since I have 719 activities in Strava.

    This yields 36 files containing 20 activities each. Then joining them together should be easy in your favorite scripting language…

Leave a Reply

Your email address will not be published. Required fields are marked *