Skip to main content

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.AsyncClient for 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

pingbus-0.5.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pingbus-0.5.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pingbus-0.5.0.tar.gz.

File metadata

  • Download URL: pingbus-0.5.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pingbus-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ff1034ab06cd8666bd055caf3b144d7a0e3394c9486ace7ef033d35cab781ddf
MD5 8d58e8adced3b482a337d41ec2373c3b
BLAKE2b-256 5762b14aab59deb68c8bfb1a3c75eb345524c107ea23e4c52148a40843bccff2

See more details on using hashes here.

File details

Details for the file pingbus-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pingbus-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pingbus-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aa6ceea4f57b58e086f9b6eb0b4270462e0c20f7c4ee3baa25faf628f461ddf
MD5 3a7ad339827cf82d17595559649bc4ff
BLAKE2b-256 68455a56bdc39fb17c5805d11f9c4d77417e847e530d98c05377ea8a678422b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page