Skip to content
Advertisement

How to rate limit a NestJS API by multiple time intervals?

I am trying to rate limit my API with @NestJs/throttler. I want to set two different limit caps:

  • 100 requests per 1 second
  • 10,000 requests per 24 hours.

Setting either one of these rate limits is explained in the docs and is pretty straight forwad. But, setting both limitations is not articulated in the docs.

How can I rate limit my API by both time intervals?

Advertisement

Answer

As I told you on Discord, with @nestjs/throttler, this functionality currently doesn’t exist. You can have one or the other, or you can override the global config to be more specific for one endpoint, but there’s not currently a way to have two limits set up.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement