It took me some time to get a proper access token with the right scope (strava-cli to the rescue!), but I’m now able to update the
sports_type of a single activity.
Unfortunately the Strava API has rather strict rate limits: the default rate limit allows 100 requests every 15 minutes, with up to 1,000 requests per day.
How would you handle this rate limit?
Do I need to create a script that updates activities in batches and runs for several hours (waiting most of the time), or can I do something smarter? What?
I don’t know Strava’s API at all, but rate limits are usually set up to slow automations down so they don’t use too much in the way of resources.
My guess is you’ll need to run on a schedule, include enough pauses, etc., to stay within the rate limit.
I don’t know if this is necessarily “smarter”, but I would use a schedule rather than having a script pause and hang around in the background.
at for one off jobs, so I would parameterise or read values from a file for the main script, and use another script for or manually create the
at commands (depending upon the number of commands required).
I’m indeed in doubt between these options.
I wish they offered bulk update (so that I could update an array of activities, instead of a single activity, in a single call).
Since (I hope) I need to run this script only once, I did not want to put too much effort in it, but the reference to the
at command was super helpful!
I used this command to “schedule” my script on a Raspberry Pi, so the script would continue to run, even if I accidentally exited the shell that I used to SSH into the Pi. As a bonus, the script could easily read my Strava access token from the environment.
The script initially determines which activities are rides on MTB bikes and then updates batches of 90 rides every 20 minutes (to safely stay within the 100 requests per 15 minutes rate limit)
This worked great. All those rides are now marked as “Mountain Bike Ride”