Skip to main content

litestar-asyncapi

Generate AsyncAPI 3.1 documents from Litestar WebSocket routes and serve packaged documentation. Requires Python 3.11–3.15 and Litestar >=2.24,<3. AsyncAPI 3.0 remains available with spec_version="3.0.0".

from dataclasses import dataclass

from litestar import Litestar, websocket_listener
from litestar.dto import DataclassDTO
from litestar_asyncapi import AsyncAPIConfig, AsyncAPIPlugin, DocsConfig
from litestar_asyncapi.spec import Server


@dataclass
class Message:
    text: str


@websocket_listener("/chat", dto=DataclassDTO[Message])
async def chat(data: Message) -> Message:
    return data


app = Litestar(
    [chat],
    plugins=[AsyncAPIPlugin(AsyncAPIConfig(
        title="Chat", version="1.0.0",
        docs=DocsConfig(interactive=True),
        servers={"local": Server(host="localhost:8000", protocol="ws")},
    ))],
)

Save as app.py and run uv run litestar --app app:app run. Open /asyncapi/ for React documentation and /asyncapi/asyncapi.json for JSON. YAML is opt-in with DocsConfig(yaml=True). Python consumers need no Node installation.

Operations describe the application: incoming messages are receive, outgoing messages are send. Native Litestar schema generation supplies model schemas; fixed tuples export Draft07 positional items with exact length bounds.

Interaction defaults to off. The example enables the upstream WebSocket console: validation is advisory; Send transmits entered text even when invalid. Supported JSON text object/array contracts can connect to explicit servers. Binary, plain-text, JSON-string and ambiguous contracts remain documentation-only. The application must enforce its own validation and authorization.

AsyncAPI React component 3.2.1 (React 18.3.1) is the default renderer. DocsConfig(renderer="scalar") selects Scalar 1.69.2, which omits tuple positions, zero-length bounds and boolean schemas. With interactive=True, Scalar links to the shared React console at /asyncapi/playground.

Export without starting a server:

uv run litestar --app app:app asyncapi export
uv run litestar --app app:app asyncapi export --format yaml --output asyncapi.yaml

Existing files require --overwrite. Export also works with DocsConfig(enabled=False).

See the documentation, including the migration guide, runnable examples and Learn guides. Build documentation with make docs.

Development uses make lint, make test, make validate-asyncapi, and the locked Node (.nvmrc) frontend toolchain. CI tests installed wheels across supported Python versions. Release workflows publish the tested wheel and its accompanying source distribution.

Metadata

Release files for litestar-asyncapi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litestar-asyncapi 0.3.0
File Size Uploaded Provenance Actions
litestar_asyncapi-0.3.0.tar.gz 2.3 MB With provenance Details for litestar_asyncapi-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for litestar-asyncapi 0.3.0
File Interpreter ABI Platform Actions
litestar_asyncapi-0.3.0-py3-none-any.whl Python 3 none any Details for litestar_asyncapi-0.3.0-py3-none-any.whl

Total release size: 4.3 MB

Release files / litestar_asyncapi-0.3.0.tar.gz

Download URL litestar_asyncapi-0.3.0.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
ce76f819687f64ca39d75d30bf75aaecadbcc3db5a7d44f4b850ab5bab4a4dd7
BLAKE2b-256 checksum
How to use checksums
b4d5b559dfdefb9be37f859ef4ed3c4d42b1230e40c8f0105f6bd8ec28fea8cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / litestar_asyncapi-0.3.0-py3-none-any.whl

Download URL litestar_asyncapi-0.3.0-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
737f0255de40451ad5b42d1d7123fd0367f1236d120980b4ddddf0bce566ae29
BLAKE2b-256 checksum
How to use checksums
aeba1bf2cfa526833c669bb9111c22e9cb2dc2123ec46016b6cf4f67fc717aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for litestar-asyncapi 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for litestar_asyncapi-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page