Skip to main content

Server-Sent Events client for Python

sseclient-py turns a streaming HTTP response into Server-Sent Events (SSE). It works with requests, urllib3 and httpx, and has no dependencies. Python 3.11 or newer is required.

Installation

$ pip install sseclient-py

Usage

import requests
import sseclient

url = "https://example.com/events"
with requests.get(
    url,
    headers={"Accept": "text/event-stream"},
    stream=True,
    timeout=(3.05, 60),
) as response:
    response.raise_for_status()
    for event in sseclient.SSEClient(response).events():
        print(event.id, event.event, event.data)

The timeout is a connect/read timeout, not a limit on the whole stream. Adjust the read timeout to allow for your server’s keep-alive interval.

Other HTTP clients

Pass the client’s byte stream to SSEClient:

import httpx
import urllib3

# urllib3
http = urllib3.PoolManager()
response = http.request("GET", url, preload_content=False)
client = sseclient.SSEClient(response.stream())

# httpx
with httpx.stream("GET", url) as response:
    client = sseclient.SSEClient(response.iter_bytes())
    for event in client.events():
        print(event.data)

Reconnecting

Manage connections and retries in your application. Reconnect when events() ends or the HTTP client raises a connection or read-timeout error. Use a delay or backoff between attempts.

Resuming depends on the server. When event.id is not None, remember that ID, including an empty string (which clears it). Send a non-empty remembered ID in the next request’s Last-Event-ID header. ID-only updates are not exposed by this parser; duplicate-free delivery is not guaranteed.

The yielded events have id, event, data and retry attributes. Comments and events without data are ignored.

Resources

Metadata

Release files for sseclient-py 2.0.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 sseclient-py 2.0.0
File Size Uploaded Provenance Actions
sseclient_py-2.0.0.tar.gz 77.4 kB With provenance Details for sseclient_py-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sseclient-py 2.0.0
File Interpreter ABI Platform Actions
sseclient_py-2.0.0-py3-none-any.whl Python 3 none any Details for sseclient_py-2.0.0-py3-none-any.whl

Total release size: 86.6 kB

Release files / sseclient_py-2.0.0.tar.gz

Download URL sseclient_py-2.0.0.tar.gz
Size 77.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dfbaa7a9b076cefd46f3a1ab1ccb9ae52cfad6d29ad2492273285d40f58b354f
BLAKE2b-256 checksum
How to use checksums
51f2dd7ce6df53e1ff13d39e37dadca6dea6093cec12c3ec01732d7c43ba521f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 15, 2026.

Transparency log

Release files / sseclient_py-2.0.0-py3-none-any.whl

Download URL sseclient_py-2.0.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efad5729df93d3f4055320b3aceb9d3d8d73444c00c1c304c5a4c104338c3e8f
BLAKE2b-256 checksum
How to use checksums
04ec92960b67e492d3971d705e32212240d35ebae4a672edad7daa1501c9648e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 15, 2026.

Transparency log

Security for sseclient-py 2.0.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 sseclient_py-2.0.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 15, 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