Vonage Number Insight

1.0.7 · maintenance · verified Thu Apr 16

The `vonage-number-insight` package provides Python access to Vonage's Number Insight API, allowing users to retrieve real-time intelligence about phone numbers at basic, standard, and advanced levels. While currently functional, the Vonage Number Insight API is scheduled for sunset on February 4, 2027, with migration encouraged to the Vonage Identity Insights API. The library's current version is 1.0.7 and it's typically updated in conjunction with the main Vonage Python SDK.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to perform a basic Number Insight request. It initializes the Vonage client using API credentials, ideally sourced from environment variables, and then calls the `basic_number_insight` method with a `BasicInsightRequest` object. The response is printed in JSON format. For advanced insights, asynchronous requests via webhooks are recommended.

import os
from vonage import Vonage
from vonage_number_insight import BasicInsightRequest

# Set environment variables: VONAGE_API_KEY, VONAGE_API_SECRET
API_KEY = os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY')
API_SECRET = os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')
PHONE_NUMBER = '12345678900' # Replace with a valid phone number

if not API_KEY or not API_SECRET:
    print("Error: VONAGE_API_KEY and VONAGE_API_SECRET environment variables must be set.")
else:
    try:
        client = Vonage(key=API_KEY, secret=API_SECRET)
        
        # Make a Basic Number Insight Request
        request = BasicInsightRequest(number=PHONE_NUMBER)
        response = client.number_insight.basic_number_insight(request)
        
        print(f"Basic Number Insight for {PHONE_NUMBER}:")
        print(response.model_dump_json(indent=2, exclude_none=True))

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

view raw JSON →