Rate Limiter API
A simple library to easily manage rate limits of APIs without any hassles.
Table of Contents
Usage ⮭
Browser ⮭
NodeJS ⮭
$ {sudo -H} npm install -S rate-limiter-api
Public Interface ⮭
rateLimiter = RateLimiterAPI({threshold: 5})
rateLimiter.limit(requestHandler) => Promise
rateLimiter.updateRateLimits
on success to update ratesrequestHandler(responseHandler)
on success to continue
const rateLimiter =
Pass an optional threshold
value which would limit the total rate limits till the threshold is reached in the current session pulse till rate reset.
const request = rateLimiter //=> Promise { }
The limit
method is passed a requestHandler
which would manage the request and then call the node-style responseHandler
callback (which gets passed by the RateLimiter library to the requestHandler
function) after the request is successful or unsuccessful accordingly.
The request
method returns a Promise
.
responseHandler(Error, response)
where the first parameter is the Error object and the seconds parameter is theresponse
.
responseHandler
callback must be called to continue getting responses.
Update the rate limits i.e. {rateLimit, rateRemaining, rateReset}
got from the header using updateRateLimits
method.
request
When the request completes, the Promise
resolves and can be thenable to get the response or error.
Stats ⮭
1 text file.
1 unique file.
0 files ignored.
https://github.com/AlDanial/cloc v 1.66 T=0.04 s (22.7 files/s, 2516.9 lines/s)
Language | files | blank | comment | code |
---|---|---|---|---|
JavaScript | 1 | 12 | 37 | 62 |
Technologies Used ⮭
- Babel — Transpiles modern JS to compatible and runnable JS
- Stamp It - Composable inheritance object creation libray
- Async JS - Utility for asynchronous functions
- Lodash - Utility library
Help & Support ⮭
- BabelJS — BabelJS Slack Chat Room
- nodejs/node — NodeJS Gitter Chat Room
- Fun with Stamps - Learn StampIt
Contributors ⮭
Abhisek Pattnaik 💻 🎨 📖 💡 |
---|
This project follows the all-contributors specification.
All types of Contributions are Welcome 🙏
License ⮭
Tweet @abhisek
Know about/abhisekp
Chat with
@abhisekp