Skip to main content

pysfpubsub

Python gRPC client for the Salesforce Pub/Sub API.

https://developer.salesforce.com/docs/platform/pub-sub-api/overview

Installation

pip install pysfpubsub

Usage

from datetime import datetime
from pysfpubsub import Client

def process_event(event, client):
    """
    This is a callback that gets passed to the `Client.subscribe()` method.
    When no events are received within a certain time period, the API's subscribe
    method sends keepalive messages and the latest replay ID through this callback.
    """
    if event.events:
        print("Number of events received in FetchResponse: ", len(event.events))
        # If all requested events are delivered, release the semaphore
        # so that a new FetchRequest gets sent by `Client.fetch_req_stream()`.
        if event.pending_num_requested == 0:
            client.release_subscription_semaphore()

        for evt in event.events:
            # Get the event payload and schema, then decode the payload
            payload_bytes = evt.event.payload
            json_schema = client.get_schema_json(evt.event.schema_id)
            decoded_event = client.decode(json_schema, payload_bytes)
            print(decoded_event)
    else:
        print(f"[{datetime.now():%Y-%m-%d %H:%M:%S}] The subscription is active.")

config = {
    "url": "https://login.salesforce.com",
    "username": "myusername",
    "password": "mypassword",
    "grpc_host": "api.pubsub.salesforce.com",
    "grpc_port": 7443,
    "api_version": "57.0"
}
sfdc_handler = Client(**config)
sfdc_handler.auth()
sfdc_handler.subscribe("/events/Example_Event__c", "LATEST", "", 1, process_event)

Metadata

Release files for pysfpubsub 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysfpubsub 0.1.2
File Size Uploaded Provenance Actions
pysfpubsub-0.1.2.tar.gz 11.5 kB Without provenance Details for pysfpubsub-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysfpubsub 0.1.2
File Interpreter ABI Platform Actions
pysfpubsub-0.1.2-py3-none-any.whl Python 3 none any Details for pysfpubsub-0.1.2-py3-none-any.whl

Total release size: 23.3 kB

Release files / pysfpubsub-0.1.2.tar.gz

Download URL pysfpubsub-0.1.2.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d61333bee3d2020b97203dab7aeef49c06a659303a370deb37c8532188f32217
BLAKE2b-256 checksum
How to use checksums
72b90f2e5d595fb6f8adcda23ab945c0b37ed8c726a99b34f936c802178e1e94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Release files / pysfpubsub-0.1.2-py3-none-any.whl

Download URL pysfpubsub-0.1.2-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bccf5703d0b0bdb3e50184541b39436aa7cf2480ed7150fe5fdad44781124111
BLAKE2b-256 checksum
How to use checksums
2116f6a8c05603b0d1b9e146b666a4a9a1ef883b294fdfa111be1d07548beb7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Security for pysfpubsub 0.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

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