Skip to main content

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.

Release files for plasgate-sms 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plasgate-sms 1.0.0
File Size Uploaded
plasgate-sms-1.0.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for plasgate-sms 1.0.0
File Interpreter ABI Platform
plasgate_sms-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size:13.2 kB

Release files / plasgate-sms-1.0.0.tar.gz

Download URL plasgate-sms-1.0.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4cee316a749adeb09320576db918133b87e1521fa269f49e640dcfc8865f5864
BLAKE2b-256 checksum
How to use checksums
cc7734f91df966b7e2e04680e0dc8b727f68bf2879d7dbfbb311be8a0ebb3f3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release files / plasgate_sms-1.0.0-py3-none-any.whl

Download URL plasgate_sms-1.0.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf07c27538a83faaa57e43364801933ed5f245f294073298ee20a5b18514f1b6
BLAKE2b-256 checksum
How to use checksums
7b9deab770bd8ce876834a1fe5cfd8d9bf83495ce0bc5be1a780d119c5a65f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page