Skip to main content

Plasgate SMS API client

Project description

Plasgate SMS API Client

plasgate is a powerful Python library designed for seamless interaction with the Plasgate SMS API. It enables users to send SMS messages effortlessly and manage One-Time Passwords (OTPs) with ease.

Features

  • Send SMS Messages: Quickly send individual or batch SMS messages.
  • OTP Management: Generate and validate OTPs for secure authentication.
  • Delivery Reports: Track message delivery status with optional callbacks.
  • Batch Processing: Efficiently send messages to multiple recipients in a single request.

Installation

To install the plasgate library, use pip. Open your terminal and execute the following command:

pip install plasgate-sms

Configuration

Before using the library, ensure you have your API keys from Plasgate. You'll need:

  • Private Key: Unique identifier for your account.
  • Secret Key: Used for authenticating requests.

These can usually be found in your Plasgate account settings.

Usage

Single Sending

To send a single SMS message, follow this example:

from plasgate.rest import Client

# Initialize client with your API credentials
private = "PLASGATE_PRIVATE_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
secret = "PLASGATE_SECRET_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = Client(private, secret)

# Send a message
response = client.messages.create(
    to="855972432661",
    sender="PlasGate",  # Your sender ID
    content="TestAPI",   # Message content
    dlr="yes",           # Delivery report request
    dlr_url="https://webhook-test.com/273e777973dc8334bbaa2ef63f3d9cf6",  # URL for delivery reports
)

print(response)

Batch Sending

For sending messages to multiple recipients at once, you can use batch sending:

from plasgate.rest import Client

# Initialize client with your API credentials
private = "PLASGATE_PRIVATE_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
secret = "PLASGATE_SECRET_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = Client(private, secret, batch_sending=True)

# Send batch messages
response = client.messages.create(
    messages=[
        {"to": ["85581848677", "855972432661"], "content": "Test plasgate client"}
    ],
    globals={
        "sender": "PlasGate",  # Sender ID for all messages
        "dlr": "yes",           # Request delivery reports
        "dlr_level": 3,         # Level of detail for delivery reports
        "dlr_url": "https://webhook-test.com/273e777973dc8334bbaa2ef63f3d9cf6",  # URL for delivery reports
    },
)

print(response)

Twilio Migration

If you are migrating from Twilio, you can use the same structure with Plasgate:

from plasgate.rest import Client

# Initialize client with your API credentials
account_sid = "PLASGATE_PRIVATE_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "PLASGATE_SECRET_KEY_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = Client(account_sid, auth_token)

# Send a message using the Twilio-like syntax
message = client.messages.create(
    to="+855972432661",  # Recipient's number
    from_="PlasGate",    # Your sender ID
    body="Hello from Python!"  # Message body
)

print(message)

Additional Considerations

  • Error Handling: Ensure you implement error handling to manage any issues with sending messages (e.g., invalid numbers, network errors).
  • Rate Limiting: Be aware of any rate limits imposed by Plasgate to avoid disruptions in service.
  • Secure Your Keys: Always keep your API keys confidential and do not expose them in public repositories.

For more information and detailed documentation, please refer to the official Plasgate API documentation.

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

plasgate-sms-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

plasgate_sms-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file plasgate-sms-1.0.0.tar.gz.

File metadata

  • Download URL: plasgate-sms-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for plasgate-sms-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4cee316a749adeb09320576db918133b87e1521fa269f49e640dcfc8865f5864
MD5 7afa614ab66ef5014afb138ecfe9c0a9
BLAKE2b-256 cc7734f91df966b7e2e04680e0dc8b727f68bf2879d7dbfbb311be8a0ebb3f3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: plasgate_sms-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.17

File hashes

Hashes for plasgate_sms-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf07c27538a83faaa57e43364801933ed5f245f294073298ee20a5b18514f1b6
MD5 6728f17675fcbe250ac06a4e573c57e2
BLAKE2b-256 7b9deab770bd8ce876834a1fe5cfd8d9bf83495ce0bc5be1a780d119c5a65f3c

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