Registry / communication / vonage-network-sim-swap

vonage-network-sim-swap

JSON →
library1.1.2pypypi✓ verified 85d ago

This package provides access to the Vonage Sim Swap Network API, primarily acting as a dependency installer for the main `vonage` Python SDK (currently v4.7.2). It enables developers to check for recent SIM card swaps for a given phone number, which is crucial for fraud detection and enhancing security. While `vonage-network-sim-swap` itself is at version 1.1.2, the core Sim Swap functionality is integrated and accessed through the `vonage.Client().sim_swap` object provided by the `vonage` library. It follows the release cadence of the main `vonage` SDK for Sim Swap related updates.

pip install vonage-network-sim-swap
INSTALL
IMPORT
SIG · VONAGE-NETWORK-SIM
V
vonage-network-sim-swap
communicationpythonv1.1.2
Install
4.8s avg
Import
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 48.1MB
glibc
py 3.103.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.
fix
Update 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.
fix
Always 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.
fix
Go 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.
fix
Set `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.
Agent activity
33 hits · last 30 days
node
32
OpenAI (training)
1
Resources
vonage-network-sim-swap — pip install vonage-network-sim-swap · libregistry