Official Python SDK for PlexiSMS API
Project description
PlexiSMS Python SDK
The official Python library for the PlexiSMS API. Send SMS, manage OTPs, and check detailed analytics with our reliable Tier-1 network.
Installation
Install the package via pip:
pip install plexisms
Usage
1. Initialize the Client
You need your API Key from the PlexiSMS Dashboard.
import os
from plexisms import Client
# Option 1: Pass API Key directly
client = Client(api_key="your_api_key_here")
# Option 2: Use environment variable 'PLEXISMS_API_KEY'
# export PLEXISMS_API_KEY="your_api_key_here"
# client = Client()
2. Send an SMS
try:
response = client.messages.create(
to="+243970000000", # Change the phone number
body="Hello from Python! 🚀",
sender_id="MyApp" # Your Name or Brand
)
print(f"SMS Sent! ID: {response['message_id']}")
except Exception as e:
print(f"Error: {e}")
3. Send Bulk SMS
client.messages.create_bulk(
phone_numbers=["+243970000000", "+243810000000"],
body="Bulk message test",
sender_id="MyApp"
)
4. OTP Verification
# Step 1: Send OTP
otp_res = client.otp.send(to="+243970000000", brand="MyService")
verification_id = otp_res['verification_id']
# Step 2: Verify Code (user input)
user_code = input("Enter code: ")
verify_res = client.otp.verify(verification_id=verification_id, code=user_code)
if verify_res['verified']:
print("User verified successfully!")
else:
print("Invalid code.")
5. Check Balance
balance = client.account.balance()
print(f"Current Balance: {balance['amount']} {balance['currency']}")
Error Handling
The SDK raises specific exceptions for better control flow:
from plexisms import Client, AuthenticationError, BalanceError
try:
client.messages.create(...)
except AuthenticationError:
print("Invalid API Key")
except BalanceError:
print("Please recharge your account")
except Exception as e:
print(f"Unexpected error: {e}")
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
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 plexisms-1.0.1.tar.gz.
File metadata
- Download URL: plexisms-1.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f01456f5148290df5a522091810f89b275ac301720bbd7663f0397c9b50102dd
|
|
| MD5 |
00239b359e8b2319176f7faf720969a7
|
|
| BLAKE2b-256 |
e49a655a1ab84ed05ba00ce05d86ff176f43b559c1a6e8f26c702360b3bae39d
|
File details
Details for the file plexisms-1.0.1-py3-none-any.whl.
File metadata
- Download URL: plexisms-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9056203d4aa6a923184100cc0191fae999d3a9016de7e92902626d9e72dae2ed
|
|
| MD5 |
a7160301fdc08fc5f86892f4ab81531c
|
|
| BLAKE2b-256 |
c4d991afa42bae976a5c2c65b98268a478a6f57b808025ecd3713076d4490c2a
|