FastAPI is a free, open-source Python framework for building HTTP APIs from ordinary type hints. Sebastián Ramírez released it in 2018 on top of two existing libraries — Starlette for the ASGI web layer and Pydantic for data validation — and the central idea is that the function signature is the contract: annotate a parameter and FastAPI validates the incoming request, serialises the response, documents the endpoint and reports the error, all from the same declaration. It speaks OpenAPI and JSON Schema natively, so every application is born with interactive documentation at /docs and a machine-readable specification at /openapi.json. FastAPI 0.162 is the current release series, it needs Python 3.10 or newer, and the code is MIT licensed.
/docs and a ReDoc reference at /redoc with no extra annotations.Depends() composes shared logic (database sessions, current user, pagination, permission checks) declaratively, and the same dependencies are reused by the docs and by the tests.async def handlers run on the ASGI event loop while ordinary def handlers are offloaded to a thread pool, so blocking libraries do not stall the server.response_model filters and validates what leaves the API, so a field added to an internal object does not leak into a public payload.fastapi dev runs the app with reload, and fastapi run serves it for deployment, without a separate server command.The framework’s argument is that correctness and documentation should come from the code rather than from a parallel spec that drifts. Because the schema is derived from the annotations, a validation error, the generated docs and the editor’s autocompletion all describe the same contract; changing a field updates all three at once. That makes FastAPI particularly effective where an API is consumed by people outside the team — a public endpoint, an internal platform service or a model-serving endpoint — and where the request and response shapes are complex enough that hand-written validation would be the bulk of the code. The trade is the dependency graph: FastAPI is a thin layer over Starlette and Pydantic, so debugging a validation or routing problem usually means reading those libraries’ behaviour, and the async model rewards a working knowledge of the event loop. The documentation and tutorial are among the most complete in the Python ecosystem, and the project ships type stubs so editors complete endpoint code as it is written.
FastAPI installs from PyPI with pip install fastapi plus an ASGI server such as uvicorn, ideally inside a virtual environment. A minimal application creates the app, decorates a function with @app.get, and returns a dict or a Pydantic model; fastapi dev main.py then serves it at 127.0.0.1:8000 with reload, and the documentation appears at /docs as soon as the first route exists. From there the official tutorial covers path and query parameters, request bodies, dependencies, security, database integration and testing with TestClient.
Related reading in this directory: Python, the language FastAPI is written in, and Flask, the lightweight WSGI alternative when async and generated specs are not needed.