Strava API - Cycling Data for Visualization

Strava is awesome, Tableau is awesome...let's combine them together!

Using Tableau Public, Python, and the Strava API v3, we can quickly build heat maps, and later, specific analysis  for our activities.  I assume that you have already have a Strava account and Python 2.7+ installed, along with the python libraries "pandas", "stravalib", and "webbrowser". 

Step 1:

Setup your strava API access at https://www.strava.com/developers.  Make note of your application client secret and client ID.

Step 2:

Download the code  - the python script to run.  Put the code in a working project directory on your computer.

Step 3:

Create a file in the working directory with the code named "client.secret".  Populate the file with one line : <Strava Client ID>,<Strava Client Secret>

Step 4:

Execute the python code named "Strava_Stream_to_CSV_150406.py".  By default it will retrieve the last 100 activities from your Strava feed.  Change the value in the code by editing the "limit" variable.  Set the limit to 10, for example, to only extract the latest 10 activities.

Step 5: 

When the script completes, you will have a "Ride_<datetime>.csv" file in the same directory as your script.  This is your data!

Step 6: 

Open up tableau Public and import the CSV file as a new data source extract.  

Step 7:

Create a basic visualization - More to come on how to dive into this and the analysis, on the next post!

GitHub for the code in this blog post.

Enjoy starting your own analysis!