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

API Limits? #139

Closed
pjmattingly opened this issue Jun 2, 2021 · 4 comments
Closed

API Limits? #139

pjmattingly opened this issue Jun 2, 2021 · 4 comments

Comments

@pjmattingly
Copy link

I was planning to use pyzotero for some Zotero automation, but I didn't see a mention on polite limits on queries. Are you aware of any such limits? Currently my automation does a query every ~1 minute or so, but this could increase in time.

Thank you.

@urschrei
Copy link
Owner

urschrei commented Jun 2, 2021

Pyzotero tries to do the right thing by introducing successively longer backoff periods before retrying an API call if it receives a 429 ("you are being rate-limited") response. I don't have any information about hourly / daily limits; the zotero-dev Google group is probably the best place to ask if you're concerned.

@pjmattingly
Copy link
Author

Fair enough.

Can these responses be piped to the caller? That way I could include some handling as well. More specifically, I might have some other calls to the Zotero occurring that I could limit if I knew they had requested or required some limiting.

@urschrei
Copy link
Owner

urschrei commented Jun 2, 2021

Sorry, I just checked and it's slightly more complex: any response (successful or otherwise) can return a backoff header, which the client handles by sleeping for the requested number of seconds before making subsequent calls. If the client receives a 429 response with a backoff header, it'll sleep and then retry that call until it succeeds or it receives a 429 response without a backoff header, which will raise a TooManyRetries error which you can catch and handle as you see fit.

Essentially, the client implements the behaviour that the API v3 docs ask for, and you can't easily make it behave more conservatively than that -- in practice, that shouldn't be a problem, but the Zotero team is helpful and responsive on the group if you're concerned about rate-limiting.

There are retrieval approaches that take advantage of the sync functionality provided by the API, and you may be able to exploit those to reduce calls or bandwidth, depending on your use case, but again, that's probably better discussed on the group.

@pjmattingly
Copy link
Author

pjmattingly commented Jun 3, 2021 via email

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