from stravalib.util.limiter import RateLimitRule, RateLimiter
class DefaultRateLimiter(RateLimiter):
"""
Implements something similar to the default rate limit for Strava apps.
To do this correctly we would actually need to change our logic to reset
the limit at midnight, etc. Will make this more complex in the future.
Strava API usage is limited on a per-application basis using a short term,
15 minute, limit and a long term, daily, limit. The default rate limit allows
600 requests every 15 minutes, with up to 30,000 requests per day.
"""
def __init__(self):
super(DefaultRateLimiter, self).__init__()
self.rules.append(RateLimitRule(requests=40, seconds=60, raise_exc=False))
self.rules.append(RateLimitRule(requests=30000, seconds=(3600 * 24), raise_exc=True))