stravalib.util.limiter.DefaultRateLimiter#

class stravalib.util.limiter.DefaultRateLimiter(priority: Literal['low', 'medium', 'high'] = 'high')[source]#

Implements something similar to the default rate limit for Strava apps.

See https://developers.strava.com/docs/rate-limits/ and https://communityhub.strava.com/t5/developer-knowledge-base/our-developer-program/ta-p/8849.

Rate limits are enforced by throttling requests based on their method and client/app-specific limits imposed by Strava.

The rate limiter supports three priority levels:

  • high: No cool-down period between requests. Requests are made as fast as possible until limits are reached, then waits until the limit period expires.

  • medium: Applies a cool-down period to avoid exceeding short-term limits (e.g., 600 requests per 15 minutes, actual limits are app-specific).

  • low: Applies a cool-down period to avoid exceeding long-term limits (e.g., 30,000 requests per day, actual limits are app-specific), spreading requests evenly throughout the day.

Examples

Using default (high priority) rate limiter:

from stravalib.client import Client
client = Client(access_token=token)  # Uses high priority by default

Using a custom rate limiter with medium priority:

from stravalib.client import Client
from stravalib.util.limiter import DefaultRateLimiter

rate_limiter = DefaultRateLimiter(priority="medium")
client = Client(access_token=token, rate_limiter=rate_limiter)
__init__(priority: Literal['low', 'medium', 'high'] = 'high') None[source]#

Initializes the rate limiter based on the given priority.

Parameters:

priority (Literal["low", "medium", "high"]) – The priority given to the requests. Default is “high” (i.e. no throttling).