API Reference

Litestar

A high-performance ASGI framework for Python with typed handlers, dependency injection, and validation.

Official Documentation ↗
CompatibilityThis documentation covers version v2. Check the official docs for the latest API surface.

Installation

pippip install litestar

Methods

Litestar wires typed route handlers to a validated data model and injects dependencies by signature.

Key Features

  • Typed handlers with automatic validation
  • Dependency injection by signature
  • OpenAPI generation and layered middleware

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

How is validation handled?
Handler parameter types drive validation. Use dataclasses, Pydantic models, or built-in types and invalid input is rejected automatically.
How does dependency injection work?
Dependency values are declared as handler parameters with a value provider; Litestar resolves them from the signature at request time.
Does it generate API docs?
Yes. OpenAPI schema and Swagger or ReDoc UIs are generated from the typed handlers.