Vonage Account API Client

1.1.1 · active · verified Thu Apr 16

The `vonage-account` library provides Python bindings for interacting with the Vonage Account API. It is part of the larger Vonage Python SDK monorepo (version 4.x.x+), offering functionalities to manage account-related operations such as retrieving balance information. The SDK aims for a regular release cadence, with the main `vonage` package seeing frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Vonage client using API key and secret (preferably from environment variables) and then retrieve the current account balance and top-up status using the `client.account` interface.

import os
from vonage import Vonage, Auth

# Initialize Vonage client using API key and secret from environment variables
# VONAGE_API_KEY and VONAGE_API_SECRET
client = Vonage(
    auth=Auth(
        api_key=os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY'),
        api_secret=os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')
    )
)

try:
    # Retrieve account balance
    balance_response = client.account.get_balance()
    print(f"Account Balance: {balance_response['value']} {balance_response['unit']}")

    # Get account top-up status (example of another account method)
    topup_response = client.account.get_topup()
    print(f"Account Auto Top-up: {'Enabled' if topup_response.get('auto_topup') else 'Disabled'}")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure VONAGE_API_KEY and VONAGE_API_SECRET are correctly set and have permissions.")

view raw JSON →