Not all APIs have rate limits
See original GitHub issueWhen working with the integrations API, I noticed that not all APIs have rate limits, which causes gidgethub to fail hard:
Traceback (most recent call last):
File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 459, in callback
self._startRunCallbacks(result)
File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 567, in _startRunCallbacks
self._runCallbacks()
File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 1357, in gotResult
_inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 1301, in _inlineCallbacks
result = g.send(result)
File "t.py", line 46, in inner
async for installation in gh.getiter("/integration/installations"):
File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/abc.py", line 64, in getiter
authorization)
File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/abc.py", line 48, in _make_request
data, self.rate_limit, more = sansio.decipher_response(*response)
File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/sansio.py", line 267, in decipher_response
return data, RateLimit.from_http(headers), _next_link(headers.get("link"))
File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/sansio.py", line 211, in from_http
limit = int(headers["x-ratelimit-limit"])
builtins.KeyError: 'x-ratelimit-limit'
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Understanding rate limits for APIs and Plans - IBM
This rate limit applies to all calls involving the API, from all consumer orgs. If the containing Plan allows the call but the...
Read more >What is API Rate Limiting and How to Implement It - DataDome
API rate limiting is used to ensure your API can provide optimal service for its users, while also ensuring their safety.
Read more >Everything You Need To Know About API Rate Limiting
This rate-limiting library automatically limits the number of requests that can be sent to an API. It also sets up the request queue ......
Read more >API Management 101: Rate Limiting - Tyk.io
API -level rate limiting assesses all traffic coming into an API from all sources and ensures that the overall rate limit is not...
Read more >How to handle API rate limits: Do your integrations work at ...
The different APIs with which a unified API makes connections all carry different rate limits and have standards in place to deal with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
[ @eliot1019 edited your message ⬆️ to come off as more 😃 and less 😠 ]
Probably if you update
https://github.com/brettcannon/gidgethub/blob/4d5819cf50f3ad896713364d5e749bea466b9f05/gidgethub/sansio.py#L233-L234
to catch the
KeyError
and returnNone
instead that should do it (plus tests and docs, of course). If anyone wants to provide a PR I will happily review it.