PingBus Python SDK (pingbus)
A production-grade Python SDK for the PingBus Notification Gateway. Features native httpx async support, full type hints, and first-class integration for multi-channel messaging.
📦 Installation
pip install pingbus
🔑 Configuration
| Option | Env Variable | Default | Description |
|---|---|---|---|
api_key |
PINGBUS_API_KEY |
Required | Your pk_... API key from Account settings. |
base_url |
PINGBUS_BASE_URL |
https://www.pingbus.live |
Production API base URL. |
timeout |
PINGBUS_TIMEOUT |
30.0 |
Global request timeout in seconds. |
import os
from pingbus import PingBusClient
client = PingBusClient(
api_key=os.getenv("PINGBUS_API_KEY"), # keep server-side only
base_url="https://www.pingbus.live"
)
Security: Your
pk_API key is a full-access bearer token. Always keep it on the server — never expose it in frontend/client code.
🔐 Authentication
All requests are authenticated with a standard Authorization header automatically set by the SDK:
Authorization: Bearer pk_your_key_here
Content-Type: application/json
No token in the URL is required or used.
🚀 Unified Orchestration (client.dispatch)
Trigger notifications across multiple channels simultaneously or via a waterfall fallback using a single, idempotent API call.
import asyncio
async def main():
result = await client.dispatch.trigger({
"idempotencyKey": "unique-uuid-v4",
"event": "order_shipped",
"targets": {
"whatsapp": { "instanceId": "waInstance4256253175", "chatId": "919876543210@c.us" },
"email": { "to": "customer@example.com" },
"sms": { "to": "+19876543210" }
},
"content": {
"title": "Order Shipped!",
"body": "Hi {{name}}, your order #{{orderId}} is on the way."
},
"variables": { "name": "Alice", "orderId": "ORD-777" },
"strategy": "waterfall",
"config": { "waterfallTimeoutMs": 300000 }
})
# Check dispatch status
status = await client.dispatch.get_status("unique-uuid-v4")
asyncio.run(main())
🛰️ WhatsApp Service (client.whatsapp)
Messaging
async def whatsapp_examples():
# Send a text message
await client.whatsapp.send_message('4256253175', '919876543210@c.us', 'Hello from PingBus!')
# Send a file from URL
await client.whatsapp.send_file_by_url(
'4256253175',
'919876543210@c.us',
'https://example.com/invoice.pdf',
name='invoice.pdf',
caption='Your Invoice'
)
# Poll for incoming messages (returns None if queue is empty)
notification = await client.whatsapp.receive('4256253175')
(Note: In the Python SDK, instance ID can be passed simply as the number string, e.g., '4256253175', because client.whatsapp internally prepends waInstance to it.)
📧 Email Service (client.email)
async def email_examples():
# Send Email
await client.email.send('user@example.com', 'Welcome', '<h1>Hi!</h1>', options={'isHtml': True})
# Fetch Logs
logs = await client.email.list_logs(limit=50, offset=0)
📱 Push & SMS Services
Push Notifications (FCM)
from pingbus.models import PushTarget
async def push_example():
target = PushTarget(type="user", userId="app_user_123")
await client.push.send(
target=target,
notification={"title": "Update", "body": "New feature available!"}
)
☁️ Account & Management
async def mgmt_examples():
# Get profile
profile = await client.account.get_profile()
# Provision Proxies for WhatsApp
proxy = await client.proxies.provision()
await client.proxies.attach(proxy['id'], 'waInstance4256253175')
🛡️ Reliability
Automatic Retries
The SDK implements Exponential Backoff with Jitter. It automatically handles rate limits (429) and server availability issues (503).
Webhook Verification
Validate that incoming webhooks genuinely originated from PingBus:
is_valid = PingBusClient.verify_signature(raw_body, signature_header, os.getenv("PINGBUS_API_KEY"))
📄 License
MIT © PingBus 2026
Metadata
Release files for pingbus 0.8.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pingbus-0.8.5.tar.gz | 7.5 kB | Without provenance | Details for pingbus-0.8.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pingbus-0.8.5-py3-none-any.whl | Python 3 | none | any | Details for pingbus-0.8.5-py3-none-any.whl |
Total release size: 14.3 kB
Release files / pingbus-0.8.5.tar.gz
| Download URL | pingbus-0.8.5.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9b16524923a4b17553ba37a2607dcf2780598fbd61c1e5167b8da433d9f13eb
|
|
BLAKE2b-256 checksum How to use checksums |
851f920f85d4ed1da15d2bbf761ff3da9bc03cddcdae9bc2bec9369b5cc22adc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / pingbus-0.8.5-py3-none-any.whl
| Download URL | pingbus-0.8.5-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66883fcdbc1f9d72908f794fc5cc8d48c5110d37ee71144fec04936f61beb07b
|
|
BLAKE2b-256 checksum How to use checksums |
20f792d7732a14b2310ff05a2366db27c12df076b08d475794e62835a511e2ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for pingbus 0.8.5
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.