Antler by Autoflux

API Reference

The small set of classes and functions that make up FastAPI's public surface.

Path: api-reference

Third-party documentation. This is independently authored analysis of the public FastAPI codebase — not the official docs, and not reviewed or endorsed by the FastAPI team.

API Reference

Most applications only ever import from the top-level fastapi package. This is the core surface referenced throughout the other modules.

Key symbols

  • FastAPI — the application class; subclasses Starlette directly.
  • APIRouter — a composable, independently mountable subset of routing.
  • Depends — declares a callable as a dependency to be resolved before the endpoint runs.
  • HTTPException — raise to return a specific HTTP error status with a JSON detail body.
  • BackgroundTasks — schedule work to run after the response has been sent.

Interface

Interface
python
class FastAPI(Starlette):
def get(self, path: str, *, response_model=None, status_code=200, tags=None, dependencies=None): ...
def post(self, path: str, *, response_model=None, status_code=200, tags=None, dependencies=None): ...
def include_router(self, router: "APIRouter", *, prefix: str = "", tags=None) -> None: ...
 
class APIRouter:
"""Composable subset of FastAPI's routing, mountable onto an app or another router."""
 
def Depends(dependency: Callable, *, use_cache: bool = True) -> Any:
"""Declares a callable as a dependency to be resolved before the endpoint runs."""
 
class HTTPException(Exception):
def __init__(self, status_code: int, detail: Any = None, headers: dict | None = None): ...
 
class BackgroundTasks:
def add_task(self, func: Callable, *args, **kwargs) -> None: ...
 
STATUSinterface