FastAPI Overview
Relevant source files
- README.md
- docs/de/docs/index.md
- docs/en/data/sponsors.yml
- docs/en/data/sponsors_badge.yml
- docs/en/docs/advanced/generate-clients.md
- docs/en/docs/advanced/openapi-callbacks.md
- docs/en/docs/advanced/path-operation-advanced-configuration.md
- docs/en/docs/advanced/security/oauth2-scopes.md
- docs/en/docs/advanced/settings.md
- docs/en/docs/deployment/cloud.md
- docs/en/docs/how-to/extending-openapi.md
- docs/en/docs/img/fastapi-conf.jpeg
- docs/en/docs/img/sponsors/bairesdev.svg
- docs/en/docs/img/sponsors/codacy.png
- docs/en/docs/img/sponsors/dribia.png
- docs/en/docs/img/sponsors/flint.png
- docs/en/docs/img/sponsors/interviewpal.png
- docs/en/docs/img/sponsors/investsuite.svg
- docs/en/docs/img/sponsors/rapidproxy.png
- docs/en/docs/img/sponsors/requestly.png
- docs/en/docs/img/sponsors/speakeasy.png
- docs/en/docs/img/sponsors/stainless.png
- docs/en/docs/index.md
- docs/en/docs/release-notes.md
- docs/en/docs/tutorial/bigger-applications.md
- docs/en/docs/tutorial/security/first-steps.md
- docs/en/docs/tutorial/security/oauth2-jwt.md
- docs/en/docs/tutorial/security/simple-oauth2.md
- docs/en/overrides/main.html
- docs/es/docs/index.md
- docs/fr/docs/index.md
- docs/ja/docs/index.md
- docs/ko/docs/index.md
- docs/pt/docs/index.md
- docs/ru/docs/index.md
- docs/tr/docs/index.md
- docs/uk/docs/index.md
- docs/zh/docs/index.md
- docs_src/generate_clients/tutorial004.js
- docs_src/path_operation_advanced_configuration/tutorial002_py310.py
- fastapi/__init__.py
- tests/test_custom_route_class.py
- tests/test_router_include_context.py
FastAPI is a modern, fast (high-performance) web framework for building APIs with Python based on standard Python type hints. This page introduces the framework's purpose, core design philosophy, key features, and fundamental dependencies.
For detailed internals of the framework's architecture, see Core Framework Architecture. For advanced features, see Advanced Features. For deployment options, see Deployment and Distribution.
What FastAPI Is
FastAPI is a Python web framework for building HTTP APIs. It stands on the shoulders of two giants:
- Starlette — handles the web parts (routing, middleware, WebSocket, ASGI lifecycle).
- Pydantic — handles the data parts (validation, serialization, JSON Schema generation).
All request parsing, response serialization, and OpenAPI schema generation are derived from these two foundational libraries. FastAPI acts as an orchestration layer that connects standard Python type hints to automatic validation, documentation, and serialization.
The primary entry point is the FastAPI class, exported from fastapi/__init__.py7
Current stable version: 0.138.0 (see fastapi/__init__.py3)
Sources: fastapi/__init__.py1-25 README.md30-34 docs/en/docs/index.md41-45
Design Philosophy
The framework's central design principle is declare once, get everything. A single Python function signature using standard type annotations is sufficient to define:
- Which parameters come from the path, query string, headers, cookies, or request body.
- What validation rules apply (via Pydantic validators).
- What the response schema looks like.
- What appears in the auto-generated OpenAPI document.
- What editor autocompletion suggests.
This design reduces code duplication, minimizes errors, and eliminates the need to learn framework-specific syntax. Developers write standard Python with type hints, and FastAPI handles the rest.
Core principle: Standard Python types = Runtime validation + API documentation
Sources: README.md32-43 docs/en/docs/index.md43-53
Key Features
Estimations based on tests on an internal development team building production applications.
Technical features:
- Type-driven validation — Uses Python type hints to derive validation, serialization, and documentation.
- Automatic OpenAPI — Every running app exposes
/openapi.json,/docs(Swagger UI), and/redoc(ReDoc). - Dependency Injection — Built-in
DependsandSecurityfor composable dependency graphs. - Async support — Supports both
async defanddefendpoint functions. - WebSocket support — First-class WebSocket handling via
WebSocketandWebSocketDisconnectclasses fastapi/__init__.py24-25 - Frontend Serving — Support for serving static frontend apps via
app.frontend()docs/en/docs/release-notes.md19
Sources: README.md32-43 docs/en/docs/index.md43-53 fastapi/__init__.py1-25
Real-World Usage
FastAPI is used in production by major technology companies:
- Microsoft — "I'm using FastAPI a ton these days. [...] I'm actually planning to use it for all of my team's ML services at Microsoft." — Kabir Khan README.md83-85
- Uber — "We adopted the FastAPI library to spawn a REST server that can be queried to obtain predictions. [for Ludwig]" — Piero Molino, et al. README.md89-91
- Netflix — "Netflix is pleased to announce the open-source release of our crisis management orchestration framework: Dispatch! [built with FastAPI]" — Kevin Glisson, et al. README.md95-97
- Cisco — "If anyone is looking to build a production Python API, I would highly recommend FastAPI. It is beautifully designed, simple to use and highly scalable." — Deon Pillsbury docs/en/docs/index.md120-121
Sources: README.md81-120 docs/en/docs/index.md107-122
Core Dependencies
FastAPI requires exactly two libraries at runtime:
Required dependencies:
| Package | Role | Used For |
|---|---|---|
starlette | ASGI framework | Routing, middleware, requests, responses, WebSocket handling |
pydantic | Data validation | Request validation, response serialization, JSON Schema generation |
Standard installation extras (fastapi[standard]):
When installing with pip install "fastapi[standard]", common optional dependencies are included for server runtime (uvicorn), CLI tools (fastapi-cli), and testing (httpx).
Sources: README.md34 docs/en/docs/index.md45 docs/en/docs/release-notes.md70
High-Level Architecture
Diagram: FastAPI framework layers and dependencies
FastAPI acts as an orchestration layer that extends Starlette's routing capabilities with type-driven parameter extraction and Pydantic validation.
Sources: fastapi/__init__.py1-25 docs/en/docs/tutorial/bigger-applications.md74-98
Public API Surface
The fastapi package re-exports all symbols that application code typically needs.
Diagram: fastapi package public exports mapped to source modules
Sources: fastapi/__init__.py1-25
Primary Symbols
Sources: fastapi/__init__.py1-25
Installation and Quickstart
Installation:
Minimal application (main.py):
Starting the server:
The fastapi dev command is provided by fastapi-cli. It automatically detects the FastAPI instance and starts the server with hot-reload enabled.
Sources: README.md144-249 docs/en/docs/index.md141-246
Request Processing Flow
Diagram: HTTP request lifecycle through FastAPI
Sources: docs/en/docs/tutorial/bigger-applications.md150-188 docs/en/docs/advanced/generate-clients.md43-55
