Qortora · Search · Indexed page

litestar.devFetched 2026-08-17T15:18:08Z

Litestar: The Modern Python ASGI Framework

Build blazing fast APIs with automatic documentation, dependency injection, and type safety. Litestar makes complex web development simple and intuitive.

Open original source · Full cached text

Litestar: The Modern Python ASGI FrameworkNew website & v3 The Modern Python ASGI Framework Built to scale Fast APIs with automatic OpenAPI documentation, dependency injection, type safety, and a lot of batteries included. Litestar makes designing complex web apps simpler Get started View on Github pipuv MinimalRoutingWebsocketsDTOs main.py pyproject.toml main.py import uvicorn from litestar import Litestar, get @get("/") async def hello() -> dict[str, str]: return {"message": "Hello, World!"} app = Litestar(route_handlers=[hello]) if __name__ == "__main__": uvicorn.run(app) controllers main.py pyproject.toml main.py import uvicorn from litestar import Litestar from controllers.class_controller import MyController from controllers.router_controller import router app = Litestar(route_handlers=[MyController, router]) if __name__ == "__main__": uvicorn.run(app) main_ws_listener.py main_ws_stream.py pyproject.toml main_ws_listener.py import dataclasses import datetime from litestar import Litestar, websocket_listener @dataclasses.dataclass() class Message: data: dict[str, str] timestamp: datetime.datetime @websocket_listener("/echo") async def echo_handler(data: dict[str, str]) -> Message: """ Accept WebSocket connections on '/echo', and then for every incoming message: - Parse its content as JSON - Call 'echo_handler', passing the data to the 'data' parameter - Serialize the returned 'Message' dataclass to JSON - Send a WebSocket message back """ return Message(data=data, timestamp=datetime.datetime.now()) app = Litestar([echo_handler]) main.py pyproject.toml schema.py main.py import uvicorn from litestar import Litestar, post from schema import User, UserResponseDTO @post("/users", return_dto=UserResponseDTO) async def create_user(data: User) -> User: return User(name=data.name, email=data.email, password=data.password) app = Litestar(route_handlers=[create_user], debug=True) if __name__ == "__main__": uvicorn.run(app) Focused on development experience Modern batteries included Comprehensive optional features available out-of-the-box - authentication, validation, ORM integration, caching, middleware, and more. Use what you need, when you need it. Strict & opinionated design Thoughtful defaults and clear conventions guide you toward best practices, reducing decision fatigue and ensuring consistent, maintainable code. Hierarchical configuration Layered configuration system allows easy modularization. Override settings at any level - application, controller, or route - for maximum flexibility. Powerful plugin system Extend functionality seamlessly with official and community plugins. Build reusable components that integrate naturally with Litestar's architecture. Explore documentation Press enter or space to select a node. You can then use the arrow keys to move the node around. You can then use the arrow keys to move the node around, press delete to remove it and press escape to cancel. Press enter or space to select an edge. You can then press delete to remove it or press escape to cancel. Everything you need to build modern APIs Litestar provides all the tools you need out of the box, with minimal configuration required. Data Validation And Parsing Leverage the power of type hints to define how data should be validated, parsed and serialized. Open Ecosystem Define schemas and models for validation with standard types such as dataclasses, libraries like Pydantic, msgspec, attr, or integrate your own. OpenAPI Automatically generated OpenAPI schemas help to document APIs and integrate with the frontend via TypeScript schema generation. Interactive API Documentation Interactively explore your APIs through Swagger, Redoc or Stoplight Elements, powered by OpenAPI. Middlewares Handle rate-limiting, CORS, CSRF, compression, logging and many more common tasks with Litestar's built-in middlewares. Data Stores Interfaces for various key/value stores that seamlessly integrate with your application and third party extensions. ORM Integration First-class SQLAlchemy support let's you use your models for validation and serialization directly, reducing code duplication. Dependency Injection Powerful dependency injection on all application layers, aides in code decoupling and reduces repetition. Caching Response caching with minimal configuration and overhead to speed up response times. WebSockets Easy to use WebSockets integration, featuring high- and low-level APIs and support for automatic data validation and serialization. Authentication And Authorization Session and JWT based authentication and utilities at your disposal to start building your authentication layer with ease. Explore Litestar nowStart reading docs Extend Litestar with plugins Litestar has a rich module ecosystem, with both official and community-driven plugins. This accelerates development by providing ready-to-use solutions for common needs. Explore all plugins Advanced Alchemy Ready-to-go SQLAlchemy concoctions. 474.9K795 Copy command to install Advanced Alchemy Litestar AsyncPG Asyncpg plugin for Litestar 1.9K14 Copy command to install Litestar AsyncPG Litestar Autowire Package-based route, listener, and task discovery for Litestar 2932 Copy command to install Litestar Autowire Litestar Email Email plugin for Litestar 2.8K16 Copy command to install Litestar Email Litestar Granian Granian plugin for Litestar 28.2K44 Copy command to install Litestar Granian Litestar HTMX HTMX Integration for Litestar 1.9M12 Copy command to install Litestar HTMX Litestar MCP Litestar plugin for Model Context Protocol (MCP) integration 22.1K12 Copy command to install Litestar MCP Litestar OracleDB Oracle DB plugin for Litestar 254 Copy command to install Litestar OracleDB Litestar Queues Task queues, workers, schedules, and backend integrations for Litestar 1.2K8 Copy command to install Litestar Queues Litestar SAQ Litestar integration for SAQ 24.7K31 Copy command to install Litestar SAQ Litestar Vite Vite plugin for Litestar 18.8K36 Copy command to install Litestar Vite SQLSpec SQL Experiments in Python 15.5K98 Copy command to install SQLSpec Unlock synergy, seamless integrations with Litestar Explore Litestar seamless integrations with other tools and platforms, enhancing productivity and workflow efficiency. Scalar Scalar integration. RapiDoc RapiDoc integration. ReDoc ReDoc integration. Spotlight Elements Elements integration. Swagger UI Swagger UI integration. YAML YAML integration. Work with any Python data model Litestar supports all popular Python data modeling libraries out of the box. Choose your favorite or mix and match based on your needs. Pydantic The most popular data validation library for Python. Dataclasses Python's built-in dataclasses with full support for serialization and validation. Attrs Python classes without boilerplate. Mature and battle-tested with excellent performance. TypedDict Type hints for dictionaries with specific key-value types and API responses. Msgspec Fast serialization and validation library with JSON and MessagePack support. The developer's choice for simple and powerful APIs Litestar was born from developers' need to boost productivity and platform performance. What began as a starlette based-solution is now a solid ASGI frameworks to build APIs that scale. 1.6MMonthly downloads 8.4KGitHub Stars Open sourceLitestar is 100% powered by our passionate open source community. Start contributing 291Contributors 2.1KMembers Sponsors Litestar is made possible by contributors and sponsor, it will remain free and open source under the MIT License. Become a sponsor Scalar Telemetry Sports