Registry /
communication / vonage-network-sim-swap
Install & Compatibility
Where this runs
tested against v1.1.2 · 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
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 48.1MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.8s · import 0.000s · 48MB
47MB installed
● package 47MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
NetworkSimSwap
✓ from vonage_network_sim_swap import NetworkSimSwap
✗ import vonage
SimSwapCheckRequest
✓ from vonage_network_sim_swap import SimSwapCheckRequest
✗ import vonage
SwapStatus
✓ from vonage_network_sim_swap import SwapStatus
✗ import vonage
This quickstart demonstrates how to initialize the Vonage client and use the `check_sim_swap_date` method to query for SIM swap activity on a given phone number. Ensure your Vonage API Key and Secret are configured, and the phone number is in E.164 format. You must also enable the Network Registry capability in your Vonage Application for this API to work.
import vonage
import os
from datetime import date
# Ensure VONAGE_API_KEY and VONAGE_API_SECRET are set in your environment
# or replace with actual credentials for testing (not recommended for production)
api_key = os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY')
api_secret = os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')
phone_number = os.environ.get('VONAGE_SIM_SWAP_PHONE_NUMBER', '+15551234567')
if not api_key or not api_secret or api_key == 'YOUR_API_KEY':
print("Please set VONAGE_API_KEY and VONAGE_API_SECRET environment variables.")
exit(1)
if not phone_number.startswith('+'):
print("Warning: Phone number should be in E.164 format (e.g., +15551234567). Prepending '+' for example.")
phone_number = '+' + phone_number
client = vonage.Client(key=api_key, secret=api_secret)
try:
# Check for SIM swap activity as of a specific date
# The date should be within the last 30 days for most carriers.
response = client.sim_swap.check_sim_swap_date(
phone_number=phone_number,
date_identifier=date(2024, 1, 1), # Example date. Use a relevant date for real checks.
five_g_nr_check=False # Optional: set to True for 5G network checks if supported and desired
)
if response.is_successful():
print(f"SIM Swap Check successful for {phone_number}:")
print(f" Status: {response.status}")
print(f" Latest SIM Swap Date: {response.latest_sim_swap_date}")
print(f" Is Swapped: {response.is_swapped}")
else:
print(f"SIM Swap Check failed for {phone_number}:")
print(f" Error Code: {response.error_code}")
print(f" Error Message: {response.error_message}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingOlder versions of the Vonage SDK or Sim Swap examples might refer to a `check_sim_swap()` method, which is now deprecated. Use `check_sim_swap_date()` or `check_sim_swap_two_factor()` instead for current functionality.fixUpdate your code to use `client.sim_swap.check_sim_swap_date()` or `client.sim_swap.check_sim_swap_two_factor()` as per the latest Vonage Python SDK documentation.
affects: <4.x.x (for main `vonage` SDK), <1.x.x (for this package's conceptual use)
gotchaThe Vonage Sim Swap API requires phone numbers to be in E.164 format (e.g., `+12345678900`), including the country code prefix. Incorrect formatting will lead to API errors.fixAlways ensure phone numbers are properly formatted to E.164 before making API calls. You can validate and format numbers using libraries like `phonenumbers`.
affects: All versions
gotchaTo use the Sim Swap API, you must enable the 'Network Registry' capability within your Vonage Application in the Vonage Dashboard. For initial testing, utilize the 'Playground' mode, which allows testing with virtual operators or whitelisted numbers without full production approval.fixGo to your Vonage Dashboard -> Applications, select or create an application, and enable the 'Network Registry' capability. For local development, configure 'Playground' access.
affects: All versions
gotchaAuthentication for `vonage.Client` typically uses API Key and Secret. Ensure these are correctly configured and kept secure, preferably via environment variables.fixSet `VONAGE_API_KEY` and `VONAGE_API_SECRET` environment variables. Alternatively, you can pass them directly to `vonage.Client(key='YOUR_KEY', secret='YOUR_SECRET')` but avoid hardcoding in production.
affects: All versions
Upgrade
Version history
1.1.2latest on PyPI · released Nov 29, 2024
Audit
Dependencies
vonagerequiredProvides the core client and Sim Swap functionality, as this package acts as a dependency wrapper.