Skip to main content

Smsdrop-Python

python MIT License black

The official python sdk for the smsdrop api.

Quickstart

import datetime
import logging
import time

import pytz
from dotenv import dotenv_values

from smsdrop import Campaign, Client, RedisStorage

# Enable Debug Logging
# This will og the API request and response data to the console:
logging.basicConfig(level=logging.DEBUG, format="%(message)s")

config = dotenv_values(".env")

TEST_EMAIL = config.get("TEST_EMAIL")
TEST_PASSWORD = config.get("TEST_PASSWORD")
MY_TIMEZONE = config.get("MY_TIMEZONE")


def main():
    # Initialize the client
    client = Client(
        email=TEST_EMAIL, password=TEST_PASSWORD, storage=RedisStorage()
    )
    # Get your account profile information
    print(client.get_profile())
    # Get your subscription information's
    print(client.get_subscription())
    # Get your first 500 campaigns
    print(client.get_campaigns(skip=0, limit=500))

    # Send a simple sms
    client.send_message(message="hi", sender="Max", phone="<phone>")

    # Create a new Campaign
    cp = Campaign(
        title="Test Campaign",
        message="Test campaign content",
        sender="TestUser",
        recipient_list=["<phone1>", "<phone2>", "<phone3>"],
    )
    client.launch(cp)
    time.sleep(20)  # wait for 20 seconds for the campaign to proceed
    client.refresh(cp)  # refresh your campaign data
    print(cp.status)  # Output Example : COMPLETED

    # create a scheduled campaign
    naive_dispatch_date = datetime.datetime.now() + datetime.timedelta(hours=1)
    aware_dispatch_date = pytz.timezone(MY_TIMEZONE).localize(
        naive_dispatch_date
    )
    cp2 = Campaign(
        title="Test Campaign 2",
        message="Test campaign content 2",
        sender="TestUser",
        recipient_list=["<phone1>", "<phone2>", "<phone3>"],
        # The date will automatically be sent in iso format with the timezone data
        defer_until=aware_dispatch_date,
    )
    client.launch(cp2)
    # If you check the status one hour from now it should return 'COMPLETED'

    # create another scheduled campaign using defer_by
    cp3 = Campaign(
        title="Test Campaign 3",
        message="Test campaign content 3",
        sender="TestUser",
        recipient_list=["<phone1>", "<phone2>", "<phone3>"],
        defer_by=120,
    )
    client.launch(cp3)
    time.sleep(120)  # wait for 120 seconds for the campaign to proceed
    client.refresh(cp3)  # refresh your campaign data
    print(cp3.status)  # should output : COMPLETED
    # If you get a 'SCHEDULED' printed, you can wait 10 more seconds in case the network
    # is a little slow or the server is busy


if __name__ == "__main__":
    main()

Metadata

Release files for smsdrop-python 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 smsdrop-python 1.0.0
File Size Uploaded
smsdrop-python-1.0.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for smsdrop-python 1.0.0
File Interpreter ABI Platform
smsdrop_python-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / smsdrop-python-1.0.0.tar.gz

Download URL smsdrop-python-1.0.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ad714180c59392bd3a6835fa8d0b4aa99c5100c644e8232472cde292316ffa2a
BLAKE2b-256 checksum
How to use checksums
96f26898bb5329440c40b02e3075d14d203fad0b7314237cfbd64081c2fddadd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0

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

Download URL smsdrop_python-1.0.0-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c3a48abe87610f952659c08a674cef78efd09b46306d9831ff7721da47bd996
BLAKE2b-256 checksum
How to use checksums
3ab6875d993f2cce0e475c5385917ac810f6f8cadcc4948952ad4868cadcd73e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Darwin/21.4.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

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