FastAPI

FastAPI is a modern Python web framework for building APIs, built on Starlette (ASGI) and Pydantic (data validation). It uses Python type hints to drive request parsing, validation, OpenAPI schema generation, and editor autocomplete, all from one source of truth.

Distinguishing features

  • Type-driven. Function parameter annotations define query, path, header, body, and dependency injection.
  • Automatic OpenAPI. Generates an OpenAPI document and Swagger UI / Redoc pages from the type signatures.
  • Async by default. Built on Starlette; supports async def handlers natively.
  • Dependency injection. Depends() system for sharing logic across endpoints (auth, db sessions, pagination).
  • Pydantic v2. Fast, Rust-backed validation engine for request and response models.

Common ecosystem

  • Servers: Uvicorn, Hypercorn, Gunicorn with Uvicorn workers
  • ORMs: SQLModel (by FastAPI's author), SQLAlchemy 2.0, Tortoise ORM
  • Auth: FastAPI Users, Authlib, fastapi-jwt-auth
  • Background tasks: arq, Celery, RQ, dramatiq
🔗
Related Terms
Django, REST API, OpenAPI, ORM.

Subscribe to Sahil's Playbook

Clear thinking on product, engineering, and building at scale. No noise. One email when there's something worth sharing.
[email protected]
Subscribe
Mastodon