A Python web framework for building APIs with standard type hints, offering automatic validation, OpenAPI docs and high performance.
litestar-org/litestar
A flexible ASGI Python web framework for building APIs, with data validation, dependency injection, OpenAPI generation and ORM integration.
- Stars
- 8,537
- Forks
- 683
- Open issues
- 364
- Last commit
- yesterday
What is it?
Litestar is an ASGI framework for Python focused on building APIs. It covers the pieces most API projects need out of the box: request data validation and serialization, dependency injection, middleware, route guards for authorization, and a plugin API. Route handlers can be plain functions or class-based controllers, and type hints drive both validation and the generated OpenAPI 3.1 schema.
The framework supports dataclasses, TypedDict, msgspec, pydantic (v1 and v2) and attrs models. Interactive API documentation is served through Scalar, ReDoc, Swagger-UI and Stoplight Elements, all enabled by default. It also ships a SQLAlchemy plugin so SQLAlchemy models can be used directly as request and response types, and it runs on asyncio or Trio via AnyIO.
Installation is available through pip, and the `litestar[standard]` extra adds the CLI and uvicorn for running applications.
Key features
- 01Request data validation and serialization driven by Python type hints.
- 02Dependency injection with named, sync or async providers at multiple application levels.
- 03Route guards for authorization and layered middleware including CORS, CSRF, rate limiting and compression.
- 04OpenAPI 3.1 schema generation with Scalar, ReDoc, Swagger-UI and Stoplight Elements documentation.
- 05Built-in SQLAlchemy plugin and DTO support, plus support for pydantic, msgspec and attrs models.
Use cases
- Building a JSON REST API in Python with automatically generated OpenAPI documentation.
- Creating async backend services that need typed request validation and dependency injection.
- Exposing SQLAlchemy-backed data directly through typed route handlers.
Quick start
- 1
Install Litestar with pip
pip install litestar - 2
Save the hello world example as app.py
- 3
Run the application
litestar run
In collections
Topics
FAQ
- What is litestar?
- A flexible ASGI Python web framework for building APIs, with data validation, dependency injection, OpenAPI generation and ORM integration. Litestar is an ASGI framework for Python focused on building APIs. It covers the pieces most API projects need out of the box: request data validation and serialization, dependency injection, middleware, route guards for authorization, and a plugin API. Route handlers can be plain functions or class-based controllers, and type hints drive both validation and the generated OpenAPI 3.1 schema.
- Is litestar free to use? What license does it have?
- litestar is open source under the MIT license. Check the license terms before using it in commercial products.
- Is litestar still maintained?
- Actively maintained. The last commit to litestar was on Nov 6, 2026.
- What can I use litestar for?
- Building a JSON REST API in Python with automatically generated OpenAPI documentation. Creating async backend services that need typed request validation and dependency injection. Exposing SQLAlchemy-backed data directly through typed route handlers.
- How do I install litestar?
- Install Litestar with pip: pip install litestar Save the hello world example as app.py Run the application: litestar run
- Where can I get litestar?
- The source code and installation instructions are on GitHub: https://github.com/litestar-org/litestar
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A lightweight ASGI framework and toolkit for building async web services and APIs in Python.
A Python web framework for building type-hinted REST APIs on top of Django, with automatic OpenAPI docs and Pydantic validation.
A PHP 8+ REST API framework that generates routes, validation and OpenAPI docs from plain class methods using reflection.
Asynchronous Kotlin framework for building microservices, web applications and HTTP APIs, developed by JetBrains.
A standalone server that turns any existing PostgreSQL database into a RESTful API with no backend code to write.