{"id":9392,"library":"vonage-http-client","title":"Vonage HTTP Client for Python","description":"The `vonage-http-client` is a foundational Python HTTP client library for interacting with Vonage APIs. It provides low-level request building and authentication mechanisms, supporting API key/secret and JWT-based authentication. While primarily an internal dependency of the higher-level `vonage` Python SDK, it can be used directly for specific API interactions. The current version is 1.5.1, and it has a relatively stable release cadence, with updates typically coinciding with major SDK changes or specific HTTP client enhancements.","status":"active","version":"1.5.1","language":"en","source_language":"en","source_url":"https://github.com/Vonage/vonage-python-sdk","tags":["vonage","http-client","api","rest","authentication"],"install":[{"cmd":"pip install vonage-http-client","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for making HTTP requests.","package":"requests","optional":false},{"reason":"Used for JWT-based authentication.","package":"pyjwt","optional":false},{"reason":"Provides cryptographic primitives for JWT signing.","package":"cryptography","optional":false}],"imports":[{"note":"The Client class is exposed directly at the top level of the package.","wrong":"from vonage_http_client.client import Client","symbol":"Client","correct":"from vonage_http_client import Client"}],"quickstart":{"code":"import os\nfrom vonage_http_client import Client\nfrom vonage_http_client.exceptions import VonageServerException\n\n# NOTE: For most users, the higher-level 'vonage' SDK (pip install vonage)\n# is recommended for easier API interaction.\n\n# Retrieve API key and secret from environment variables\nAPI_KEY = os.environ.get('VONAGE_API_KEY', '')\nAPI_SECRET = os.environ.get('VONAGE_API_SECRET', '')\n\nif not API_KEY or not API_SECRET:\n    print(\"Warning: Please set VONAGE_API_KEY and VONAGE_API_SECRET environment variables.\")\n    print(\"Skipping quickstart as authentication is required.\")\nelse:\n    try:\n        # Instantiate the HTTP client with your Vonage API credentials\n        client = Client(\n            api_key=API_KEY,\n            api_secret=API_SECRET,\n            # For demonstration, using a common Vonage API base URL.\n            # Specific API paths (e.g., /account/balance) need to be appended manually.\n            base_url=\"https://api.nexmo.com\"\n        )\n\n        # Example: Make a GET request to a Vonage API endpoint.\n        # This will likely require valid credentials and specific endpoint access.\n        # A common endpoint is '/account/balance'.\n        print(\"Attempting to fetch account balance...\")\n        response = client.get('/account/balance')\n\n        print(f\"Status Code: {response.status_code}\")\n        print(f\"Response Body: {response.json()}\")\n\n    except VonageServerException as e:\n        print(f\"Vonage API error: {e.status_code} - {e.reason} - {e.error_response}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to instantiate the `vonage-http-client` with API key/secret and make a basic GET request to a Vonage API endpoint. Remember to set `VONAGE_API_KEY` and `VONAGE_API_SECRET` environment variables. For more complex interactions, the full `vonage` Python SDK is generally preferred as it handles endpoint paths and response parsing automatically."},"warnings":[{"fix":"For most application development, use `pip install vonage` and import from `vonage` instead of `vonage_http_client`.","message":"Users often mistake `vonage-http-client` for the primary Vonage Python SDK. While it provides low-level access, the `vonage` package (`pip install vonage`) offers a much richer, higher-level interface to Vonage APIs, handling endpoint specifics, data serialization, and common use cases.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the specific Vonage API documentation for the exact paths and parameters required for each endpoint. Alternatively, use the `vonage` SDK for simplified API calls.","message":"When using `vonage-http-client` directly, you are responsible for constructing the full API endpoint path (e.g., `/account/balance` for `https://api.nexmo.com/account/balance`) and managing request body/query parameters manually, unlike the higher-level SDK which abstracts these details.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Double-check your API key and secret, ensure they are active in your Vonage account, and verify that the associated API key has the required permissions for the API endpoint you are calling.","message":"Authentication failures (e.g., HTTP 401 Unauthorized) are common when using the client directly if API key/secret or JWT details are incorrect, expired, or if the API key lacks necessary permissions for the requested endpoint.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install vonage-http-client` to install the library.","cause":"The `vonage-http-client` library is not installed in your Python environment.","error":"from vonage_http_client import Client\nModuleNotFoundError: No module named 'vonage_http_client'"},{"fix":"Verify your `VONAGE_API_KEY` and `VONAGE_API_SECRET` environment variables or parameters passed to `Client()`. Ensure they are correct and active in your Vonage account, and have the appropriate permissions.","cause":"The Vonage API key and/or secret provided are invalid, missing, or do not have the necessary permissions for the requested operation.","error":"vonage_http_client.exceptions.VonageServerException: Unauthorized"},{"fix":"Check your internet connection, verify the `base_url` provided to the `Client` constructor is correct (e.g., `https://api.nexmo.com`), and inspect any proxy settings that might be interfering.","cause":"This typically indicates a network issue, an incorrect `base_url`, or a misconfigured proxy preventing the client from reaching the Vonage API servers.","error":"requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))"}]}