Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle API rate limits gracefully #192

Merged
merged 1 commit into from
Dec 3, 2024
Merged

Handle API rate limits gracefully #192

merged 1 commit into from
Dec 3, 2024

Conversation

matpimenta
Copy link
Collaborator

This PR adds the following to the SDK:

  1. Limits the number of requests to 400 per minute as per docs. The SDK waits for the next window to send more requests. It allows bursting, so it doesn't slow down requests under the limits; however, it will block when the limit is reached. It also considers the header X-Rate-Limit-Remaining to adjust the request count according to the server.
  2. In case the API returns 429 Too Many Request, the SDK will retry the request using exponential backoff, with a maximum delay of 1 minute (matching the 1-minute window)

@trentrosenbaum trentrosenbaum self-requested a review December 3, 2024 15:22
@matpimenta matpimenta merged commit 7dcf80f into main Dec 3, 2024
3 checks passed
@matpimenta matpimenta deleted the handle-rate-limits branch December 3, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants