Open Darkbound opened 2 years ago
I have the same issue right now too!
You could nest the ratelimited Instance.
const axiosInstance = rateLimit(rateLimit(axios.create(), { maxRequests: 10, perMilliseconds: 5000 }), {
maxRequests: 20,
perMilliseconds: 100000,
});
You could nest the ratelimited Instance.
const axiosInstance = rateLimit(rateLimit(axios.create(), { maxRequests: 10, perMilliseconds: 5000 }), { maxRequests: 20, perMilliseconds: 100000, });
Is this actually working?
I am working with several APIs on my app and a few of them have limits that are not just simply per sec. For example one of my apis has the following limits:
So I have tried implementing it the following way:
But it can't take advantage of the 20 requests per 1 second limit, because to adhere to the 100 requests per 2 minutes, I have to limit it to 1 per 1.2 seconds, otherwise if I limit it to 20 per second, I can do 2400 requests in 2 minutes.
So how can I implement both conditions and have them both working together? What if I need to do only 50 requests every 2 minutes, with the current implementation, it will take me 1 minute for all of them, and I am not taking advantage of the 20 per second (becaus if I do, I can do it in 3 seconds, instead of 1 minute).
Is there a way to accomplish this with this library? Initially I thought that the
maxRequests
works withperMilliseconds
andmaxRPS
can be used to handle the other case, so when all 3 are supplied I thought it would be like:But the docs say:
So obviously it doesnt work the way I expected it to work, is there a way to achieve what I want?