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", # 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

  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.1.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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

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

Hashes for plexisms-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f01456f5148290df5a522091810f89b275ac301720bbd7663f0397c9b50102dd
MD5 00239b359e8b2319176f7faf720969a7
BLAKE2b-256 e49a655a1ab84ed05ba00ce05d86ff176f43b559c1a6e8f26c702360b3bae39d

See more details on using hashes here.

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

Hashes for plexisms-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9056203d4aa6a923184100cc0191fae999d3a9016de7e92902626d9e72dae2ed
MD5 a7160301fdc08fc5f86892f4ab81531c
BLAKE2b-256 c4d991afa42bae976a5c2c65b98268a478a6f57b808025ecd3713076d4490c2a

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