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.2.0.tar.gz (14.8 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.2.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: volga_sdk-1.2.0.tar.gz
  • Upload date:
  • Size: 14.8 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.2.0.tar.gz
Algorithm Hash digest
SHA256 c5db4d6361464ce43ae8bf26da75f8e3aa397fd989a9ced9f0bc5c69efcbe1e4
MD5 187a83141c4ec054d7c4daf79454eba4
BLAKE2b-256 8e9206271cb497b7517be92ad344b9826fd28acd7b26e1496fd16092d7aefd8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: volga_sdk-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31a342888176c1ad8e08aac50e9cc98d68df2e38f88b507408c7d2c472ecc050
MD5 10084351478540f52a09cd066b34cefb
BLAKE2b-256 b0563816aaa40350d63445eec0e9df8a2dcf922cf76648385ae05146047b6d3d

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