Softlink SMS SDK
A Python SDK for Softlink's SMS Gateway - a reliable and efficient platform for sending SMS messages in Kenya and beyond. This SDK provides a simple interface to integrate Softlink's SMS services into your Python applications.
Overview
Softlink SMS Gateway is a leading provider of SMS services in Kenya, offering:
- High delivery rates
- Real-time delivery reports
- Competitive pricing
- 24/7 support
- Reliable infrastructure
Features
- Send individual and bulk SMS messages
- Flexible configuration options
- Comprehensive error handling
- Type hints for better IDE support
- Simple and intuitive API
- Real-time delivery status
- Support for all Kenyan mobile networks
Installation
pip install softlink
Configuration
You can configure the SMS client in two ways:
1. Using Environment Variables
Set the following environment variable:
export SOFTLINK_SMS_API_KEY='your_consumer_key'
2. Using Direct Configuration
from softlink import SMSConfig
# Using consumer key
config = SMSConfig(
consumer_key='your_consumer_key'
)
# Or use default configuration from environment
config = SMSConfig()
Usage
Basic Usage
from softlink import SMSClient
# Using environment variables
client = SMSClient()
# Send SMS
results = client.send_sms({
"message": "Jambo Kenya",
"recipients": ["+254713164545"]
})
With Custom Configuration
from softlink import SMSClient, SMSConfig
# Using consumer key
config = SMSConfig(
consumer_key='your_consumer_key'
)
client = SMSClient(config)
Error Handling
The library provides a comprehensive set of exceptions for better error handling:
from softlink import (
SMSClient,
SoftlinkException,
APIError,
APIConnectionError,
AuthenticationError,
InvalidRequestError,
RateLimitError,
SMSError,
SMSDeliveryError,
SMSValidationError,
SMSQuotaError
)
try:
client = SMSClient()
results = client.send_sms({
"message": "Jambo Kenya",
"recipients": ["+254713164545"]
})
except AuthenticationError as e:
print(f"Authentication failed: {e}")
except SMSValidationError as e:
print(f"Invalid input: {e}")
except SMSDeliveryError as e:
print(f"Message delivery failed: {e}")
except SMSQuotaError as e:
print(f"Quota exceeded: {e}")
except RateLimitError as e:
print(f"Rate limit exceeded: {e}")
except APIConnectionError as e:
print(f"Network error: {e}")
except APIError as e:
print(f"API error: {e}")
except SoftlinkException as e:
print(f"General error: {e}")
Available Exceptions
SoftlinkException: Base exception class for all SDK exceptionsAPIError: Raised when the API returns an error responseAPIConnectionError: Raised when network communication failsAuthenticationError: Raised when authentication failsInvalidRequestError: Raised when invalid parameters are passedRateLimitError: Raised when too many requests are madeSMSError: Base exception for SMS-specific errorsSMSDeliveryError: Raised when SMS delivery failsSMSValidationError: Raised when SMS validation failsSMSQuotaError: Raised when SMS quota is exceeded
API Reference
SMSClient
__init__(config: Optional[SMSConfig] = None)
Initialize the SMS client with configuration.
send_sms(payload: dict) -> dict
Send SMS messages to recipients.
Parameters:
payload(dict): Dictionary containing:message(str): The message contentrecipients(List[str]): List of recipient phone numbers in E.164 format (e.g., +254713164545)
Returns:
dict: Response from the API containing message status and details
SMSConfig
Configuration class for managing API credentials.
Parameters:
consumer_key(Optional[str]): Consumer key for authentication. If not provided, will try to load from environment variable SOFTLINK_SMS_API_KEY
Best Practices
-
Phone Number Format
- Always use E.164 format (e.g., +254713164545)
- Include country code
- Remove any spaces or special characters
-
Message Content
- Keep messages concise
- Avoid special characters
- Test messages before bulk sending
-
Error Handling
- Always implement proper error handling
- Log errors for debugging
- Implement retry logic for failed messages
- Handle rate limits appropriately
Support
For support, please contact:
- Email: softwareproviders69@gmail.com
- Phone: +254 713 164 545
- Website: https://softlinksms.co.ke
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for softlink 0.1.5
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 | Actions |
|---|---|---|---|---|
| softlink-0.1.5.tar.gz | 4.0 kB | With provenance | Details for softlink-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| softlink-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for softlink-0.1.5-py3-none-any.whl |
Total release size: 9.2 kB
Release files / softlink-0.1.5.tar.gz
| Download URL | softlink-0.1.5.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4250e13a8452eac13b89e998511ebe6e71b42066c531e7c8e47c02a32fa9db0
|
|
BLAKE2b-256 checksum How to use checksums |
a9ffa08191e759c77d08f81a38341013c422caf809b4491e81c1ff15b202a55e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2025.
Transparency logRelease files / softlink-0.1.5-py3-none-any.whl
| Download URL | softlink-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb1f7f289e78fddc82814735b657b3814abf316cc2b7cb0a74135eb3ab8ffebf
|
|
BLAKE2b-256 checksum How to use checksums |
ef6fa53e5c947d534f22514f4df65bea7373dde0f78b5a399bd03a6b1f5a5926
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2025.
Transparency logSecurity for softlink 0.1.5
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for softlink-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 13, 2025.
Transparency logA 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.