https://github.com/overcat/requests-sse
server-sent events python client library based on requests
https://github.com/overcat/requests-sse
Last synced: 7 months ago
JSON representation
server-sent events python client library based on requests
- Host: GitHub
- URL: https://github.com/overcat/requests-sse
- Owner: overcat
- License: apache-2.0
- Created: 2023-11-08T11:13:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-12-01T06:39:13.000Z (8 months ago)
- Last Synced: 2025-12-03T17:53:59.312Z (8 months ago)
- Language: Python
- Size: 184 KB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
============
requests-sse
============
.. image:: https://img.shields.io/github/actions/workflow/status/overcat/requests-sse/test-deploy.yml?branch=main
:alt: GitHub Workflow Status
:target: https://github.com/overcat/requests-sse/actions
.. image:: https://img.shields.io/pypi/v/requests-sse.svg
:alt: PyPI
:target: https://pypi.python.org/pypi/requests-sse
.. image:: https://img.shields.io/badge/python-%3E%3D3.8-blue
:alt: Python - Version
:target: https://pypi.python.org/pypi/stellar-sdk
A Server-Sent Events python client based on requests, provides a simple interface to process `Server-Sent Events `_.
Installation
------------
.. code-block:: bash
pip install requests-sse
Usage
-----
.. code-block:: python
import requests
from requests_sse import EventSource, InvalidStatusCodeError, InvalidContentTypeError
with EventSource("https://stream.wikimedia.org/v2/stream/recentchange", timeout=30) as event_source:
try:
for event in event_source:
print(event)
except InvalidStatusCodeError:
pass
except InvalidContentTypeError:
pass
except requests.RequestException:
pass
Credits
-------
This project was inspired by `aiohttp-sse-client `_, `aiosseclient `_,
`sseclient `_, and `sseclient-py `_.