FastAPI is an open-source Python web framework created by Sebastián Ramírez and now maintained with a large open-source community. It's the #9 most-used web framework overall, reported in roughly 14.8% of developer surveys, and the fastest-rising framework in the Python ecosystem. Developers reach for it because it generates interactive OpenAPI/Swagger documentation automatically from your code's type hints, while also delivering async performance close to Node.js and Go.
A minimal FastAPI app defines routes with plain Python type hints — FastAPI uses those hints to validate requests and build the docs page automatically.
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
price: float
in_stock: bool = True
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
@app.post("/items")
async def create_item(item: Item):
return {"created": item.name, "price": item.price}
Install FastAPI with an ASGI server, then run the app with hot reload.
# install FastAPI + Uvicorn server
pip install fastapi uvicorn
# run with auto-reload (main.py contains `app = FastAPI()`)
uvicorn main:app --reload