Last active
October 31, 2024 14:54
-
-
Save scottpdawson/74f85f60a7cf7fcc8ee527592dadf498 to your computer and use it in GitHub Desktop.
Bulk download Strava activities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
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?
Thanks! Not if you don't see in the JSON, no.
…On Sat, Nov 26, 2022 at 3:22 PM reedpryor ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
This is awesome thank you! Is there any way to retrieve heart rate and
pace data for each activity as well?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/74f85f60a7cf7fcc8ee527592dadf498#gistcomment-4382289>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKGCKLXMUPG6NVU4L2O56TWKJWRJBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTANJZGAZTONJUU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
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 !!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Pollewops Strava doesn't include that data point in the API above, so no.