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

Rate limit helpers #67

Closed
hadley opened this issue Jan 2, 2018 · 3 comments · Fixed by #174
Closed

Rate limit helpers #67

hadley opened this issue Jan 2, 2018 · 3 comments · Fixed by #174
Labels
feature a feature request or enhancement tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@hadley
Copy link
Member

hadley commented Jan 2, 2018

i.e. see how many requests you have left in the current period, and another function to automatically wait until you have another request

@gaborcsardi gaborcsardi added feature a feature request or enhancement tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day labels Jan 21, 2020
@Deleetdk
Copy link

Deleetdk commented Mar 8, 2020

Related to this, I think it would be helpful to have a simple .wait parameter to gh(), which specifies the wait period in seconds between API calls. This would allow the user to rely upon the .limit = Inf existing functionality without getting an error due to the API rate being exceeded. The point is to avoid the user to have to write their own loops using gh_next() etc.

E.g., avoid:

> moodle_commmits_12months = gh("GET /repos/:owner/:repo/commits", owner = "moodle", repo = "moodle", since = year_ago, .limit = Inf)
ℹ Running gh query, got 66600 records of about 77700Error in gh_process_response(raw) : 
GitHub API error (403): 403 Forbidden
Message: API rate limit exceeded for MY_IP. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Read more at https://developer.github.com/v3/#rate-limiting

(Note there is a lack of newline here making the error message hard to read.)

By using something like:

moodle_commmits_12months = gh("GET /repos/:owner/:repo/commits", owner = "moodle", repo = "moodle", since = year_ago, .limit = Inf, .wait = 10)

@gaborcsardi
Copy link
Member

@Deleetdk I guess #113 will address that?

@hadley
Copy link
Member Author

hadley commented Feb 6, 2023

We could also resolve this by switching to httr2, since that has a helpers (https://httr2.r-lib.org/reference/req_retry.html and https://httr2.r-lib.org/reference/req_throttle.html) built in.

hadley added a commit that referenced this issue Feb 8, 2023
hadley added a commit that referenced this issue Feb 14, 2023
And add rate limiting via new `.max_wait` argument. Fixes #67.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants