fastapi-rate-limiting-integration

Integrates slowapi rate limiting into FastAPI endpoints with correct decorator signatures and whitelist logic.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/ZaxbyHub/ragappv3 --skill fastapi-rate-limiting-integration-zaxbyhub
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fastapi-rate-limiting-integration
Source: https://github.com/ZaxbyHub/ragappv3/tree/main/.opencode/skills/generated/fastapi-rate-limiting-integration
Command: npx skills add https://github.com/ZaxbyHub/ragappv3 --skill fastapi-rate-limiting-integration-zaxbyhub

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires slowapi.

What problem does it solve? Rate limiting in FastAPI with slowapi often fails silently when the request: Request parameter is missing from endpoint signatures, leaving APIs unprotected without any obvious error. This Skill provides the correct patterns, common pitfalls, and review checklists to ensure rate limits are actually enforced. ## Core Features & Use Cases - Correct Decorator Signatures: Enforces the mandatory request: Request parameter on all rate-limited endpoints so slowapi can extract the request for key generation. - Custom Whitelist Limiter: Shows how to subclass slowapi.Limiter and override _check_request_limit to bypass limits for trusted API keys using hmac.compare_digest. - Error Diagnosis Table: Maps common symptoms (limits not enforced, missing imports, broken whitelist bypass) to their root causes and fixes. - Use Case: When adding @limiter.limit() to a chat endpoint, apply this Skill to verify the signature includes request: Request, the import is present, and rate limiting is tested with both authenticated and unauthenticated requests. ## Quick Start Review my FastAPI endpoint that uses slowapi rate limiting and verify the decorator signature and whitelist logic are correct.

Frequently Asked Questions about fastapi-rate-limiting-integration

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

FAQPage Schema
How do I add rate limiting to FastAPI endpoints with slowapi?▼

Apply the @limiter.limit() decorator to your endpoint and include request: Request in the function signature so slowapi can extract the request for rate limit key generation. The parameter can appear at any position in the signature.

How to bypass slowapi rate limits for whitelisted API keys?▼

Subclass slowapi.Limiter and override _check_request_limit to return early when a trusted API key is present in the request headers. Always compare keys with hmac.compare_digest instead of == to prevent timing attacks.

Why is my slowapi rate limit not being enforced?▼

The most common cause is a missing request: Request parameter in the endpoint signature, which fails silently. Add the parameter, verify the starlette Request import is present, and test with both authenticated and unauthenticated requests.

Does the request parameter need to be first in a rate-limited FastAPI endpoint?▼

No, request: Request can appear at any position in the endpoint signature. The only requirement is that it is present so slowapi can extract the request object for rate limit key generation.

Why use hmac.compare_digest instead of == for API key comparison?▼

Plain == comparison leaks timing information that attackers can use to guess API keys character by character. hmac.compare_digest performs constant-time comparison, preventing timing attacks on whitelist key checks.