Python SDK for CloudSMS API
Project description
CloudSMS Python SDK
A Python SDK for the CloudSMS API, allowing you to easily integrate SMS functionality into your Python applications.
Installation
You can install the package using pip:
pip install cloudsms
Requirements
- Python 3.6 or higher
- requests>=2.25.0
Quick Start
from cloudsms import CloudSMSClient
# Initialize the client
client = CloudSMSClient(
api_token="your-api-token",
sender_id="your-sender-id"
)
# Test the connection
test_response = client.test_connection()
print(test_response["status"]) # 'success' or 'error'
# Check your balance
balance_response = client.get_balance()
if balance_response["status"] == "success":
print(f"Current balance: {balance_response['data']}")
# Send an SMS
sms_response = client.send_sms(
phone_number="+1234567890",
message="Hello from CloudSMS!"
)
if sms_response["status"] == "success":
print("SMS sent successfully!")
else:
print(f"Error: {sms_response['message']}")
API Reference
CloudSMSClient
The main class for interacting with the CloudSMS API.
Constructor
client = CloudSMSClient(api_token: str = "", sender_id: str = "")
api_token: Your CloudSMS API tokensender_id: Your CloudSMS sender ID
Methods
get_balance()
Get your current account balance.
response = client.get_balance()
Returns:
{
"status": "success",
"data": "100.00" # Balance amount without currency symbol
}
test_connection()
Test the API connection.
response = client.test_connection()
Returns:
{
"status": "success",
"message": "Connection successful! Your account is properly configured."
}
send_sms(phone_number: str, message: str)
Send an SMS message.
response = client.send_sms(
phone_number="+1234567890",
message="Hello from CloudSMS!"
)
Returns:
{
"status": "success",
"success": True
}
Error Handling
All methods return a dictionary with at least a "status" key that can be either "success" or "error". When an error occurs, the response will include an error message:
{
"status": "error",
"message": "Error description here"
}
Usage
Initialize the SDK
from gsoftware_sms import GSoftwareSMS
# Initialize with your API token and base URL
sms = GSoftwareSMS(
api_token='your_api_token_here',
base_url='https://your-gsoftware-instance.com'
)
Send SMS to Single Number
response = sms.send_sms(
recipient='31612345678',
sender_id='YourName',
message='This is a test message'
)
print(response)
Send SMS to Multiple Numbers
response = sms.send_sms(
recipient=['31612345678', '8801721970168'],
sender_id='YourName',
message='This is a test message'
)
print(response)
Schedule an SMS
from datetime import datetime
scheduled_time = datetime(2024, 12, 20, 7, 0) # Year, Month, Day, Hour, Minute
response = sms.send_sms(
recipient='31612345678',
sender_id='YourName',
message='This is a scheduled message',
schedule_time=scheduled_time
)
print(response)
Send Campaign to Contact Lists
response = sms.send_campaign(
contact_list_ids=['6415907d0d37a', '6415907d0d7a6'],
sender_id='YourName',
message='This is a campaign message'
)
print(response)
Get SMS Details
# Get details of a specific SMS
sms_details = sms.get_sms('606812e63f78b')
print(sms_details)
# List all SMS messages
all_messages = sms.list_sms()
print(all_messages)
Get Campaign Details
campaign_details = sms.get_campaign('campaign_uid_here')
print(campaign_details)
Response Format
All methods return a dictionary with the following structure:
Success Response
{
"status": "success",
"data": "response data here"
}
Error Response
{
"status": "error",
"message": "A human-readable description of the error"
}
Requirements
- Python 3.6 or higher
- requests>=2.25.1
- python-dateutil>=2.8.2
License
This project is licensed under the MIT License.
License
This project is licensed under the MIT License.
Support
For support, please visit https://cloudsms.gr or contact info@gsoftware.gr.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloudsms-1.0.1.tar.gz.
File metadata
- Download URL: cloudsms-1.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a28ff00eb9d0f0a78098f17828a19fc07c69be74af73e0e58e7d595d1c2d4d0
|
|
| MD5 |
c64d04b5971e8b69bf039e74041fc0fe
|
|
| BLAKE2b-256 |
ae54e2d535f889a7f2e56b89450227a61d351c21be59ce4424fe9044c91eb995
|
File details
Details for the file cloudsms-1.0.1-py3-none-any.whl.
File metadata
- Download URL: cloudsms-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd14fc3acde56dee9d6cfef61c4b6b5ed3508871553f69e491b59da2689572be
|
|
| MD5 |
7c87dbeb0f838a8d1a5f4b108ac2ea34
|
|
| BLAKE2b-256 |
af3cb068417a6e78be49e7058d0ccd36af612d103ec75cf65a40b0c7ead37b03
|