Litestar

2.21.1 · active · verified Sat Apr 11

Litestar is a production-ready, highly performant, and extensible ASGI API framework, currently at version 2.21.1. It emphasizes type safety, developer experience, and modularity, supporting features like dependency injection, OpenAPI schema generation, and ORM integration. The project maintains a frequent release cadence, often issuing minor versions monthly or bi-weekly.

Warnings

Install

Imports

Quickstart

This minimal example demonstrates how to create a Litestar application with a single GET endpoint. It uses an environment variable for a customizable greeting. The 'litestar run' command requires 'uvicorn', which is included with the 'standard' extra.

from litestar import Litestar, get
import os

@get("/")
async def hello_world() -> str:
    return f"Hello, {os.environ.get('NAME', 'World')}!"

app = Litestar(route_handlers=[hello_world])

# To run this application:
# 1. Save it as app.py
# 2. Run in terminal: litestar run --reload
# 3. Access at http://127.0.0.1:8000/

view raw JSON →