# Rate Limits and Security Headers

A sign-in route that answers every guess lets a script try thousands of passwords, so a rate limit counts each address's tries in a window of time and answers 429 with Retry-After, slowapi puts one on a FastAPI route, and a small middleware adds security headers to every answer.

![Cheat sheet: Rate Limits and Security Headers](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/5778da2a212841fa9b17df7b9ec3cba9.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: 429 Too Many Requests, fastapi, Rate Limiting, Security Headers, slowapi, web-development
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-security-rate-limits-and-headers-cheat-sheet
