aicometd-ng is a Python 3.10+ compatible fork of https://github.com/robertmrk/aiosfstream
import asyncio
from aiosfstream-ng import SalesforceStreamingClient
async def stream_events():
# connect to Streaming API
async with SalesforceStreamingClient(
consumer_key="<consumer key>",
consumer_secret="<consumer secret>",
username="<username>",
password="<password>") as client:
# subscribe to topics
await client.subscribe("/topic/one")
await client.subscribe("/topic/two")
# listen for incoming messages
async for message in client:
topic = message["channel"]
data = message["data"]
print(f"{topic}: {data}")
if __name__ == "__main__":
asyncio.run(stream_events())
pip install aiosfstream-ng
- Python 3.6+
- aiohttp
- aiocometd-ng