Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Ratelimit | 1,811 | 1 | 4 days ago | 44 | March 31, 2022 | 22 | apache-2.0 | Go | ||
Go/gRPC service designed to enable generic rate limit scenarios from different types of applications. | ||||||||||
Limiter | 1,741 | 44 | 15 days ago | 45 | March 17, 2022 | 14 | mit | Go | ||
Dead simple rate limit middleware for Go. | ||||||||||
Redis Cell | 1,078 | 24 days ago | 1 | July 31, 2018 | 11 | mit | Rust | |||
A Redis module that provides rate limiting in Redis as a single command. | ||||||||||
Flask Limiter | 953 | 345 | 32 | 3 days ago | 78 | June 07, 2022 | 1 | mit | Python | |
Rate Limiting extension for Flask | ||||||||||
Node Ratelimiter | 706 | 122 | 47 | 4 months ago | 19 | February 24, 2020 | 9 | JavaScript | ||
Abstract rate limiter for nodejs | ||||||||||
Recommendationraccoon | 690 | 26 | 2 | 3 years ago | 19 | March 06, 2017 | 19 | mit | JavaScript | |
A collaborative filtering based recommendation engine and NPM module built on top of Node.js and Redis. The engine uses the Jaccard coefficient to determine the similarity between users and k-nearest-neighbors to create recommendations. This module is useful for anyone with a database of users, a database of products/movies/items and the desire to give their users the ability to like/dislike and receive recommendations. | ||||||||||
Redis_rate | 573 | 36 | 12 days ago | 33 | October 07, 2021 | 23 | bsd-2-clause | Go | ||
Rate limiting for go-redis | ||||||||||
Ratelimitj | 433 | 2 | 3 | a year ago | 18 | May 08, 2021 | 21 | apache-2.0 | Java | |
A Java library for Rate-Limiting, providing extensible storage and application framework adaptors. | ||||||||||
Ratelimit | 424 | 96 | 27 | 2 years ago | 19 | July 19, 2021 | 3 | mit | JavaScript | |
Rate limiter middleware | ||||||||||
Rolling Rate Limiter | 287 | 42 | 15 | 2 months ago | 29 | September 13, 2022 | 3 | mit | TypeScript | |
Rate limiter for node.js that supports a rolling window, either in-memory or backed by redis |
Rate limiter middleware for koa.
# npm
$ npm install koa-ratelimit
# yarn
$ yarn add koa-ratelimit
const Koa = require('koa');
const ratelimit = require('koa-ratelimit');
const Redis = require('ioredis');
const app = new Koa();
// apply rate limit
app.use(ratelimit({
driver: 'redis',
db: new Redis(),
duration: 60000,
errorMessage: 'Sometimes You Just Have to Slow Down.',
id: (ctx) => ctx.ip,
headers: {
remaining: 'Rate-Limit-Remaining',
reset: 'Rate-Limit-Reset',
total: 'Rate-Limit-Total'
},
max: 100,
disableHeader: false,
whitelist: (ctx) => {
// some logic that returns a boolean
},
blacklist: (ctx) => {
// some logic that returns a boolean
}
}));
// response middleware
app.use(async (ctx) => {
ctx.body = 'Stuff!';
});
// run server
app.listen(
3000,
() => console.log('listening on port 3000')
);
const Koa = require('koa');
const ratelimit = require('koa-ratelimit');
const app = new Koa();
// apply rate limit
const db = new Map();
app.use(ratelimit({
driver: 'memory',
db: db,
duration: 60000,
errorMessage: 'Sometimes You Just Have to Slow Down.',
id: (ctx) => ctx.ip,
headers: {
remaining: 'Rate-Limit-Remaining',
reset: 'Rate-Limit-Reset',
total: 'Rate-Limit-Total'
},
max: 100,
disableHeader: false,
whitelist: (ctx) => {
// some logic that returns a boolean
},
blacklist: (ctx) => {
// some logic that returns a boolean
}
}));
// response middleware
app.use(async (ctx) => {
ctx.body = 'Stuff!';
});
// run server
app.listen(
3000,
() => console.log('listening on port 3000')
);
driver
memory or redis [redis]db
redis connection instance or Map instance (memory)duration
of limit in milliseconds [3600000]errorMessage
custom error messageid
id to compare requests [ip]headers
custom header namesmax
max requests within duration
[2500]disableHeader
set whether send the remaining, reset, total
headers [false]remaining
remaining number of requests ['X-RateLimit-Remaining'
]reset
reset timestamp ['X-RateLimit-Reset'
]total
total number of requests ['X-RateLimit-Limit'
]whitelist
if function returns true, middleware exits before limitingblacklist
if function returns true, 403
error is thrownthrow
call ctx.throw if trueExample 200 with header fields:
HTTP/1.1 200 OK
X-Powered-By: koa
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1384377793
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Date: Wed, 13 Nov 2013 21:22:13 GMT
Connection: keep-alive
Stuff!
Example 429 response:
HTTP/1.1 429 Too Many Requests
X-Powered-By: koa
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1384377716
Content-Type: text/plain; charset=utf-8
Content-Length: 39
Retry-After: 7
Date: Wed, 13 Nov 2013 21:21:48 GMT
Connection: keep-alive
Rate limit exceeded, retry in 8 seconds