needmorecowbell / giggity

Wraps github api for openly available information about an organization, user, or repo
Apache License 2.0
126 stars 19 forks source link

ratelimit errors aren't handled appropriately #8

Open needmorecowbell opened 5 years ago

needmorecowbell commented 5 years ago

Github limits you to 5000 requests per hour when authenticated and 60 when unauthenticated. Giggity should be able to check for the different error messages and handle them appropriately. This is now an important issue because of how many queries are being made.

For example:

Abuse and limited responses will look like this, and should be handled by telling the script to ping every 15 minutes to see if it can start scraping again.

HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=utf-8
Connection: close
{
  "message": "You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.",
  "documentation_url": "https://developer.github.com/v3/#abuse-rate-limits"
}

HTTP/1.1 403 Forbidden
Date: Tue, 20 Aug 2013 14:50:41 GMT
Status: 403 Forbidden
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1377013266
{
   "message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
   "documentation_url": "https://developer.github.com/v3/#rate-limiting"
}