crflynn / pypistats.org

PyPI downloads analytics dashboard
https://pypistats.org/
140 stars 10 forks source link

Getting "429 Client Error: TOO MANY REQUESTS" on <20 requests #28

Closed jwodder closed 4 years ago

jwodder commented 4 years ago

I have a small script that queries the pypistats.org API to see how much my packages have been downloaded lately. It makes one request to /api/packages/:project/recent per project, and I only have eighteen projects. I usually only run it once every couple of weeks. However, the past few weeks, running it fails with a "429 TOO MANY REQUESTS" error somewhere in the middle of the project list. My best guess at an explanation is that some form of API rate-limiting was implemented after #20, but the limit seems set too low. What can I do to get my script working again?

hugovk commented 4 years ago

The rate limit is 5 per second, and 30 per minute.

https://github.com/crflynn/pypistats.org/pull/27/files#diff-f43b9ad708915ad0355ef66cbe7e7865R27

Put some delays in between calls to stay within the limit and you'll be fine.

jwodder commented 4 years ago

Seems a little low, but OK. Limit worked-around.