APIRouter groups related FastAPI path operations into a reusable router. Shared prefixes, tags, dependencies, responses, lifecycle handlers, and schema settings can be configured once and applied when the router is included in an application.
FastAPI's HTTPException is raised to send a deliberate client-facing HTTP error. It accepts a status code plus optional JSON-compatible detail data and response headers.
BaseModel is the Pydantic superclass for defining typed data models in FastAPI. Subclass it to describe request bodies with standard Python annotations, enabling structured input handling and automatic API schema generation.
Request is FastAPI's raw HTTP request object, injected into path operations or dependencies through a type annotation. Use it to inspect request-level data directly when standard parameter declarations do not provide the needed access.
FastAPI's Response class represents an HTTP response that can be injected to modify headers or cookies, or constructed and returned directly. Its constructor controls content, status, headers, media type, and background work.
BackgroundTasks collects callable work and runs it after FastAPI sends the response. FastAPI injects it into path operations or dependencies, and add_task() accepts a synchronous or asynchronous function with its arguments.
Depends declares a callable that FastAPI resolves and injects into a route or another dependency. It also controls per-request result caching and, for yield dependencies, cleanup timing.
Path declares a URL path parameter for a FastAPI path operation. It provides schema metadata and validation while the parameter remains required because it is part of the route.
Query declares a FastAPI query parameter and adds validation, documentation metadata, and OpenAPI schema information. Use it with Annotated to express constraints such as length limits or numeric bounds.
Header declares an HTTP request-header parameter for a FastAPI path operation or dependency. It supports defaults, validation, metadata, aliases, and automatic underscore-to-hyphen conversion.
Form declares FastAPI endpoint parameters that are read from submitted form data instead of JSON or query parameters. It supports the same style of configuration as other parameter helpers, including validation and aliases.
get is a FastAPI decorator method that registers a function as the handler for an HTTP GET path. Its keyword arguments configure response behavior and generated OpenAPI metadata.
FastAPI's status module provides named integer constants for HTTP and WebSocket status codes. Import it from fastapi to use readable values such as status.HTTP_200_OK in application code.
Search across every package and filter by type in your dashboard.