FastAPI
- Category
- Frameworks and libraries
- Docs outline
- 18 sections
Official docs outline
fastapi.tiangolo.com- First Steps
Creating a FastAPI app, path operation decorators and functions, HTTP methods, running with uvicorn, automatic OpenAPI docs.
- Path and Query Parameters
Declaring path parameters with type hints and Enums, query parameters, defaults, optional values, and automatic type conversion and validation.
- Request Body
Declaring request bodies with Pydantic models, multiple body parameters, Body fields, nested models, and example data.
- Parameter Validation
Query and Path with string and numeric constraints, min/max length, regex patterns, Annotated metadata, and query parameter models.
- Headers, Cookies, Forms and Files
Header and cookie parameters, form data, file uploads with UploadFile, and parameter models for headers and cookies.
- Response Models and Status Codes
response_model and return type filtering, extra models, response_model_exclude_unset, status codes, and JSON compatible encoding.
- Handling Errors
HTTPException, custom exception handlers, overriding validation error handlers, and returning error responses.
- Dependencies and Dependency Injection
Depends, classes as dependencies, sub-dependencies, global dependencies, dependencies with yield for setup and teardown, and dependency overrides.
- Security and Authentication
OAuth2 password flow, bearer tokens, JWT, password hashing, get current user, OAuth2 scopes, and HTTP basic auth.
- Middleware and CORS
HTTP middleware, request/response interception, CORSMiddleware, and cross-origin configuration.
- SQL Databases
Using SQLModel or SQLAlchemy with FastAPI, session dependencies, CRUD operations, and database models versus API models.
- Bigger Applications
APIRouter, splitting an app across multiple files, router prefixes, tags, and include_router.
- Background Tasks
BackgroundTasks for post-response work, adding tasks, and using them with dependencies.
- Streaming, WebSockets and Server-Sent Events
WebSocket endpoints, streaming responses, server-sent events, and real-time bidirectional communication.
- Lifespan Events and Settings
Startup and shutdown lifespan context managers, Pydantic settings, and environment variable configuration.
- Testing
TestClient, dependency overrides in tests, async tests, and testing WebSockets and lifespan events.
- Advanced Responses and OpenAPI
Custom response classes, returning Response directly, additional responses, OpenAPI customization, callbacks, webhooks, and generated clients.
- Sub Applications, Proxies and WSGI
Mounting sub-applications, running behind a reverse proxy with root_path, and including WSGI apps like Flask.
Each section links to the official page. Titles and summaries by Extra Credit; the docs belong to their authors.