This short tutorial describes how to upload GPS tracks to Strava using your command line interface / shell. It requires no special tools or any 3rd party code.
Strava uses OAuth2 to authenticate against 3rd party applications. In order to authenticate to your Strava account from your command line, you first have to generate an API key. To create a new API, go to https://www.strava.com/settings/api. The settings are as follows:
Application Namechoose whatever name you like
Websitechoose whatever website you want to use (needs to be a valid url]
Callback Domainany domain name that should be used as a callback
After you saved your API, you need to upload a image for it.
Then, copy the following values to use for HTTP requests.
Client ID- an ID for your application, used later on to identify your App
Secret- a secret token generated for you (not your OAuth Token!)
Strava has defined seven different types of permissions to access the API:
Please refer to the official documentation for what each scope represent.
- Open the following URL (replace CLIENT_ID with the ID from above):
- Login to Strava then click
Authorizeand tick the required permissions if needed.
- Browser should go to 404 as
- Copy the authorization code from URL that is given as the URL
- Run the following CURL request, to get the final OAuth token (replace
- Copy the
access_tokenfrom the JSON response - this is your OAuth token
Returns the currently authenticated athlete. Tokens with
profile:read_all scope will receive a detailed athlete representation; all others will receive a summary representation.
Use the following command to upload a track to Strava:
The other data_types can be
To check the status of your update, use the
id from the JSON response and run
If you want to upload a directory with files, use the following command