Name | litestar JSON |
Version |
2.17.0
JSON |
| download |
home_page | None |
Summary | Litestar - A production-ready, highly performant, extensible ASGI API Framework |
upload_time | 2025-08-10 13:37:41 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4.0,>=3.8 |
license | MIT |
keywords |
api
asgi
litestar
rest
starlite
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<!-- markdownlint-disable -->
<p align="center">
<img src="https://raw.githubusercontent.com/litestar-org/branding/473f54621e55cde9acbb6fcab7fc03036173eb3d/assets/Branding%20-%20PNG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Light.png" alt="Litestar Logo - Light" width="100%" height="auto" />
</p>
<!-- markdownlint-restore -->
<div align="center">
<!-- prettier-ignore-start -->
| Project | | Status |
|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| CI/CD | | [](https://github.com/litestar-org/litestar/actions/workflows/publish.yml) [](https://github.com/litestar-org/litestar/actions/workflows/ci.yml) [](https://github.com/litestar-org/litestar/actions/workflows/docs.yml) |
| Quality | | [](https://codecov.io/github/litestar-org/litestar) |
| Package | | [](https://badge.fury.io/py/litestar)    |
| Community | | [](https://reddit.com/r/litestarapi) [](https://discord.gg/litestar) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |
| Meta | | [](https://github.com/litestar-org/litestar) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black) [](#contributors-) |
<!-- prettier-ignore-end -->
</div>
<hr>
Litestar is a powerful, flexible yet opinionated ASGI framework, focused on
building APIs. It offers high-performance data validation, dependency injection,
first-class ORM integration, authorization primitives, a rich plugin API, middleware,
and much more that's needed to get applications up and running.
Check out the [documentation 📚](https://docs.litestar.dev/) for a detailed overview of
its features!
Additionally, the [Litestar fullstack repository](https://github.com/litestar-org/litestar-fullstack)
can give you a good impression how a fully fledged Litestar application may look.
<details>
<summary>Table of Contents</summary>
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Core Features](#core-features)
- [Example Applications](#example-applications)
- [Features](#features)
- [Class-based Controllers](#class-based-controllers)
- [Data Parsing, Type Hints, and Msgspec](#data-parsing-type-hints-and-msgspec)
- [Plugin System, ORM support, and DTOs](#plugin-system-orm-support-and-dtos)
- [OpenAPI](#openapi)
- [Dependency Injection](#dependency-injection)
- [Middleware](#middleware)
- [Route Guards](#route-guards)
- [Request Life Cycle Hooks](#request-life-cycle-hooks)
- [Performance](#performance)
- [Contributing](#contributing)
</details>
## Installation
```shell
pip install litestar
```
or to include the CLI and a server (uvicorn) for running your application:
```shell
pip install 'litestar[standard]'
```
## Quick Start
```python title="app.py"
from litestar import Litestar, get
@get("/")
async def hello_world() -> dict[str, str]:
"""Keeping the tradition alive with hello world."""
return {"hello": "world"}
app = Litestar(route_handlers=[hello_world])
```
And run it with
```bash
litestar run
```
## Core Features
- [Class based controllers](#class-based-controllers)
- [Dependency Injection](#dependency-injection)
- [Layered Middleware](#middleware)
- [Plugin System](#plugin-system-orm-support-and-dtos)
- [OpenAPI 3.1 schema generation](#openapi)
- [Life Cycle Hooks](#request-life-cycle-hooks)
- [Route Guards based Authorization](#route-guards)
- Support for `dataclasses`, `TypedDict`, [`msgspec`](https://jcristharif.com/msgspec/), [pydantic version 1 and version 2 (even within the same application)](https://docs.pydantic.dev/latest/) and [(c)attrs](https://catt.rs/en/stable/)
[msgspec](https://github.com/jcrist/msgspec) and [attrs](https://www.attrs.org/en/stable/)
- Layered parameter declaration
- Support for [RFC 9457](https://datatracker.ietf.org/doc/html/rfc9457) standardized "Problem Detail" error responses
- [Automatic API documentation with](#redoc-swagger-ui-and-stoplight-elements-api-documentation):
- [Scalar](https://github.com/scalar/scalar/)
- [RapiDoc](https://github.com/rapi-doc/RapiDoc)
- [Redoc](https://github.com/Redocly/redoc)
- [Stoplight Elements](https://github.com/stoplightio/elements)
- [Swagger-UI](https://swagger.io/tools/swagger-ui/)
- [Trio](https://trio.readthedocs.io/en/stable/) support (built-in, via [AnyIO](https://anyio.readthedocs.io/))
- Ultra-fast validation, serialization and deserialization using [msgspec](https://github.com/jcrist/msgspec)
- [SQLAlchemy integration](https://docs.advanced-alchemy.litestar.dev/latest/)
## Example Applications
<details>
<summary>Pre-built Example Apps</summary>
- [litestar-hello-world](https://github.com/litestar-org/litestar-hello-world): A bare-minimum application setup. Great
for testing and POC work.
- [litestar-fullstack](https://github.com/litestar-org/litestar-fullstack): A reference application that contains most of the boilerplate required for a web application.
It features a Litestar app configured with best practices, SQLAlchemy 2.0 and SAQ, a frontend integrated with Vitejs and Jinja2 templates, Docker, and more. Like all
Litestar projects, this application is open to contributions, big and small.
</details>
## Sponsors
Litestar is an open-source project, and we enjoy the support of our sponsors to help fund the exciting
work we do.
A **huge** thanks to our sponsors:
[//]: # "Note to maintainers: Highest sponsors first; no more than 3 per row - create new div if needed"
<a href="https://github.com/scalar/scalar/?utm_source=litestar&utm_medium=website&utm_campaign=main-badge" target="_blank" title="Scalar.com - Document, Discover and Test APIs with Scalar."><img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/sponsors/scalar.svg" width="180" alt="Scalar.com"></a>
<a href="https://telemetrysports.com/" title="Telemetry Sports - Changing the way data influences the sports experience"><img src="https://raw.githubusercontent.com/litestar-org/branding/main/assets/sponsors/telemetry-sports/unofficial-telemetry-whitebg.svg" width="150" alt="Telemetry Sports"></a>
<a href="https://docs.litestar.dev/dev/#sponsors" class="external-link" target="_blank">Check out our sponsors in the docs</a>
If you would like to support the work that we do please consider [becoming a sponsor][sponsor-polar]
via [Polar.sh][sponsor-polar] (preferred), [GitHub][sponsor-github] or [Open Collective][sponsor-oc].
Also, exclusively with [Polar][sponsor-polar], you can engage in pledge-based sponsorships.
[sponsor-github]: https://github.com/sponsors/litestar-org
[sponsor-oc]: https://opencollective.com/litestar
[sponsor-polar]: https://polar.sh/litestar-org
## Features
### Class-based Controllers
While supporting function-based route handlers, Litestar also supports and promotes python OOP using class based
controllers:
<details>
<summary>Example for class-based controllers</summary>
```python title="my_app/controllers/user.py"
from typing import List, Optional
from datetime import datetime
from litestar import Controller, get, post, put, patch, delete
from litestar.dto import DTOData
from pydantic import UUID4
from my_app.models import User, PartialUserDTO
class UserController(Controller):
path = "/users"
@post()
async def create_user(self, data: User) -> User: ...
@get()
async def list_users(self) -> List[User]: ...
@get(path="/{date:int}")
async def list_new_users(self, date: datetime) -> List[User]: ...
@patch(path="/{user_id:uuid}", dto=PartialUserDTO)
async def partial_update_user(
self, user_id: UUID4, data: DTOData[PartialUserDTO]
) -> User: ...
@put(path="/{user_id:uuid}")
async def update_user(self, user_id: UUID4, data: User) -> User: ...
@get(path="/{user_name:str}")
async def get_user_by_name(self, user_name: str) -> Optional[User]: ...
@get(path="/{user_id:uuid}")
async def get_user(self, user_id: UUID4) -> User: ...
@delete(path="/{user_id:uuid}")
async def delete_user(self, user_id: UUID4) -> None: ...
```
</details>
### Data Parsing, Type Hints, and Msgspec
Litestar is rigorously typed, and it enforces typing. For example, if you forget to type a return value for a route
handler, an exception will be raised. The reason for this is that Litestar uses typing data to generate OpenAPI specs,
as well as to validate and parse data. Thus, typing is essential to the framework.
Furthermore, Litestar allows extending its support using plugins.
### Plugin System, ORM support, and DTOs
Litestar has a plugin system that allows the user to extend serialization/deserialization, OpenAPI generation, and other
features.
It ships with a builtin plugin for SQL Alchemy, which allows the user to use SQLAlchemy declarative classes "natively"
i.e., as type parameters that will be serialized/deserialized and to return them as values from route
handlers.
Litestar also supports the programmatic creation of DTOs with a `DTOFactory` class, which also supports the use of
plugins.
### OpenAPI
Litestar has custom logic to generate OpenAPI 3.1.0 schema, include optional generation of examples using the
[`polyfactory`](https://pypi.org/project/polyfactory/) library.
#### ReDoc, Swagger-UI and Stoplight Elements API Documentation
Litestar serves the documentation from the generated OpenAPI schema with:
- [ReDoc](https://redoc.ly/)
- [Swagger-UI](https://swagger.io/tools/swagger-ui/)
- [Stoplight Elements](https://github.com/stoplightio/elements)
- [RapiDoc](https://rapidocweb.com/)
All these are available and enabled by default.
### Dependency Injection
Litestar has a simple but powerful DI system inspired by pytest. You can define named dependencies - sync or async - at
different levels of the application, and then selective use or overwrite them.
<details>
<summary>Example for DI</summary>
```python
from litestar import Litestar, get
from litestar.di import Provide
async def my_dependency() -> str: ...
@get("/")
async def index(injected: str) -> str:
return injected
app = Litestar([index], dependencies={"injected": Provide(my_dependency)})
```
</details>
### Middleware
Litestar supports typical ASGI middleware and ships with middlewares to handle things such as
- CORS
- CSRF
- Rate limiting
- GZip and Brotli compression
- Client- and server-side sessions
### Route Guards
Litestar has an authorization mechanism called `guards`, which allows the user to define guard functions at different
level of the application (app, router, controller etc.) and validate the request before hitting the route handler
function.
<details>
<summary>Example for route guards</summary>
```python
from litestar import Litestar, get
from litestar.connection import ASGIConnection
from litestar.handlers.base import BaseRouteHandler
from litestar.exceptions import NotAuthorizedException
async def is_authorized(connection: ASGIConnection, handler: BaseRouteHandler) -> None:
# validate authorization
# if not authorized, raise NotAuthorizedException
raise NotAuthorizedException()
@get("/", guards=[is_authorized])
async def index() -> None: ...
app = Litestar([index])
```
</details>
### Request Life Cycle Hooks
Litestar supports request life cycle hooks, similarly to Flask - i.e. `before_request` and `after_request`
## Performance
Litestar is fast. It is on par with, or significantly faster than comparable ASGI frameworks.
You can see and run the benchmarks [here](https://github.com/litestar-org/api-performance-tests),
or read more about it [here](https://docs.litestar.dev/latest/benchmarks) in our documentation.
## Contributing
Litestar is open to contributions big and small. You can always [join our discord](https://discord.gg/litestar) server
or [join our Matrix](https://matrix.to/#/#litestar:matrix.org) space
to discuss contributions and project maintenance. For guidelines on how to contribute, please
see [the contribution guide](CONTRIBUTING.rst).
Raw data
{
"_id": null,
"home_page": null,
"name": "litestar",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": "Litestar Developers <hello@litestar.dev>, Cody Fincher <cody@litestar.dev>, Jacob Coffee <jacob@litestar.dev>, Janek Nouvertn\u00e9 <janek@litestar.dev>, Visakh Unnikrishnan <guacs@litestar.dev>, Julien Courtes <julien@litestar.dev>",
"keywords": "api, asgi, litestar, rest, starlite",
"author": null,
"author_email": "Cody Fincher <cody@litestar.dev>, Jacob Coffee <jacob@litestar.dev>, Janek Nouvertn\u00e9 <janek@litestar.dev>, Na'aman Hirschfeld <nhirschfeld@gmail.com>, Peter Schutt <peter@litestar.dev>",
"download_url": "https://files.pythonhosted.org/packages/3f/62/36619846adb94d24d31e1aad7a52632544f2db7b0df22c8839cfa1db0b2e/litestar-2.17.0.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable -->\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/litestar-org/branding/473f54621e55cde9acbb6fcab7fc03036173eb3d/assets/Branding%20-%20PNG%20-%20Transparent/Logo%20-%20Banner%20-%20Inline%20-%20Light.png\" alt=\"Litestar Logo - Light\" width=\"100%\" height=\"auto\" />\n</p>\n<!-- markdownlint-restore -->\n\n<div align=\"center\">\n\n<!-- prettier-ignore-start -->\n\n| Project | | Status |\n|-----------|:----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| CI/CD | | [](https://github.com/litestar-org/litestar/actions/workflows/publish.yml) [](https://github.com/litestar-org/litestar/actions/workflows/ci.yml) [](https://github.com/litestar-org/litestar/actions/workflows/docs.yml) |\n| Quality | | [](https://codecov.io/github/litestar-org/litestar) |\n| Package | | [](https://badge.fury.io/py/litestar)    |\n| Community | | [](https://reddit.com/r/litestarapi) [](https://discord.gg/litestar) [](https://matrix.to/#/#litestar:matrix.org) [](https://blog.litestar.dev) [](https://twitter.com/LitestarAPI) [](https://blog.litestar.dev) |\n| Meta | | [](https://github.com/litestar-org/litestar) [](https://github.com/python/mypy) [](https://spdx.org/licenses/) [](https://github.com/sponsors/litestar-org) [](https://github.com/astral-sh/ruff) [](https://github.com/psf/black) [](#contributors-) |\n\n<!-- prettier-ignore-end -->\n</div>\n\n<hr>\n\nLitestar is a powerful, flexible yet opinionated ASGI framework, focused on\nbuilding APIs. It offers high-performance data validation, dependency injection,\nfirst-class ORM integration, authorization primitives, a rich plugin API, middleware,\nand much more that's needed to get applications up and running.\n\nCheck out the [documentation \ud83d\udcda](https://docs.litestar.dev/) for a detailed overview of\nits features!\n\nAdditionally, the [Litestar fullstack repository](https://github.com/litestar-org/litestar-fullstack)\ncan give you a good impression how a fully fledged Litestar application may look.\n\n<details>\n<summary>Table of Contents</summary>\n\n- [Installation](#installation)\n - [Quick Start](#quick-start)\n- [Core Features](#core-features)\n - [Example Applications](#example-applications)\n- [Features](#features)\n - [Class-based Controllers](#class-based-controllers)\n - [Data Parsing, Type Hints, and Msgspec](#data-parsing-type-hints-and-msgspec)\n - [Plugin System, ORM support, and DTOs](#plugin-system-orm-support-and-dtos)\n - [OpenAPI](#openapi)\n - [Dependency Injection](#dependency-injection)\n - [Middleware](#middleware)\n - [Route Guards](#route-guards)\n - [Request Life Cycle Hooks](#request-life-cycle-hooks)\n- [Performance](#performance)\n- [Contributing](#contributing)\n\n</details>\n\n## Installation\n\n```shell\npip install litestar\n```\nor to include the CLI and a server (uvicorn) for running your application:\n```shell\npip install 'litestar[standard]'\n```\n\n## Quick Start\n\n```python title=\"app.py\"\nfrom litestar import Litestar, get\n\n@get(\"/\")\nasync def hello_world() -> dict[str, str]:\n \"\"\"Keeping the tradition alive with hello world.\"\"\"\n return {\"hello\": \"world\"}\n\napp = Litestar(route_handlers=[hello_world])\n```\n\nAnd run it with\n\n```bash\nlitestar run\n```\n\n\n## Core Features\n\n- [Class based controllers](#class-based-controllers)\n- [Dependency Injection](#dependency-injection)\n- [Layered Middleware](#middleware)\n- [Plugin System](#plugin-system-orm-support-and-dtos)\n- [OpenAPI 3.1 schema generation](#openapi)\n- [Life Cycle Hooks](#request-life-cycle-hooks)\n- [Route Guards based Authorization](#route-guards)\n- Support for `dataclasses`, `TypedDict`, [`msgspec`](https://jcristharif.com/msgspec/), [pydantic version 1 and version 2 (even within the same application)](https://docs.pydantic.dev/latest/) and [(c)attrs](https://catt.rs/en/stable/)\n [msgspec](https://github.com/jcrist/msgspec) and [attrs](https://www.attrs.org/en/stable/)\n- Layered parameter declaration\n- Support for [RFC 9457](https://datatracker.ietf.org/doc/html/rfc9457) standardized \"Problem Detail\" error responses\n- [Automatic API documentation with](#redoc-swagger-ui-and-stoplight-elements-api-documentation):\n - [Scalar](https://github.com/scalar/scalar/)\n - [RapiDoc](https://github.com/rapi-doc/RapiDoc)\n - [Redoc](https://github.com/Redocly/redoc)\n - [Stoplight Elements](https://github.com/stoplightio/elements)\n - [Swagger-UI](https://swagger.io/tools/swagger-ui/)\n- [Trio](https://trio.readthedocs.io/en/stable/) support (built-in, via [AnyIO](https://anyio.readthedocs.io/))\n- Ultra-fast validation, serialization and deserialization using [msgspec](https://github.com/jcrist/msgspec)\n- [SQLAlchemy integration](https://docs.advanced-alchemy.litestar.dev/latest/)\n\n## Example Applications\n\n<details>\n<summary>Pre-built Example Apps</summary>\n\n- [litestar-hello-world](https://github.com/litestar-org/litestar-hello-world): A bare-minimum application setup. Great\nfor testing and POC work.\n- [litestar-fullstack](https://github.com/litestar-org/litestar-fullstack): A reference application that contains most of the boilerplate required for a web application.\n It features a Litestar app configured with best practices, SQLAlchemy 2.0 and SAQ, a frontend integrated with Vitejs and Jinja2 templates, Docker, and more. Like all\n Litestar projects, this application is open to contributions, big and small.\n</details>\n\n## Sponsors\n\nLitestar is an open-source project, and we enjoy the support of our sponsors to help fund the exciting\nwork we do.\n\nA **huge** thanks to our sponsors:\n\n[//]: # \"Note to maintainers: Highest sponsors first; no more than 3 per row - create new div if needed\"\n\n<a href=\"https://github.com/scalar/scalar/?utm_source=litestar&utm_medium=website&utm_campaign=main-badge\" target=\"_blank\" title=\"Scalar.com - Document, Discover and Test APIs with Scalar.\"><img src=\"https://raw.githubusercontent.com/litestar-org/branding/main/assets/sponsors/scalar.svg\" width=\"180\" alt=\"Scalar.com\"></a>\n<a href=\"https://telemetrysports.com/\" title=\"Telemetry Sports - Changing the way data influences the sports experience\"><img src=\"https://raw.githubusercontent.com/litestar-org/branding/main/assets/sponsors/telemetry-sports/unofficial-telemetry-whitebg.svg\" width=\"150\" alt=\"Telemetry Sports\"></a>\n\n<a href=\"https://docs.litestar.dev/dev/#sponsors\" class=\"external-link\" target=\"_blank\">Check out our sponsors in the docs</a>\n\nIf you would like to support the work that we do please consider [becoming a sponsor][sponsor-polar]\nvia [Polar.sh][sponsor-polar] (preferred), [GitHub][sponsor-github] or [Open Collective][sponsor-oc].\n\nAlso, exclusively with [Polar][sponsor-polar], you can engage in pledge-based sponsorships.\n\n[sponsor-github]: https://github.com/sponsors/litestar-org\n[sponsor-oc]: https://opencollective.com/litestar\n[sponsor-polar]: https://polar.sh/litestar-org\n\n## Features\n\n### Class-based Controllers\n\nWhile supporting function-based route handlers, Litestar also supports and promotes python OOP using class based\ncontrollers:\n\n<details>\n<summary>Example for class-based controllers</summary>\n\n```python title=\"my_app/controllers/user.py\"\nfrom typing import List, Optional\nfrom datetime import datetime\n\nfrom litestar import Controller, get, post, put, patch, delete\nfrom litestar.dto import DTOData\nfrom pydantic import UUID4\n\nfrom my_app.models import User, PartialUserDTO\n\n\nclass UserController(Controller):\n path = \"/users\"\n\n @post()\n async def create_user(self, data: User) -> User: ...\n\n @get()\n async def list_users(self) -> List[User]: ...\n\n @get(path=\"/{date:int}\")\n async def list_new_users(self, date: datetime) -> List[User]: ...\n\n @patch(path=\"/{user_id:uuid}\", dto=PartialUserDTO)\n async def partial_update_user(\n self, user_id: UUID4, data: DTOData[PartialUserDTO]\n ) -> User: ...\n\n @put(path=\"/{user_id:uuid}\")\n async def update_user(self, user_id: UUID4, data: User) -> User: ...\n\n @get(path=\"/{user_name:str}\")\n async def get_user_by_name(self, user_name: str) -> Optional[User]: ...\n\n @get(path=\"/{user_id:uuid}\")\n async def get_user(self, user_id: UUID4) -> User: ...\n\n @delete(path=\"/{user_id:uuid}\")\n async def delete_user(self, user_id: UUID4) -> None: ...\n```\n\n</details>\n\n### Data Parsing, Type Hints, and Msgspec\n\nLitestar is rigorously typed, and it enforces typing. For example, if you forget to type a return value for a route\nhandler, an exception will be raised. The reason for this is that Litestar uses typing data to generate OpenAPI specs,\nas well as to validate and parse data. Thus, typing is essential to the framework.\n\nFurthermore, Litestar allows extending its support using plugins.\n\n### Plugin System, ORM support, and DTOs\n\nLitestar has a plugin system that allows the user to extend serialization/deserialization, OpenAPI generation, and other\nfeatures.\n\nIt ships with a builtin plugin for SQL Alchemy, which allows the user to use SQLAlchemy declarative classes \"natively\"\ni.e., as type parameters that will be serialized/deserialized and to return them as values from route\nhandlers.\n\nLitestar also supports the programmatic creation of DTOs with a `DTOFactory` class, which also supports the use of\nplugins.\n\n### OpenAPI\n\nLitestar has custom logic to generate OpenAPI 3.1.0 schema, include optional generation of examples using the\n[`polyfactory`](https://pypi.org/project/polyfactory/) library.\n\n#### ReDoc, Swagger-UI and Stoplight Elements API Documentation\n\nLitestar serves the documentation from the generated OpenAPI schema with:\n\n- [ReDoc](https://redoc.ly/)\n- [Swagger-UI](https://swagger.io/tools/swagger-ui/)\n- [Stoplight Elements](https://github.com/stoplightio/elements)\n- [RapiDoc](https://rapidocweb.com/)\n\nAll these are available and enabled by default.\n\n### Dependency Injection\n\nLitestar has a simple but powerful DI system inspired by pytest. You can define named dependencies - sync or async - at\ndifferent levels of the application, and then selective use or overwrite them.\n\n<details>\n<summary>Example for DI</summary>\n\n```python\nfrom litestar import Litestar, get\nfrom litestar.di import Provide\n\n\nasync def my_dependency() -> str: ...\n\n\n@get(\"/\")\nasync def index(injected: str) -> str:\n return injected\n\n\napp = Litestar([index], dependencies={\"injected\": Provide(my_dependency)})\n```\n\n</details>\n\n### Middleware\n\nLitestar supports typical ASGI middleware and ships with middlewares to handle things such as\n\n- CORS\n- CSRF\n- Rate limiting\n- GZip and Brotli compression\n- Client- and server-side sessions\n\n### Route Guards\n\nLitestar has an authorization mechanism called `guards`, which allows the user to define guard functions at different\nlevel of the application (app, router, controller etc.) and validate the request before hitting the route handler\nfunction.\n\n<details>\n<summary>Example for route guards</summary>\n\n```python\nfrom litestar import Litestar, get\n\nfrom litestar.connection import ASGIConnection\nfrom litestar.handlers.base import BaseRouteHandler\nfrom litestar.exceptions import NotAuthorizedException\n\n\nasync def is_authorized(connection: ASGIConnection, handler: BaseRouteHandler) -> None:\n # validate authorization\n # if not authorized, raise NotAuthorizedException\n raise NotAuthorizedException()\n\n\n@get(\"/\", guards=[is_authorized])\nasync def index() -> None: ...\n\n\napp = Litestar([index])\n```\n\n</details>\n\n### Request Life Cycle Hooks\n\nLitestar supports request life cycle hooks, similarly to Flask - i.e. `before_request` and `after_request`\n\n## Performance\n\nLitestar is fast. It is on par with, or significantly faster than comparable ASGI frameworks.\n\nYou can see and run the benchmarks [here](https://github.com/litestar-org/api-performance-tests),\nor read more about it [here](https://docs.litestar.dev/latest/benchmarks) in our documentation.\n\n## Contributing\n\nLitestar is open to contributions big and small. You can always [join our discord](https://discord.gg/litestar) server\nor [join our Matrix](https://matrix.to/#/#litestar:matrix.org) space\nto discuss contributions and project maintenance. For guidelines on how to contribute, please\nsee [the contribution guide](CONTRIBUTING.rst).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Litestar - A production-ready, highly performant, extensible ASGI API Framework",
"version": "2.17.0",
"project_urls": {
"Blog": "https://blog.litestar.dev",
"Changelog": "https://github.com/litestar-org/litestar/releases/",
"Discord": "https://discord.gg/litestar",
"Discussions": "https://github.com/litestar-org/litestar/discussions",
"Documentation": "https://docs.litestar.dev/",
"Funding": "https://github.com/sponsors/litestar-org",
"Homepage": "https://litestar.dev/",
"Issue Tracker": "https://github.com/litestar-org/litestar/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc",
"Reddit": "https://www.reddit.com/r/LitestarAPI",
"Repository": "https://github.com/litestar-org/litestar",
"Twitter": "https://twitter.com/LitestarAPI"
},
"split_keywords": [
"api",
" asgi",
" litestar",
" rest",
" starlite"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "52040935667c3cee2a26152102b9319fdfe987b0f765e14e0311c17ca6698820",
"md5": "873f1ac057347ab824cd47ebacca21ec",
"sha256": "2e62f01f852195362d69e3305cccddaf6371f5ab0ced30a081a66fb85e1df532"
},
"downloads": -1,
"filename": "litestar-2.17.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "873f1ac057347ab824cd47ebacca21ec",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 564343,
"upload_time": "2025-08-10T13:37:39",
"upload_time_iso_8601": "2025-08-10T13:37:39.462500Z",
"url": "https://files.pythonhosted.org/packages/52/04/0935667c3cee2a26152102b9319fdfe987b0f765e14e0311c17ca6698820/litestar-2.17.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3f6236619846adb94d24d31e1aad7a52632544f2db7b0df22c8839cfa1db0b2e",
"md5": "f8fd29773843135f441d65379d55d3ff",
"sha256": "0f50c3b7063417c338b32902f9eb40b81a7b14c9802edbff921a24aec3b0ea5b"
},
"downloads": -1,
"filename": "litestar-2.17.0.tar.gz",
"has_sig": false,
"md5_digest": "f8fd29773843135f441d65379d55d3ff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 372203,
"upload_time": "2025-08-10T13:37:41",
"upload_time_iso_8601": "2025-08-10T13:37:41.401548Z",
"url": "https://files.pythonhosted.org/packages/3f/62/36619846adb94d24d31e1aad7a52632544f2db7b0df22c8839cfa1db0b2e/litestar-2.17.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-10 13:37:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "litestar-org",
"github_project": "litestar",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "litestar"
}