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

Sys.sleep() in between API requests? #33

Open
tts opened this issue Sep 21, 2021 · 1 comment
Open

Sys.sleep() in between API requests? #33

tts opened this issue Sep 21, 2021 · 1 comment

Comments

@tts
Copy link

tts commented Sep 21, 2021

Let's assume that the API provider wants me to send requests one by one, ie. not sending a new request before the previous one is taken care of. I wonder if a Sys.sleep() anywhere inside the oadoi_fetch_ function would do the trick? Or, would it need to be (if possible) in the "scope" of the plyr::llply function?

The reason why I'm asking is that I'm learning proper ways to deal with APIs, and your roadoi code acts as an excellent, well-built tutorial. In other words, my question does not refer to the Unpaywall API as such.

Thanks for any pointers!

@njahn82
Copy link
Member

njahn82 commented Sep 24, 2021

Hi @tts Just recently, there has been an update of httr, httr2, which has a great tutorial how to wrap APIs. The tutorial shows how to deal with rate limits:
https://httr2.r-lib.org/articles/wrapping-apis.html#rate-limits

I think, I would use this approach to make sure that requests are sent in accordance with the server policy.

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

No branches or pull requests

2 participants