Core Concepts
The handful of ideas — path operations, type-hint-driven schemas, dependency injection, automatic docs — that everything else in FastAPI is built from.
Third-party documentation. This is independently authored analysis of the public FastAPI codebase — not the official docs, and not reviewed or endorsed by the FastAPI team.
Core Concepts
Path operations
A "path operation" is a function decorated with an HTTP-method decorator (@app.get, @app.post, etc.) bound to a path. The decorator registers the function with the router; it does not wrap or replace the function itself.
Type hints are the schema
A parameter typed as a Pydantic model becomes the expected request body. Primitive-typed parameters (str, int, bool, ...) that also appear in the path become path parameters; the same primitives that don't appear in the path become query parameters. There is no separate schema definition — the function signature is read directly.
Dependency injection (Depends)
Any callable — function, class, or generator — can be declared as a dependency with Depends(callable). Dependencies can themselves declare dependencies, forming a directed acyclic graph that FastAPI resolves before the endpoint runs. Generator dependencies (yield) provide setup/teardown semantics, most commonly used for database sessions.
Automatic interactive docs
Because every route's parameters, bodies, and response models are already structured Pydantic/typing metadata, FastAPI generates a complete OpenAPI schema with no additional annotation, and serves interactive Swagger UI (/docs) and ReDoc (/redoc) documentation from that schema automatically.
