alan-turing-institute / whatwhat

A reimagining of nowwhat in OCaml
MIT License
0 stars 0 forks source link

Check GitHub rate limiting #80

Closed yongrenjie closed 1 year ago

yongrenjie commented 1 year ago

GitHub allows 5000 requests per hour to the REST API, but it's actually possible to exceed that depending on how many issues (and reactions) we're fetching at once, and how hard we're working on it. (The GraphQL API is also rate-limited, but that's less of an issue as it's only used to obtain the users.)

Should check response headers to see whether we are being rate limited - https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting

Headers can be gotten with

let* r, b = Client.get ~headers uri in
let headers = Cohttp.Response.headers r in

API is here https://mirage.github.io/ocaml-cohttp/cohttp/Cohttp/Header/index.html