-
-
Save scottpdawson/74f85f60a7cf7fcc8ee527592dadf498 to your computer and use it in GitHub Desktop.
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"); |
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.
Works great still.
Is it possible to export the MAX speed as well from Strava to JSON to CSV?
@Pollewops Strava doesn't include that data point in the API above, so no.
If you download your profile from Strava you will get MAX Speed
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.
This is awesome thank you! Is there any way to retrieve heart rate and pace data for each activity as well?
The JSON terminated after 300 activities, so I used https://github.com/liskin/strava-offline instead using strava-offline sqlite
.
It worked perfectly, thank you !!!
See blog post for detailed usage instructions. Steps: