Skip to content

Create GPX files from datastreams downloaded using the Strava API

Notifications You must be signed in to change notification settings

PhysicsDan/GPXfromStravaAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GPXfromStravaAPI

Create GPX files from datastreams downloaded using the Strava API

DISCLAIMER: I am a hobbiest so this may not be the 'best' way to do the following but it has worked well for me.

The StravaAPI doesn't allow for direct downloading of GPX files. Therefore individual latitude, longitude and elevation values are downloaded and then converted into a gpx file using the gpxpy.gpx module.

Note: The GPX files produced could be used in this code by Remi Salmon which generates a heatmap of the activities (and looks class!).

Currently the limitations are the GPX file will only contain latitude, longitude, time and elevation, not heartrate although that is easy enough to add but was not required by me.

Setting up the API

There is a handy guide here that shows you how to set up an Strava so you can make API requests.

The main information and actions you require are:

  • In the keys directory, please delete the file strava_tokens.json if it exists as this will be generated on the initial successful run with the relevant information returned from Strava
  • User Code (numeric, Shown in the API section of Strava settings as Client ID)
  • Secret Code (GUID, Shown in the API section of Strava settings as Client Secret)
  • Authentication Token (GUID, see the linked guide on how to obtain this from the returned URL)

You will need to add this info to the client_info.json file in the keys folder. After that when you run the code for the first time it should generate the relavent tokens etc that are required.

If the inital requests fails, you need to commence this process from the start.

Requirements: see requirements.txt

Usage:

python main.py

You can also use:

python main.py --dir /path/to/directory

if the python file and folders etc are in a different directory

You can also specify the location of where you want to store your data and api keys relative to the working directory

python main.py --keys path/to/api/keys --data path/to/data/folder

Limitations: There is a limit to the number of API requests a user can make (per 15 mins and per day). This code is set up in such a way that it should stop once that limit has been reached to avoid pointless requests. However, this does mean in can take several days to fully download a users GPX files for the first time.

If you have any issues feel free to open a discussion and I can try and help :)

About

Create GPX files from datastreams downloaded using the Strava API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages