Hi Strava community!
On my account, it is possible to manually export a GPX file of an activity (not a route, an activity). This GPX file can then be imported in another app (specific for biking stats for example).
Is there a way to do it programmatically? On the API documentation, I saw that there is an endpoint to extract GPX for a route but not for an activity.
I've understood how to get the list of activities I am looking for from the public API and their ids, but is there a way to get the GPX file from a specific activity?
I also haven't found parameters to filter the activity list we can get from the GET activity endpoind (to search for ride activities only for example). This is available using the desktop app.
Is there a way to do this? Thank you for your answers.
I don't think there's any direct way to get the GPX/TCX, but hopefully someone more knowledgeable can chime in.
Assuming there isn't, you can build one yourself using the activity stream data. You can use getActivityStreams to request all of the data streams for the activity, then pack that data into the file format you want. There are libraries available in most languages to write GPX/TCX/FIT files so it would just be a matter of taking the data returned from getActivityStreams and getting it into the format needed from whatever library you decide to use. It's not an ideal solution but could work if I'm correct about there being no API call to export the GPX file.
As to your second question, I don't think there's a way to filter the activities from the API call directly. Instead you would use getLoggedInAthleteActivities to get a list of activities and on your backend (or frontend) filter the results by the sport_type field.