Registry / web-framework / fastapi

fastapi

JSON →
library0.136.0pypypiunverified

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.

web-frameworkserializationhttp-networkingobservability
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
musl
py 3.103.955 runs
installs and imports cleanly · install 0.0s · import 1.546s · 81.2MB
glibc
py 3.103.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 Body
from fastapi import Query
from fastapi import Path

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
Debug
Known footguns
breakingFastAPI version 0.100.0 and above officially support Pydantic V2. Upgrading FastAPI may automatically upgrade Pydantic from V1 to V2, leading to significant breaking changes in model syntax, validators, and error handling. This is a major compatibility consideration.
gotchaUsing blocking I/O operations (e.g., synchronous database calls, heavy computations) directly within `async def` FastAPI path operations can block the entire event loop, severely degrading performance and concurrency.
gotchaTo run FastAPI applications, an ASGI server like Uvicorn is required. For certain features, such as parsing form data, optional dependencies like `python-multipart` are also needed. Missing these will lead to runtime errors or incomplete functionality.
deprecatedThe experimental `@app.vibe()` decorator, briefly introduced in v0.135.3 for 'vibe coding,' was removed just one patch version later in v0.135.4. Applications that adopted this feature during its short lifespan will fail to start on newer versions.
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.

Agent activity
28 hits · last 30 days
oai-searchbot
9
ahrefsbot
4
claudebot
4
bytedance
2
chatgpt-user
2
dotbot
1
commoncrawl
1
Resources