STK-22Optional Open source
Use FastAPI for a Python API
Use FastAPI for a Python service that only answers JSON, and pin its minor version.
Review by
2027-04-30
How to do it
This pick is a recorded exception to the five-year test, dated 27 October 2026, because FastAPI has never reached 1.0. FastAPI first came out in December 2018, and version 0.156.8 shipped in October 2026. It has never reached version 1.0, so it fails the five-year stable test, and minor versions can break code. It passes the rest. It has about 114 million weekly downloads and an MIT licence. It was used by 18.5% of developers in the 2026 Stack Overflow survey, above Flask and Django. Record the exception as the first chapter asks. Choose something else when the app also needs pages, accounts and an admin, which Django brings. It checks input with Pydantic, as Use Zod or Pydantic to check every input says.
Examples
Python example
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Order(BaseModel):
id: int
total_cents: int
@app.get("/orders/{order_id}")
def get_order(order_id: int) -> Order:
return Order(id=order_id, total_cents=4200)
JavaScript example
const PINNED_MINOR = /^fastapi>=0\.(\d+)(\.\d+)?,<0\.(\d+)$/;
export const isMinorPinned = requirement => {
const match = PINNED_MINOR.exec(requirement.replace(/\s/g, ''));
return Boolean(match) && Number(match[3]) === Number(match[1]) + 1;
};
How to check
requirements or pyproject pins FastAPI to one minor version, such as fastapi>=0.156,<0.157, and a decision record names the exception.
Sources
Related rules
- STK-23 Use Zod or Pydantic to check every input in Software choices
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/web-frameworks/fastapi">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.