skillfed

datastar-py

Helper functions and classes for the Datastar library (https://data-star.dev/)

datastar-py v1.0.2 170.2K downloads/30d#10,402 on PyPI172
Permissive license MIT Active released

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-py

uv

uv add datastar-py

poetry

poetry add datastar-py

Installing 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

Development Status :: 4 - BetaEnvironment :: Web EnvironmentIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

server-sent events pythonreal-time backend updatesSSE response helpersdatastar framework integrationlive data streaming pythonasync web framework SSEbackend to browser events
real-time-webserver-sent-eventsweb-framework-integration

More Dynamic Content packages