fastapi/fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
FastAPI – High‑performance Python web framework for APIs
What it is – FastAPI is a modern, production‑ready web framework for building HTTP APIs with Python. It leverages standard Python type hints, Starlette for the async web core, and Pydantic for data validation/serialization.
Why it matters – The framework is engineered for speed (comparable to Node.js or Go) while keeping the developer experience simple: you write ordinary Python functions, get automatic request validation, serialization, and interactive OpenAPI docs (Swagger UI & ReDoc) for free.
Core features (as listed in the README)
- Performance – Built on Starlette and Pydantic; one of the fastest Python API frameworks.
- Fast to code – Typical development speed gains of 200‑300 %.
- Fewer bugs – Roughly 40 % reduction in developer‑induced errors thanks to automatic validation.
- Intelligent editor support – Full type‑aware autocompletion and linting.
- Standards‑based – Generates OpenAPI (Swagger) and JSON‑Schema specifications automatically.
- Automatic docs – Interactive Swagger UI and ReDoc interfaces are served out‑of‑the‑box.
- Dependency injection – Simple, type‑based DI system for clean architecture.
- Security helpers – Built‑in OAuth2, JWT, HTTP Basic, etc.
- Extensible – Supports WebSockets, CORS, cookie sessions, GraphQL (via Strawberry), and more via Starlette extensions.
Typical use cases
- Micro‑services and internal APIs.
- Public RESTful services for machine‑learning models or data pipelines.
- Backend for web or mobile applications where rapid iteration is needed.
- Prototyping and production deployments that require automatic OpenAPI docs.
Getting started (from the README)
# Install with uv (or pip) – the "standard" extra pulls in recommended dependencies
uv add "fastapi[standard]"
Create main.py:
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def read_root():
return {"Hello": "World"}
@app.get('/items/{item_id}')
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
Run the development server:
uv run fastapi dev # auto‑reload, serves at http://127.0.0.1:8000
Visit http://127.0.0.1:8000/docs (Swagger UI) or .../redoc for the alternative UI.
Extending the example (PUT with a body)
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: float
is_offer: bool | None = None
@app.put('/items/{item_id}')
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}
The docs update automatically to show the new request body schema.
Deployment options
- FastAPI Cloud – one‑click deployment via
uv run fastapi deploy(provided by the same team). - Any ASGI‑compatible host (Uvicorn, Hypercorn, Gunicorn with Uvicorn workers, Docker, serverless platforms, etc.).
Who uses it
The README cites production use at Microsoft, Uber (Ludwig), Netflix (Dispatch), Cisco, and many other companies.
TL;DR
FastAPI lets you write standard Python functions, annotates them with type hints, and instantly gets:
- high‑performance async handling,
- automatic request validation & response serialization,
- live OpenAPI documentation,
- strong editor support. All with a tiny learning curve, making it a go‑to choice for modern Python APIs.
Related
- Project
- Project
- Project
- Dispatch
- Project