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

Pause execution if request limit reached #123

Merged

Conversation

judith-bourque
Copy link
Member

@judith-bourque judith-bourque commented Jun 14, 2023

Check in the response if the request limit was reached and pause for the amount of time provided in the response.

This will help respect the API policy:

"The returned HTTP header X-Rl contains the number of requests remaining in the current rate limit window. X-Ttl contains the seconds until the limit is reset.

Your implementation should always check the value of the X-Rl header, and if its is 0 you must not send any more requests for the duration of X-Ttl in seconds." (source)

Closes #122

@judith-bourque judith-bourque added the bug Something isn't working label Jun 14, 2023
@judith-bourque judith-bourque linked an issue Jun 14, 2023 that may be closed by this pull request
1 task
@judith-bourque
Copy link
Member Author

Before last commit, it still threw a too many requests error

@judith-bourque
Copy link
Member Author

Sometimes it works for 50 requests, other times it throws a too many requests error message. Could there be a limit per hour for free usage?

The documentation only mentions a limit per minute for free non-commercial usage.

@judith-bourque judith-bourque added enhancement New feature or request and removed bug Something isn't working labels Jun 16, 2023
@judith-bourque
Copy link
Member Author

The throttle works as intended.

I suspect that the 429 errors were because I was using a shared IP adress with other researchers. Multiple calls could have been made without my knowledge.

@judith-bourque judith-bourque merged commit c3fb4de into main Jun 16, 2023
@judith-bourque judith-bourque deleted the 122-check-value-of-x-ri-header-before-sending-next-request branch June 16, 2023 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check value of X-RI header before sending next request
1 participant