Skip to content

Instantly share code, notes, and snippets.

@scottpdawson
Last active May 21, 2025 19:19
Show Gist options
  • Save scottpdawson/74f85f60a7cf7fcc8ee527592dadf498 to your computer and use it in GitHub Desktop.
Save scottpdawson/74f85f60a7cf7fcc8ee527592dadf498 to your computer and use it in GitHub Desktop.
Bulk download Strava activities
var maxPage = 25; // calculate this using (activities/20 + 1)
var activityType = "Run"; // change to the workout type you want, or blank for all
var p = 1;
var done = 0;
var url;
var nw = window.open("workouts.html");
nw.document.write("[");
while (p <= maxPage) {
url = "https://www.strava.com/athlete/training_activities" +
"?keywords=&activity_type=" + activityType + "&workout_type=&commute=&private_activities=" +
"&trainer=&gear=&new_activity_only=false" +
"&page=" + p + "&per_page=20";
jQuery.ajax({
url: url,
dataType: "json",
method: "GET",
success: function(data, textStatus, jqXHR) {
for (i in data.models) {
nw.document.write(JSON.stringify(data.models[i]) + "," + "");
}
done++;
if (done >= maxPage) {
nw.document.write("]");
nw.document.close();
}
window.open("workouts.html");
}
});
p++;
};
window.open("workouts.html");
@Pollewops
Copy link

Is it possible to export the MAX speed as well from Strava to JSON to CSV?

@scottpdawson
Copy link
Author

@Pollewops Strava doesn't include that data point in the API above, so no.

@hesbryce
Copy link

hesbryce commented Jan 7, 2022

If you download your profile from Strava you will get MAX Speed

@yoyoyvr
Copy link

yoyoyvr commented Jun 3, 2022

Nice, thanks for this! Note that if you want a start date format that plays nicely with Google Sheets (and probably Excel, I haven't checked), you can modify the inner loop like this.

            for (i in data.models) {
				start_date = new Date(data.models[i].start_date_local_raw * 1000)
				data.models[i].start_date = start_date.toISOString().slice(0, 10);
                nw.document.write(JSON.stringify(data.models[i]) + "," + "");
            }

This will replace the existing start_date field - which is formatted "Day, mm/dd/yyyy" and isn't parsed as a date by the Google Sheets importer - with "yyyy-mm-dd", which is handled fine.

@reedpryor
Copy link

This is awesome thank you! Is there any way to retrieve heart rate and pace data for each activity as well?

@scottpdawson
Copy link
Author

scottpdawson commented Nov 27, 2022 via email

@dhimmel
Copy link

dhimmel commented May 7, 2023

The JSON terminated after 300 activities, so I used https://github.com/liskin/strava-offline instead using strava-offline sqlite.

@antlev
Copy link

antlev commented Oct 26, 2023

It worked perfectly, thank you !!!

@joshuroy
Copy link

Thank you so much for this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment