Get GPX from Activity

150 views
Skip to first unread message

Maxime Koster

unread,
Jun 12, 2019, 4:24:38 AM6/12/19
to Strava API
Hello,

I saw a few posts on this topic but they don't seem to give an efficient solution for me,

I wondered if there was an API call that would get the GPX from an activity just like how "http://www.strava.com/activities/{id}/export_gpx" is parsing the GPX or just a simple way to get this data without having the user login 2 times ( one for my app, one for the gpx ).
I saw that you could use the stream API but then you have to parse the GPX yourself and make two calls, one for the Activity informations and one for the streams which is not really efficient.

Since the user can export a GPX we know that everything is already there, it's weird that there is no API call to do that.

Eric McConkie

unread,
Jun 12, 2019, 9:37:44 AM6/12/19
to Strava API
you have to use the stream api - i think the minimum stream set criteria are time and latlng. In my case i pulled the data and used a gpx library to build the file. 
eg

const getActivity = (activity: any, token: string) => {
   return api.get(`/activities/${activity.id}/streams/latlng,altitude,time`,{access_token:token})
}
 
and after you have the data you can parse it into GPX. I used gpx-builder
Reply all
Reply to author
Forward
0 new messages