FastAPI: typed Python APIs with automatic OpenAPI docs
FastAPI is a Python web framework for building async APIs with type hints, automatic OpenAPI documentation and request validation. Here is what it gives you and how to start.
TL;DR: FastAPI is a Python web framework for HTTP APIs. The repository description calls it high performance, easy to learn, fast to code and ready for production, and the topics confirm the shape: api, async, asyncio, json, framework. At 103,778 stars it is one of the most starred projects on GitHub in any language, and the MIT license means you can read it, use it and ship with it.
What it is
FastAPI sits between a plain Python web server and a full framework. You declare a function, annotate its parameters, and the framework handles request parsing, validation and response serialization for you. Because those annotations carry types, the same source of truth also drives the generated OpenAPI documentation.
The metadata for the repository is unusually clean. Implementation language Python, license MIT, created on 2018-12-08 and pushed to yesterday. The homepage is fastapi.tiangolo.com, and the six declared topics are api, async, asyncio, fastapi, framework and json, which tells you the project is squarely about HTTP APIs and about doing them in an asyncio world rather than a request-per-thread one.
What the repository tells you
The tree is small enough to read in a minute and says a lot about how the project is run:
| Path | What it holds |
|---|---|
fastapi/ | The framework package itself |
docs_src/ | Documentation examples as runnable source |
docs/ | The documentation site content |
tests/ | The test suite |
scripts/ | Maintenance and release helper scripts |
pyproject.toml | Packaging, dependencies and tool configuration |
uv.lock | A locked dependency resolution for the project itself |
Two details there are worth more than they look. docs_src/ means the documentation examples live as real source files rather than as prose snippets, so the docs and the code drift far less often than they usually do. uv.lock means the project pins its own development environment with uv, and .python-version and .pre-commit-config.yaml alongside it point to a deliberately reproducible setup.
Getting something running
The smallest useful setup is two packages, the framework and an ASGI server:
pip install fastapi uvicorn
A single module is enough to get an endpoint:
from fastapi import FastAPI
app = FastAPI()
@app.get("/items/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id}
Note the type annotation on the path parameter. That single int is what tells FastAPI to validate incoming input and to document the parameter as an integer in the generated schema, so validation and docs come from the same annotation instead of from two places you have to keep in sync.
Serve it with:
uvicorn main:app --reload
The --reload flag restarts the process when a file changes, which is what you want while iterating.
Where the async topics come from
The async and asyncio topics are the most opinionated part of the project. FastAPI is built around ASGI, so handlers can be async def and await other async work without blocking the event loop. That is the right shape for an API that mostly waits on a database or another service, and it is also why you will see uvicorn rather than a threaded WSGI server in most examples.
The practical consequence is one decision you have to make per handler: if the thing you are calling is a blocking library, running it directly inside an async def handler will stall every other request on that worker. FastAPI handles the case where you declare the handler as a plain def instead, which it runs in a thread pool, so a blocking client library does not become a bottleneck by accident.
When to use it
It fits when you are building a JSON API, when you want the request contract written once as Python types, and when the documentation should exist before anyone asks for it. It also fits when the team is Python-first and would rather not maintain a separate schema file or a separate spec document.
When to skip it
Three cases argue against it. If you are building a server-rendered HTML application, a template-oriented framework is a better fit. If your workload is CPU bound rather than IO bound, async buys you nothing and adds a level of indirection. And if you want a zero-dependency script that answers a handful of requests, a framework is more machinery than the job needs.
One more practical note: the repository already carries 103,778 stars and 10,091 forks, so the ecosystem around it is large and there is a lot of third-party guidance to sift through. Stick to the official documentation at fastapi.tiangolo.com when you are learning the basics.
Source and Accuracy Notes
- Project page: https://github.com/fastapi/fastapi
- Source repository: fastapi/fastapi (verified via GitHub API
html_url) - License: MIT (verified via GitHub API
license.spdx_id) - Stars at time of writing: 103778
Related Posts
dev-tools
Automotive Skills Suite for AI Engineering
Evaluate Automotive Skills Suite for APQP, ASPICE, HARA, safety-plan, and DIA workflows with setup notes, governance risks, and SME review guidance.
5/28/2026
dev-tools
awesome-agentic-ai-zh Roadmap Guide
Explore awesome-agentic-ai-zh as a Chinese agentic AI learning roadmap, with setup notes, track selection, study workflow, and evaluation guidance.
5/28/2026
dev-tools
Baguette iOS Simulator Automation Guide
Set up Baguette for iOS Simulator automation, web dashboards, device farms, gesture input, streaming, and camera testing with Xcode caveats.
5/28/2026