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.1.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.1.0
File Size Uploaded Provenance Actions
sseclient_py-2.1.0.tar.gz 79.4 kB With provenance Details for sseclient_py-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 88.5 kB

Release files / sseclient_py-2.1.0.tar.gz

Download URL sseclient_py-2.1.0.tar.gz
Size 79.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aa133479a27ab6f83054674acd716a0e822c612a7764c5c89360fbbcf0297447
BLAKE2b-256 checksum
How to use checksums
2e5428751655aeb6a43c19b496ea3065b6957ef1f70066a37c4d50f1f1ad5abb
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.1.0-py3-none-any.whl

Download URL sseclient_py-2.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32a76b209f9fde6a7f01d5e993a5a3db8cc0fe22b700b9246898d6e3af9d159e
BLAKE2b-256 checksum
How to use checksums
2b55339b70e9872559540689078b575abcedb897b9b186fdb9bc48cadc391e17
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.1.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.1.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