Skip to content

Latest commit

 

History

History
108 lines (82 loc) · 3.74 KB

README.rst

File metadata and controls

108 lines (82 loc) · 3.74 KB

aiosfstream

PyPI package Documentation Status Build status Coverage MIT license

aiosfstream is a Salesforce Streaming API client for asyncio. It can be used to receive push notifications about changes on Salesforce objects or notifications of general events sent through the Streaming API.

For detailed guidance on how to work with PushTopics or how to create Generic Streaming Channels please consult the Streaming API documentation. For working with Platform Events or Change Data Capture events check out the linked documentation.

Features

Usage

import asyncio

from aiosfstream 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__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(stream_events())

Documentation

http://aiosfstream.readthedocs.io/

Install

pip install aiosfstream

Requirements