Skip to main content

Official Python SDK for the Volga Public API (conversations, messages, outbound webhooks).

Project description

volga

Official Python SDK for the Volga Public API — conversations, messages, and outbound webhooks.

  • Zero dependencies (standard library only)
  • Automatic retries (429 + 5xx + network) with Retry-After support
  • Cursor auto-pagination via generators
  • Built-in webhook signature verification
  • Python 3.8+

Install

pip install volga-sdk

(The distribution is volga-sdk; you still import volga.)

Quickstart

import os
from volga import VolgaClient

volga = VolgaClient(api_key=os.environ["VOLGA_API_KEY"])

# List conversations
page = volga.conversations.list(channel="whatsapp", limit=25)

# Send a reply (idempotent retries)
import uuid
volga.messages.send(
    conversation_id=page["data"][0]["id"],
    text="Thanks for reaching out!",
    idempotency_key=str(uuid.uuid4()),
)

Pagination

# One page at a time
page = volga.messages.list(conversation_id="c_123")
print(page["data"], page["has_more"], page["next_cursor"])

# Or auto-paginate every item
for message in volga.messages.iterate(conversation_id="c_123"):
    print(message["id"], message["text"])

Webhooks

Register an endpoint (the signing secret is returned once):

endpoint = volga.webhook_endpoints.create(
    url="https://example.com/volga/webhooks",
    event_types=["message.received", "conversation.created"],
)
# store endpoint["secret"] securely

Verify and parse incoming deliveries (pass the raw request body):

from volga import construct_event, VolgaSignatureVerificationError

@app.post("/volga/webhooks")
def handle(request):
    try:
        event = construct_event(
            secret=os.environ["VOLGA_WEBHOOK_SECRET"],
            payload=request.get_data(),  # raw bytes, not parsed JSON
            signature_header=request.headers.get("Volga-Signature"),
        )
    except VolgaSignatureVerificationError:
        return "", 400
    # handle event["type"] / event["data"] ...
    return "", 200

Deliveries are at-least-once — deduplicate on the event id (or the Volga-Delivery-Id header).

Errors

from volga import VolgaRateLimitError, VolgaPermissionError, VolgaApiError

try:
    volga.messages.send(conversation_id=cid, text=text)
except VolgaRateLimitError as e:
    time.sleep(e.retry_after_sec or 1)
except VolgaPermissionError:
    ...  # the key is missing a scope
except VolgaApiError as e:
    print(e.status, e.code, e.message, e.trace_id)
Class Status
VolgaInvalidRequestError 400 / 422
VolgaAuthenticationError 401
VolgaPaymentRequiredError 402
VolgaPermissionError 403
VolgaNotFoundError 404
VolgaConflictError 409
VolgaRateLimitError 429
VolgaServerError 5xx
VolgaConnectionError / VolgaTimeoutError no response

Configuration

VolgaClient(
    api_key="vk_live_…",
    base_url="https://hooks.volga-ai.com/v1",  # default
    timeout=30.0,        # default
    max_retries=2,       # default
    retry_base_delay=0.5,
    retry_max_delay=8.0,
)

License

MIT

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

volga_sdk-1.1.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

volga_sdk-1.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file volga_sdk-1.1.0.tar.gz.

File metadata

  • Download URL: volga_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for volga_sdk-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e689a312be18d9715814d6cb0951bfac62cd9bb6e489354224c2ad886b0aa1a1
MD5 0943d14132388f6e2359a85be47d1ac1
BLAKE2b-256 06a2b3731fbc2e73b6b40cdacd98b22e1c7ddff9c90f37c345e0f3bb68fca738

See more details on using hashes here.

File details

Details for the file volga_sdk-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: volga_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for volga_sdk-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 690e44fa3a24171ab2bc0fde5cb808e1d603401cab8a7d4a5949d8e6b57d5dc1
MD5 0ed7424f094af2032d3dbf6b5d636f54
BLAKE2b-256 63058abf08e502f206648c8d1ce04e2e07bcc454cb3bc8902ea137d9c0d774b1

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