FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.8+ based on standard Python type hints. It leverages Starlette for the web parts and Pydantic for data validation and serialization. It features automatic OpenAPI documentation (Swagger UI, ReDoc). The current version is 0.136.0, and it maintains a frequent release cadence, often with minor updates several times a month.
Install & Compatibility
Where this runs
tested against v0.136.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.955 runs
installs and imports cleanly · install 0.0s · import 1.546s · 81.2MB
glibcpy 3.10–3.955 runs
installs and imports cleanly · install 6.8s · import 1.421s · 84MB
85MB installed
● package 85MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from fastapi import FastAPI
from fastapi import Depends
from fastapi import HTTPException
While `starlette.status` works, `fastapi.status` is the officially exposed and preferred import path.
from fastapi import status
from fastapi import Query
FastAPI re-exports common Starlette components for convenience; using `fastapi.Response` is generally preferred.
from fastapi import Response
This quickstart demonstrates a basic FastAPI application with two GET endpoints. It defines a root endpoint and an endpoint with a path parameter and an optional query parameter. The accompanying `uvicorn` command shows how to run the application for development.
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
async def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
# To run this app:
# 1. Save it as main.py
# 2. Run from your terminal: uvicorn main:app --reload
# Then open http://127.0.0.1:8000/ or http://127.0.0.1:8000/docs
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.