Official Python SDK for PingBus Notification Gateway
Project description
PingBus Python SDK (pingbus-python)
An asynchronous, type-safe Python SDK for the PingBus Notification Gateway. Built on httpx and pydantic for high performance and robust data validation.
📦 Installation
pip install httpx pydantic
🚀 Quick Start
Basic Usage
import asyncio
from pingbus import PingBusClient
async def main():
# Automatically picks up PINGBUS_API_KEY and PINGBUS_BASE_URL from env
client = PingBusClient()
# Send a WhatsApp Message
await client.whatsapp.send_message(
instance_id="inst_123",
chat_id="1234567890@c.us",
message="Hello from Python!"
)
# Send an Email
await client.email.send(
to="user@example.com",
subject="Welcome",
body="<h1>Welcome!</h1>",
options={"isHtml": True}
)
asyncio.run(main())
Advanced Push Notifications
from pingbus.models import PushTarget
# Send to a specific User ID
await client.push.send(
target=PushTarget(type="user", userId="user_456"),
notification={"title": "Alert", "body": "Critical Update"}
)
Unified Orchestration
Trigger notifications across multiple channels simultaneously or via a waterfall fallback system using a single, idempotent API call.
await client.dispatch.trigger({
"idempotencyKey": "unique-uuid-v4",
"event": "order_shipped",
"targets": {
"whatsapp": { "instanceId": "wa_123", "chatId": "1234567890@c.us" },
"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")
🔑 Configuration Reference
The client supports automatic environment detection.
| Option | Env Variable | Default |
|---|---|---|
api_key |
PINGBUS_API_KEY |
Required |
base_url |
PINGBUS_BASE_URL |
https://api.pingbus.com |
timeout |
PINGBUS_TIMEOUT |
30.0 |
client = PingBusClient(api_key="pk_...", timeout=10.0)
⚡ Key Features
- Async/Await Native: Uses
httpx.AsyncClientfor non-blocking concurrent requests and connection pooling. - Pydantic Models: All request and response data is validated using Pydantic, providing full IDE autocompletion and type safety.
- Automatic Retries: Implements the normative PingBus retry strategy (Exponential Backoff + Jitter) to handle rate limits (
429) and server errors (503).
🛡️ Webhook Security
Verify that incoming HTTP requests genuinely originated from PingBus using HMAC-SHA256:
is_valid = PingBusClient.verify_signature(
body=request.body,
signature=request.headers["X-PingBus-Signature"],
api_key="your_api_key"
)
📄 License
MIT © PingBus 2026
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pingbus-0.6.0.tar.gz.
File metadata
- Download URL: pingbus-0.6.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0879f478e9d385ae353e29bc873fbab7a2ef47561fd63356f59e560bfc6ac894
|
|
| MD5 |
816922a506c9c74828df902c7430f746
|
|
| BLAKE2b-256 |
f87b7fa8f219476d207cda72f6874d295ccb113df024d1cea938e974f3e7b3f9
|
File details
Details for the file pingbus-0.6.0-py3-none-any.whl.
File metadata
- Download URL: pingbus-0.6.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
268bf5f9e3f1d0d3e5b3e422e104fedf9bdbf9bc5ba70e2bb5c8fa4582d24582
|
|
| MD5 |
f8c1976dc926c9a90c3b9c44040ca301
|
|
| BLAKE2b-256 |
2955c5ef0d13208f17d9a8500956f0ebb15a920121352017f18435e64aefb472
|