kosmo / gpx-from-strava

Creates GPX tracks for all strava activities of a user. Uses streams api v3 to reconstruct the uploaded tracks.
MIT License
15 stars 3 forks source link

You can download gpx by adding /export_gpx after your activity. #1

Open aseki opened 3 years ago

aseki commented 3 years ago

This is sample python code, sorry not ruby. You can get gpx file by logining and post this url like https://www.strava.com/activities/12345678/export_gpx. You can do the same thing by ruby.

import mechanize
br = mechanize.Browser()
response = br.open('https://strava.com/login')
br.select_form(nr=0)
br.form['email'] = 'your email'
br.form['password'] = 'password'
response = br.submit()
activity_id = '123456789'
url = 'https://www.strava.com/activities/' + activity_id + '/export_gpx'
gpx = br.open(url)
gpx = gpx.read().decode('utf-8')
with open(activity_id + '.gpx', mode='w', encoding='utf-8') as f:
    f.write(gpx)
kosmo commented 3 years ago

Thank you. This may be a legal limbo due to the Strava terms of service.

darthwalsh commented 3 years ago

+1 automating anything pretending to be the browser might work, and it might get your Strava account banned.

I was hoping this might work with the API because it follows the same pattern as /routes/{id}/export_tcx, but no dice:

➜ C:\code curl -X GET "https://www.strava.com/api/v3/activities/4513393838/export_gpx" -H "authorization: Bearer secretsecret"
{"message":"Record Not Found","errors":[{"resource":"resource","field":"path","code":"invalid"}]}