Rate Limiter

Implement token bucket, sliding window, and tiered quota rate limiting for FastAPI and Next.js.

1|Updated Sep 14, 2025
One-click install
npx skills add https://github.com/CleanExpo/DR-NRPG --skill rate-limiter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Rate Limiter
Source: https://github.com/CleanExpo/DR-NRPG/tree/main/.skills/custom/rate-limiter
Command: npx skills add https://github.com/CleanExpo/DR-NRPG --skill rate-limiter

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, fastapi, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill protects your applications from being overwhelmed by too many requests, preventing abuse, ensuring fair usage, and maintaining service stability.

Core Features & Use Cases

  • Implement various rate-limiting algorithms: Token bucket, sliding window, and tiered quotas.
  • Protect API endpoints and Next.js routes: Apply limits at the edge or within your backend.
  • Use Case: Automatically limit login attempts to 5 per minute per IP address to prevent brute-force attacks, while allowing general API usage at 60 requests per minute.

Quick Start

Apply a rate limit of 10 requests per minute to the '/api/generate' endpoint.

Frequently Asked Questions about Rate Limiter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement rate limiting in FastAPI to prevent API abuse?

Implement rate limiting in FastAPI using token bucket, sliding window, or tiered quota strategies to manage request volume and prevent API abuse. The Skill integrates with existing middleware patterns to maintain service stability.

What is the best way to limit Next.js API route traffic with Redis?

The best way to limit Next.js API route traffic is using Redis for distributed limiting alongside algorithms like sliding windows. This approach controls traffic at the edge or backend while providing standard headers and Retry-After feedback to clients.

Do I need Redis to apply rate limiting strategies across multiple application instances?

Yes, you need Redis to apply distributed rate limiting strategies across multiple application instances. Redis synchronizes request counters for token bucket and sliding window algorithms, ensuring consistent traffic control across your FastAPI or Next.js deployment.

Can I set different rate limits for login endpoints versus general API usage in FastAPI?

Yes, you can set different rate limits for specific endpoints in FastAPI using tiered quotas. For example, you can restrict login attempts to 5 per minute per IP to prevent brute-force attacks while allowing 60 general API requests per minute.

How does the token bucket algorithm handle sudden bursts of API traffic?

The token bucket algorithm handles sudden bursts of API traffic by accumulating tokens over time up to a maximum capacity. Requests consume tokens, allowing temporary traffic spikes while enforcing a strict average rate limit to protect your FastAPI and Next.js applications.

How do I return Retry-After headers when an API rate limit is exceeded?

You return Retry-After headers by configuring the rate limiter to provide clear feedback to clients when limits are exceeded. The Skill automatically includes standard headers and Retry-After mechanisms, informing clients exactly when they can safely retry their blocked requests.