| name | aiohttp-sse-2-2-0 |
| description | Python library for Server-Sent Events (SSE) support in aiohttp applications. Use when building real-time streaming endpoints that push data from server to clients using the EventSource API, implementing chat applications, live notifications, or continuous data feeds without WebSocket complexity. |
aiohttp-sse 2.2.0
Overview
aiohttp-sse provides Server-Sent Events (SSE) support for aiohttp. It enables one-way real-time communication from server to client over HTTP using the text/event-stream content type and the browser's native EventSource API.
Unlike WebSockets, SSE is simpler — no handshake protocol, works over standard HTTP, supports automatic reconnection, and integrates cleanly with aiohttp's async architecture. The library provides EventSourceResponse (subclass of aiohttp.web.StreamResponse) and the convenience helper sse_response() for context-manager-based streaming.
Part of the official aio-libs family, requires aiohttp 3+ and Python 3.8–3.12.
When to Use
- Building real-time push endpoints (live feeds, notifications, progress updates)
- Implementing chat applications with server-to-client messaging
- Streaming continuous data (timestamps, sensor readings, stock prices)
- Any scenario where one-way server-to-client streaming suffices and WebSocket complexity is unnecessary
- Migrating from polling-based architectures to event-driven streaming
Core Concepts
SSE Protocol
SSE uses the text/event-stream MIME type. The connection stays open and the server pushes discrete messages:
data: message payload\r\n
\r\n
Optional fields: id: for reconnection tracking, event: for named event types, for reconnection timeout in milliseconds. Comments starting with are used internally for pings.