On this page

On this page

Python API Stack

Verdict

Preferred — FastAPI + Pydantic + Uvicorn is the standard Python API stack; adopt all three together, not as separate picks.

Use when

  • A Python backend has been justified under the criteria in Python Toolchain.
  • Building a Python API that needs data validation and structured models.
  • Serving a FastAPI application whose deployment platform provides no managed ASGI server.

Avoid when

  • A TypeScript-only architecture is sufficient — do not introduce a Python backend automatically (see Python Toolchain).
  • The deployment platform provides an appropriate managed alternative to Uvicorn.

Strengths

  • FastAPI: high-performance ASGI framework with automatic OpenAPI documentation.
  • Pydantic: typed data validation and structured models that integrate with FastAPI request and response handling.
  • Uvicorn: lightweight, standard ASGI server for serving FastAPI applications.

Tradeoffs

  • Adds a separate Python service to manage and deploy.
  • Pydantic models must be kept in sync with the data they validate.

Version policy

  • Prefer the latest stable versions of FastAPI, Pydantic, and Uvicorn for new projects.
  • Do not hold the stack on obsolete versions without a concrete compatibility reason.

Usage rules

  • Use FastAPI as the Python API framework.
  • Use Pydantic for Python data validation and structured models where appropriate.
  • Use Uvicorn as the standard ASGI server for FastAPI applications unless the deployment platform provides an appropriate managed alternative.

Works with

Internal interplay

  • FastAPI + Pydantic — Pydantic models are FastAPI's validation layer; define request and response schemas as Pydantic models rather than hand-rolled validation.
  • FastAPI + Uvicorn — Uvicorn is the standard ASGI server for FastAPI applications unless the platform provides a managed alternative.
  • Python Toolchain — pairs-with: manage environments, dependencies, and linting for this stack with uv and ruff.