Help
Sonetel Python SDK
Integrate Sonetel’s REST API endpoints into your Python projects with ease.
The Sonetel Python SDK simplifies the process of integrating Sonetel’s API into your Python projects. Here’s how you can get started:
- Installation
The easiest way to install the Sonetel Python SDK is via pip:pip install sonetel
You can find more details about the package on the PyPI page.
- Basic Usage
To use the SDK in your Python program, import it at the beginning of your script:import sonetel
- Authentication
Before using any features, you need to authenticate:import os from sonetel import Auth user = os.environ.get('sonetelUsername') pswd = os.environ.get('sonetelPassword') auth = Auth(username=user, password=pswd) access_token = auth.get_access_token()
What operations can be performed?
The SDK allows you to perform various operations on your Sonetel account:
- Account Information:
Retrieve account details, check prepaid balance, and update basic information. - Phone Number Management:
List all phone numbers in your account, purchase new numbers, update call forwarding settings, and remove numbers. - Callback Calls:
Initiate calls between two parties using Sonetel’s callback feature.
You can always see the full capabilities in the API documentation.
Setting up automated calls for telemarketing or spam purposes is strictly prohibited.
Sample Python script to use the SDK
Here’s a basic example of how to use the Sonetel Python SDK to check your account balance:
import os from sonetel import Auth, Account # Securely retrieve credentials user = os.environ.get('SONETEL_USERNAME') pswd = os.environ.get('SONETEL_PASSWORD') # Authenticate auth = Auth(username=user, password=pswd) # Create Account object account = Account(auth.get_access_token()) # Get account balance balance = account.get_balance(currency=True) print(f"Your current Sonetel account balance is: {balance}")
This script demonstrates how to authenticate, create an Account object, and retrieve the current balance of your Sonetel account.