1. License
“Permission is hereby granted, free of charge, to any person obtaining a copy of this software”
Any use, including paid and closed-source apps.
github.com/fastapi/fastapi/blob/master/LICENSE3. Used by agents' projects
Dependency in 465 public GitHub projects set up for AI coding agents that we scanned (7.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
docs.railway.com/llms.txtFrom the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error
What FastAPI does
FastAPI is a free Python framework for the server part of a website or app, the part that receives orders, sign-ups or uploads and answers them. You describe what each request must contain with plain Python types. FastAPI then checks incoming data, sends clear errors and makes a live docs page where you can try every request.
What people build with it
Server for a web or mobile app
Your front end or phone app sends orders, sign-ups and searches to a small Python server that checks each one and answers.
A docs page to try every request
Open /docs in the browser and send test requests by hand; front-end developers and AI assistants see what the server expects.
Photo and file uploads
People upload a photo or a document from a form; your server receives it without filling the memory with big files.
Send the email after answering
After a sign-up the visitor gets the answer at once, and the welcome email goes out a moment later in the background.
Put an AI model behind a web address Idea
Wrap a Python model or an LLM call in one route, so your site, a chat widget or another service can ask it questions.
Read a slow file in the background
A user uploads a big spreadsheet; the server answers "accepted" right away and works through the file afterwards.
FastAPI popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How FastAPI is used
- FastAPI is a dependency in 465 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (28.7% of the 1,623 Python ones), #2 of 102 in http servers and apis.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 3,148; those are left out of every share on this page.
- The most used alternative in our scan is Flask (106 projects).
- Projects that use it most often also use Uvicorn (92.5%), Pydantic (63.4%), python-dotenv (48.0%).
- It is more common in projects set up for OpenClaw (10.5%) than for OpenAI Codex (4.1%).
By coding agent
Often used with
FastAPI in practice
Strengths
Parameters, query values and bodies are declared once, as function parameters with normal type hints. The README stresses that there is no new syntax or library-specific classes to learn for this.
If a request does not match the declared types, FastAPI rejects it with an error message. The README says this also applies to deeply nested JSON objects.
Every app serves interactive documentation in Swagger UI and in ReDoc. Both update as you add endpoints. In Swagger UI you can fill in parameters and send real requests with "Try it out".
The maintainers say FastAPI is based on and "fully compatible with" OpenAPI and JSON Schema. The generated OpenAPI document can feed client code generators for other languages.
Watch out for
The README claims about 200% to 300% faster feature development and about 40% fewer developer-induced errors. A footnote says these numbers come from the team's own internal tests, not from an independent study.
The project is still on 0.x versions, and release 0.143.0 is marked as breaking. Automatic exporter setup from <code>OTEL_*</code> variables is now opt-in. Apps that relied on it must set a flag. Apps that configure their own providers and exporters need no changes.
FastAPI delegates the web layer to Starlette and data handling to Pydantic. Request bodies are Pydantic models, so you will be working with Pydantic directly as well as with FastAPI.
Path, query and a Pydantic request body
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
is_offer: bool | None = None
@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}
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
return {"item_name": item.name, "item_id": item_id}More about FastAPI
Funding
- GitHub Sponsors: https://github.com/tiangolo
- 113 GitHub sponsors
Agent Skills for it
- fastapi-python: Expert in FastAPI Python development with best practices for APIs and async operations
- fastapi-templates: Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new
- fastapi-expert: Use when building high-performance async Python APIs with FastAPI and Pydantic V2. Invoke to create REST endpoints, define Pydantic models,
- fastapi-python: Expert in FastAPI Python development with best practices for APIs and async operations
- fastapi-router-py: Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints,
- fastapi-pro: Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async p
Head to head
- FastAPI vs Flask used together in 18 projects
- FastAPI vs Starlette used together in 64 projects
Packages around it
- fastapi-mcp: MCP server from FastAPI apps
- fastapi-cli: fastapi dev / run commands
- fastapi-cloud-cli: FastAPI Cloud deploy CLI
- fastapi-mail: Email sending
- fastapi-cache2: Response caching
- fastapi-users: User accounts and auth
More in HTTP servers and APIs
Alternatives
FastAPI This page
Pick Flask for a classic Python site with server-made HTML pages and a large plugin collection, where automatic request checking and docs matter less.
Pick Django when you want a full Python site kit with database models, an admin panel and user accounts built in.
Pick Express when the server side of your project is JavaScript on Node.js rather than Python.
Lightweight ASGI web framework for building Python APIs and web applications.
High-performance Python web framework and async networking library for building servers.
Get started
Tell your AI assistant
“Use FastAPI (pin fastapi[standard]==0.162.4, Python 3.10+) to build a small server with Pydantic models for each request, clear 422 errors for bad input, an upload route, and the /docs page for testing.”
Install FastAPI with its standard extras (server, form and upload parsing, the fastapi command) into a virtual environment.
uv add "fastapi[standard]"Write main.py with one route that returns a dictionary.
from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"}Run it with fastapi dev while you build, and with fastapi run on the real server.
fastapi dev
Rules for your agent
## FastAPI
- Install with `uv add "fastapi[standard]"`, keeping the extra in quotes. With pip, install `fastapi[standard]` inside a virtual environment.
- Use `fastapi dev` for local work (auto-reload). Use `fastapi run` for production.
- Declare path, query and body inputs as typed function parameters. A default of `= None` makes a parameter optional. Without it the parameter is required.
- Model JSON request bodies as Pydantic `BaseModel` classes and take them as a typed parameter.
- Use `async def` for a path function only if your code uses `async` / `await`. Otherwise use plain `def`.
- On 0.143.0 or later, if the app relies on `OTEL_*` environment variables for exporters, set `FASTAPI_OTEL_AUTO_CONFIGURE=true` or pass `telemetry={"auto_configure": True}`.
- Check the generated docs at `/docs` or `/redoc` after adding endpoints.
Mistakes to avoid
The plain package leaves out the server, the fastapi command and the form parser; uploads need python-multipart.
Minor versions carry breaking changes; 0.147 to 0.162 changed how omitted booleans, empty strings and unselected files in forms are read.
Blocking calls inside async def stop the whole server from answering other requests meanwhile.
Since 0.155.0 unknown keyword arguments raise TypeError at startup.
A wildcard origin excludes requests that carry credentials, so logged-in calls from the browser fail.
Questions
Which Python version do I need?
Python 3.10 or newer for FastAPI 0.162.4; support for 3.9 was dropped in February 2026.
Do I need async and await?
No. Plain def functions work; the docs say to use plain def when a library you call cannot await.
Does FastAPI send data about my app anywhere?
Not by default. It records traces and metrics, but since 0.143.0 it sends them only when you turn on automatic setup and give it an address.
Can I use it in a paid product?
Yes. It is MIT-licensed; keep the license notice with copies you ship.