Telesign Enterprise SDK
The TeleSign Enterprise SDK for Python simplifies integration with TeleSign's APIs for phone verification, SMS messaging, and fraud prevention services. It allows developers to quickly add security and communication features to their applications. The current version is 4.0.1, and the library maintains an active development status with updates primarily released to support new TeleSign API features, address critical bugs, or incorporate breaking changes from their backend services.
Warnings
- breaking Version 3.0.0 removed all functionality and methods related to the Legacy Intelligence Use Case API and the App Verify SDK. Code using these deprecated APIs will no longer work.
- breaking Version 4.0.0 introduced support for a new Intelligence Cloud endpoint. While backward compatibility might exist for some older endpoints, relying on previous Intelligence Cloud implementations after this update may lead to unexpected behavior or require refactoring to use the new endpoint.
- gotcha The PyPI package name is `telesignenterprise`, but the primary Python package to import from is `telesign`. Importing directly from `telesignenterprise` will result in an `ImportError` for core modules like `rest` or `util`.
- gotcha Older versions of the SDK (e.g., prior to 4.0.1 and 3.0.1) had issues with `pkg_resources` in newer Python environments, potentially leading to build or runtime errors related to setuptools.
Install
-
pip install telesignenterprise
Imports
- RestClient
from telesign.rest import RestClient
- TeleSignUtils
from telesign.util import TeleSignUtils
Quickstart
import os
from telesign.rest import RestClient
CUSTOMER_ID = os.environ.get('TELE_CUSTOMER_ID', 'YOUR_CUSTOMER_ID')
API_KEY = os.environ.get('TELE_API_KEY', 'YOUR_API_KEY')
PHONE_NUMBER = os.environ.get('TELE_PHONE_NUMBER', '+1234567890') # E.164 format
if __name__ == '__main__':
if CUSTOMER_ID == 'YOUR_CUSTOMER_ID' or API_KEY == 'YOUR_API_KEY' or PHONE_NUMBER == '+1234567890':
print("Please set TELE_CUSTOMER_ID, TELE_API_KEY, and TELE_PHONE_NUMBER environment variables or replace placeholders.")
else:
try:
telesign_client = RestClient(CUSTOMER_ID, API_KEY)
# Example: Send an SMS message
response = telesign_client.sms.message(PHONE_NUMBER, "Hello from TeleSign!", message_type="ARN")
if response.status_code == 200:
print(f"SMS message sent successfully: {response.json()}")
else:
print(f"Failed to send SMS message: {response.status_code} - {response.json()}")
# Example: Check PhoneID (basic)
phoneid_response = telesign_client.phoneid.standard(PHONE_NUMBER, {}) # Second arg is optional 'ucid'
if phoneid_response.status_code == 200:
print(f"PhoneID Standard lookup successful: {phoneid_response.json()}")
else:
print(f"Failed PhoneID Standard lookup: {phoneid_response.status_code} - {phoneid_response.json()}")
except Exception as e:
print(f"An error occurred: {e}")