comms-sdk Python SDK
A Python implementation of the CommsSDK for sending SMS and managing communications, following the same patterns as the Ruby and Kotlin reference implementations.
Version: 1.1.0
Features
- Consistent API across all supported languages
- Authenticate with username and API key
- Send SMS to one or more recipients
- Optional sender ID and message priority
- Check account balance
- Comprehensive error handling
Installation
Install the package from PyPI:
pip install comms-sdk
Or for development:
pip install .
Usage
Basic Authentication
from comms_sdk.v1 import CommsSDK, MessagePriority
# Authenticate with username and API key
sdk = CommsSDK.authenticate("your_username", "your_api_key")
Sending SMS
# Send SMS to a single number
success = sdk.send_sms("0712345678", "Message to send")
# Send SMS to multiple numbers
success = sdk.send_sms(["0712345678", "0787654321"], "Message to many")
# Send SMS with custom sender ID and priority
success = sdk.send_sms(
"0712345678",
"Hello!",
sender_id="MyApp",
priority=MessagePriority.HIGH
)
# Get full API response
response = sdk.query_send_sms(
["0712345678"],
"Hello!",
"MyApp",
MessagePriority.HIGHEST
)
Checking Balance
# Get balance as a float
balance = sdk.get_balance()
print(f"Balance: {balance}")
# Get full balance response
response = sdk.query_balance()
print(f"Status: {response.Status}")
print(f"Balance: {response.Balance}")
Configuration
# Use sandbox environment
CommsSDK.use_sandbox()
# Use live server (default)
CommsSDK.use_live_server()
# Set custom sender ID
sdk.with_sender_id("MyCustomSender")
API Reference
CommsSDK
Static/Class Methods
CommsSDK.authenticate(user_name: str, api_key: str) -> CommsSDK- Authenticate and return SDK instance.
CommsSDK.use_sandbox()- Switch to sandbox environment.
CommsSDK.use_live_server()- Switch to live environment.
Instance Methods
with_sender_id(sender_id: str) -> CommsSDK- Set sender ID, returns self for chaining.
send_sms(numbers: str | List[str], message: str, sender_id: Optional[str] = None, priority: MessagePriority = MessagePriority.HIGH) -> bool- Send SMS, returns boolean.
query_send_sms(numbers: str | List[str], message: str, sender_id: Optional[str] = None, priority: MessagePriority = MessagePriority.HIGH) -> Optional[ApiResponse]- Same as
send_sms, but returns the full ApiResponse.
- Same as
get_balance() -> Optional[float]- Get account balance as float.
query_balance() -> Optional[ApiResponse]- Get full balance response as ApiResponse.
set_authenticated()- Mark SDK as authenticated (internal use).
Properties
api_key- The API key used for authentication.user_name- The username used for authentication.sender_id- Current sender ID.is_authenticated- Authentication status.
Models
MessagePriority
MessagePriority.HIGHEST- Priority "0"MessagePriority.HIGH- Priority "1"MessagePriority.MEDIUM- Priority "2"MessagePriority.LOW- Priority "3"MessagePriority.LOWEST- Priority "4"
ApiResponse
Status- Response status ("OK" or "Failed")Message- Response messageCost- Message cost (not always a whole number)MsgFollowUpUniqueCode- Unique tracking codeBalance- Account balance
Error Handling
The SDK raises appropriate Python exceptions:
try:
sdk = CommsSDK.authenticate("", "") # Empty credentials
except ValueError as e:
print(f"Authentication error: {e}")
try:
sdk.send_sms([], "") # Empty numbers and message
except ValueError as e:
print(f"Validation error: {e}")
Thread Safety
The SDK is thread-safe for read operations. For write operations or shared state modifications, use appropriate synchronization mechanisms.
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The package is available as open source under the terms of the MIT License.
Metadata
Release files for comms-sdk 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| comms_sdk-1.1.0.tar.gz | 7.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| comms_sdk-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.7 kB
Release files / comms_sdk-1.1.0.tar.gz
| Download URL | comms_sdk-1.1.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
252c06d338eb3088dfc56397afea5c3991fdf6238cefaffe39d0f792caa83844
|
|
BLAKE2b-256 checksum How to use checksums |
ce7cfcff63b50f9dbe8a9b29520df674b529c891d9588de7881c5149ff90d31b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / comms_sdk-1.1.0-py3-none-any.whl
| Download URL | comms_sdk-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
345512178ca0b050fe8ff4f7e7fa90ab41b5397b296ddcb27db6bb9248ea51ce
|
|
BLAKE2b-256 checksum How to use checksums |
756ceaeab85e20dbafea49f5d0a9d994f4ee6204a40ab3901e749fd5d291b820
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for comms-sdk 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.