Skip to content

Instantly share code, notes, and snippets.

@scottpdawson
Last active May 21, 2025 19:19
Show Gist options
  • Select an option

  • Save scottpdawson/74f85f60a7cf7fcc8ee527592dadf498 to your computer and use it in GitHub Desktop.

Select an option

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");
@scottpdawson

Copy link
Copy Markdown
Author

See blog post for detailed usage instructions. Steps:

  1. Go to https://www.strava.com/athlete/training after signing in.
  2. Open Chrome’s developer tools and navigate to console window.
  3. Set maxPage and activityType above.
  4. Paste code into console.
  5. Copy new window's content into https://konklone.io/json to convert to CSV.

@sfirke

sfirke commented Jun 29, 2021

Copy link
Copy Markdown

Thanks for this! For others: in Firefox I got the error:

Uncaught TypeError: nw is null
debugger eval code:7

But it worked fine in Chrome.

@hesbryce

Copy link
Copy Markdown

Works great still.

@Pollewops

Copy link
Copy Markdown

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

@scottpdawson

Copy link
Copy Markdown
Author

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

@hesbryce

hesbryce commented Jan 7, 2022

Copy link
Copy Markdown

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

@yoyoyvr

yoyoyvr commented Jun 3, 2022

Copy link
Copy Markdown

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
Copy Markdown

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

@scottpdawson

scottpdawson commented Nov 27, 2022 via email

Copy link
Copy Markdown
Author

@dhimmel

dhimmel commented May 7, 2023

Copy link
Copy Markdown

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

@antlev

antlev commented Oct 26, 2023

Copy link
Copy Markdown

It worked perfectly, thank you !!!

@joshuroy

Copy link
Copy Markdown

Thank you so much for this!!

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