datastar-py
Helper functions and classes for the Datastar library (https://data-star.dev/)
What it is and what it does
Datastar-py is a Python SDK that enables real-time, bidirectional communication between backend applications and browsers via server-sent events. Instead of the traditional request-response cycle, a single HTTP request can trigger a stream of events from the backend to the browser, allowing the server to push updates at any time. The package provides low-level event generation primitives (patch_elements, patch_signals) that work with any framework, plus framework-specific decorators and response classes for Django, FastAPI, FastHTML, Litestar, Quart, Sanic, and Starlette.
The SDK handles three main concerns: generating SSE-formatted events, wrapping those events in framework-appropriate response objects, and reading signal state (frontend data) sent with each request. It also includes an attribute generator for building data-* HTML attributes with IDE completion and type checking. The package has no external runtime dependencies and supports Python 3.10 through 3.14.
Use it for:
- Real-time dashboard updates: push live metrics or status changes to a browser without polling.
- Live form validation: send validation feedback to the browser as the user types, using signals to track state.
- Streaming data visualization: continuously update charts or tables with new data from a long-lived SSE connection.
- Collaborative editing: broadcast changes made by one user to all connected clients in real time.
- Progress tracking: stream progress updates from a long-running backend task to show live status.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Datastar-py provides a Python SDK for building server-sent event (SSE) responses that allow backends to push real-time updates to browsers, with built-in helpers for multiple web frameworks.
Yes. Datastar-py is actively maintained, has no external dependencies, and provides a clean abstraction for SSE-based real-time communication across multiple popular frameworks. It's suitable for production use if you're building applications that need server-to-browser push updates. The MIT license imposes no restrictions.
Install
datastar-py on PyPI
pip
pip install datastar-pyuv
uv add datastar-pypoetry
poetry add datastar-pyInstalling datastar-py
Before you install
Low friction to install—pure Python wheel with no runtime dependencies. The package is actively maintained with a recent release (73 days ago) and has accumulated 172 stars on its repository.
License in practice
MIT license is permissive; you can use this package freely in commercial and private projects without restriction.
Quickstart
pip install datastar-py
from datastar_py import ServerSentEventGenerator as SSE, attribute_generator as data
# Generate SSE events
event = SSE.patch_elements("<div>update</div>")
signal_event = SSE.patch_signals({"mysignal": "myval"})
# Generate data attributes
attrs = data.on("click", "console.log('clicked')").debounce(1000).stop
Requires Python 3.10 or later. Framework-specific helpers require installing one of the supported frameworks (Django, FastAPI, FastHTML, Litestar, Quart, Sanic, or Starlette).
Verify before relying
- Whether the package handles backpressure or connection limits for long-lived SSE streams.
- Performance characteristics when broadcasting to many concurrent clients.
- Whether signal state is persisted or only held in memory during a request.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 73 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 170,208/month — #10,402 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: datastar_py-1.0.2-py3-none-any.whl
Keywords: datastar, django, fastapi, fasthtml, flask, html, litestar, quart, sanic, starlette
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
sse-starletteProvides Server-Sent Events streaming for…
permissive · top 1,000 on PyPI
sseclient-pyParses Server-Sent Events (SSE) from HTTP…
permissive · top 5,000 on PyPI
httpx-sseConsume Server-Sent Event (SSE) messages from…
permissive · top 1,000 on PyPI
requests-sseProvides a Python client for consuming…
permissive · top 15,000 on PyPI
filigran-sseclientProvides a Python iterator interface for…
permissive · top 5,000 on PyPI
launchdarkly-eventsourceConsumes Server-Sent Events (SSE) from remote…
permissive · top 5,000 on PyPI
sseclientIterates over Server Sent Event (SSE) streams…
permissive · top 15,000 on PyPI
aiohttp-sse-clientProvides an async Python client for consuming…
permissive · top 15,000 on PyPI
aiohttp-sse-client2Provides an async Python client for consuming…
permissive · top 15,000 on PyPI