Vonage Network Number Verification

1.0.2 · active · verified Thu Apr 16

The `vonage-network-number-verification` Python library (version 1.0.2) provides a client for interacting with the Vonage Number Verification Network API. It enables programmatic access to verify phone numbers at a network level, offering details like reachability and porting status. This package acts as a specialized client, relying on the core `vonage` Python SDK (versions `>=4.0.0, <5.0.0`) for underlying API communication and authentication. While the main `vonage` SDK sees frequent updates, this specific client package has a less frequent release cadence, with its latest version (1.0.2) released on 2023-09-22.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Vonage Network Number Verification client and make a request to verify a phone number. It requires your Vonage API Key and Secret, which are used to initialize the underlying `vonage.Client` instance. The response contains various network-level details about the number.

import os
from vonage import Client as VonageCoreClient
from vonage_network_number_verification import Client as NumberVerificationClient
from vonage_network_number_verification.models import VerifyNumberRequest

# Your Vonage API key and secret
VONAGE_API_KEY = os.environ.get("VONAGE_API_KEY", "YOUR_API_KEY")
VONAGE_API_SECRET = os.environ.get("VONAGE_API_SECRET", "YOUR_API_SECRET")

# Initialize the core Vonage client (required by the number verification client)
vonage_client = VonageCoreClient(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET)

# Initialize the Network Number Verification client
nv_client = NumberVerificationClient(vonage_client=vonage_client)

# Define the request to verify a number
request_body = VerifyNumberRequest(
    type="phone", # Required: 'phone'
    number="447700900000" # Required: The phone number to verify
)

try:
    # Make the API call
    response = nv_client.post_verify_number(request_body)

    # Print the raw response for inspection
    print(f"\nNetwork Number Verification Response:\n{response.model_dump_json(indent=2)}")

    # Access specific fields
    if response.request_id:
        print(f"\nRequest ID: {response.request_id}")
    if response.port_id_check_status:
        print(f"Port ID Check Status: {response.port_id_check_status}")
    if response.reachability_status:
        print(f"Reachability Status: {response.reachability_status}")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →