Skip to main content

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",
        body="Hello from Python! 🚀",
        sender_id="MyApp"  # Optional
    )
    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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plexisms-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plexisms-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file plexisms-1.0.0.tar.gz.

File metadata

  • Download URL: plexisms-1.0.0.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

Hashes for plexisms-1.0.0.tar.gz
Algorithm Hash digest
SHA256 077ab0bc0d5522a489e6cfc5d3c67f47c412d14cfd1bd2f9fef7013fba48b5a1
MD5 0b1a7cc3100a40e75e5653bb2d5836e8
BLAKE2b-256 25d0750c3e4e217913ca03c295f50009397defd5a9ed362b1b29467e4ee927b0

See more details on using hashes here.

File details

Details for the file plexisms-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: plexisms-1.0.0-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

Hashes for plexisms-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ecd284e75fefa8a033c55308728019b56dd157962c27dba79165d0735ec20fd
MD5 c52cc7550843cf5b1f3d111eebe19b41
BLAKE2b-256 ab828f6c37c3b6cf9219b134a749a88cf7f1c3edc57902c7f11bebe59ba2e795

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page