Registry / http-networking / vonage-utils

vonage-utils

JSON →
library1.1.4pypypi✓ verified 84d ago

The `vonage-utils` library provides foundational utility objects for interacting with Vonage APIs, including a base HTTP client, error handling, and signature verification. It is currently at version `1.1.4` and serves as a low-level dependency for the `vonage-python-sdk`, which is more frequently updated. While usable independently, most users interact with the higher-level SDK for full API functionality.

pip install vonage-utils
INSTALL
IMPORT
SIG · VONAGE-UTILS
V
vonage-utils
http-networkingpythonv1.1.4
Install
3.2s avg
Import
Disk
26MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.2s · import 0.000s · 28MB
26MB installed
● package 26MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

VonageError
from vonage_utils import VonageError
from vonage_utils.client import Client
format_phone_number
from vonage_utils import format_phone_number
from vonage_utils.client import Client
remove_none_values
from vonage_utils import remove_none_values
from vonage_utils.client import Client

This quickstart demonstrates how to use the `SignatureVerification` class from `vonage-utils` to validate incoming Vonage webhook requests. This is crucial for securing your webhooks by ensuring the payload originated from Vonage and has not been altered.

import os from vonage_utils.signature import SignatureVerification # Replace with your actual signature secret from Vonage API dashboard # For example, store it in an environment variable named VONAGE_SIGNATURE_SECRET VONAGE_SIGNATURE_SECRET = os.environ.get("VONAGE_SIGNATURE_SECRET", "YOUR_SIGNATURE_SECRET") if VONAGE_SIGNATURE_SECRET == "YOUR_SIGNATURE_SECRET": print("WARNING: Please set the VONAGE_SIGNATURE_SECRET environment variable or replace 'YOUR_SIGNATURE_SECRET' with your actual secret.") # Example webhook payload (as a raw string, as received by your server) webhook_payload = '{"msisdn":"1234567890","to":"19876543210","messageId":"00000000-0000-0000-0000-000000000000","text":"Hello World","type":"text","keyword":"HELLO","api-key":"YOUR_API_KEY","message-timestamp":"2023-10-27 10:00:00"}' # Example X-Vonage-Signature header value received with the webhook # This value is a hash calculated by Vonage based on the payload and your secret. # (The example below is a placeholder; a real one would be dynamically generated.) vonage_signature = "e10adc3949ba59abbe56e057f20f883e" # Placeholder: MD5 hash of "Hello World" for illustration verifier = SignatureVerification(VONAGE_SIGNATURE_SECRET) # To verify an incoming webhook signature is_valid = verifier.check_signature(webhook_payload, vonage_signature) if is_valid: print("Signature is valid! The webhook can be trusted.") else: print("Signature is invalid! The webhook might be tampered with or is not from Vonage.") # For actual production use: # - Ensure VONAGE_SIGNATURE_SECRET is your correct secret. # - `webhook_payload` must be the exact raw request body. # - `vonage_signature` must be the exact value from the 'X-Vonage-Signature' HTTP header.
Debug
Known issues
gotchaThe `vonage-utils` package is a foundational component of the `vonage-python-sdk`. While it can be installed and used independently, most users should primarily interact with the higher-level `vonage` package (the main SDK) for full API functionality, as `vonage-utils` only provides low-level building blocks.
fix
For full Vonage API interaction, install `vonage` (`pip install vonage`) and import `Client` from `vonage`.
affects: All versions
gotchaThe `Client` class imported from `vonage_utils.client` is a basic HTTP client. It does not provide the high-level API wrappers, convenience methods (e.g., `client.sms.send_message`), or automatic authentication mechanisms found in the `Client` class from the main `vonage` package. Attempting to call Vonage APIs directly through `vonage_utils.Client` will require manual URL construction, authentication, and request body management.
fix
If you need to send messages or interact with specific Vonage APIs using convenience methods, use `from vonage import Client` after installing `vonage`.
affects: All versions
gotchaWhen using `SignatureVerification` for webhooks, the `secret` parameter expects the unique 'SIGNATURE_SECRET' found in your Vonage API Dashboard. Do not confuse this with your API Key or API Secret, as they are different credentials and will lead to invalid signature verification.
fix
Locate your 'SIGNATURE_SECRET' in the Vonage Dashboard under 'API Settings' and use that specific secret string when initializing `SignatureVerification`.
affects: All versions
Upgrade
Version history
1.1.4latest on PyPI · released Oct 21, 2024
Audit
Dependencies
requestsrequiredUsed for making HTTP requests.
pyjwtrequiredUsed for JSON Web Token (JWT) handling.
cryptographyrequiredProvides cryptographic primitives, likely for signature verification.
pydanticrequiredUsed for data validation and parsing.
Agent activity
49 hits · last 30 days
node
42
OpenAI (training)
1
Resources
vonage-utils — pip install vonage-utils · libregistry