Server SDK · Python backends
Python SDK
Python 3.10+. Uses the standard library with no runtime dependencies.
Install from GitHub
The SDK source is public on the main branch. These instructions use Git or a locally built package; package registry releases are a separate step.
pip install "git+https://github.com/pubbio/sdk-python.git@main"
Install into your existing virtual environment. Replace main with a verified commit to pin the dependency.
Publish an event
Set PUBB_APP_ID, PUBB_APP_KEY and PUBB_APP_SECRET in your server environment, then publish after checking the caller's permissions.
import os
from pubb import PubbServer
pubb = PubbServer(os.environ["PUBB_APP_ID"], os.environ["PUBB_APP_KEY"],
os.environ["PUBB_APP_SECRET"])
result = pubb.trigger("notifications", "message.sent", {"message": "Hello from Pubb!"})
print(result.publication_id)
Calls are synchronous and use a configurable timeout. trigger accepts socket_id and idempotency_key keyword arguments. PubbAPIError exposes status and retry_after; PubbProtocolError indicates an invalid response. Network errors propagate from urllib.
HTTP 202 confirms acceptance for processing, not delivery. The response includes publicationId and duplicate. SDKs do not automatically retry publications; reuse an idempotency key when retrying the same event. The API accepts 1–100 channels and up to 10 KiB of UTF-8 JSON data.
Private and presence channels
Return authorize_channel(socket_id, channel) or authorize_presence_channel(socket_id, channel, verified_user_id, user_info) from your authenticated backend route after checking channel permissions.
Your backend receives socket_id and channel_name, checks the authenticated user’s access, and returns auth plus channel_data for presence. Derive the presence user ID from the session and forward the signed channel_data unchanged.
Keep the app secret on your trusted server. Public channels must not carry personal or restricted data. Read the channel access reference for the protocol.
Verify your integration
- Subscribe to
notificationsin your app or the dashboard’s Live console. - Publish
message.sentto the same application and channel from your backend. - Check the event payload, connection cleanup and recovery after a disconnect. Test denied access as well as successful private subscriptions.
The repositories include automated tests and examples. Verify end-to-end delivery with your own application before sending production traffic. Refetch durable state after reconnecting; missed events are not replayed.
Legacy pusher:* and pusher_internal:* control names are retained where required by the protocol. Their presence alone does not imply drop-in compatibility with every Pusher client or server.