Skip to main content

Device2SMS Python SDK (End-to-End Encrypted SMS)

The official Python SDK for Device2SMS.

This SDK allows you to send SMS messages through your paired Android devices using end-to-end encryption (E2EE) powered by Google Tink.
Message content is encrypted before it leaves your application and is only decrypted on the paired Android device.


🚀 Features

  • 🔐 End-to-end encrypted SMS (E2EE)
  • 📱 Uses your own Android devices to send SMS
  • 🔑 Simple API-key authentication
  • ♻️ Idempotent message sending
  • 🧩 No key management required by the user
  • 🐍 Pythonic API with minimal dependencies

📦 Requirements

  • Python 3.11 or newer
  • A Device2SMS account
  • At least one paired Android device
  • An API key created in the Device2SMS dashboard

📥 Installation

pip install device2sms-sdk

Local development install

cd sdk/python
python -m venv .venv
.venv\Scripts\activate
pip install -e .

Linux / macOS

source .venv/bin/activate

Windows

.venv\Scripts\activate


🔑 Authentication

Create an API key in the Device2SMS dashboard and store it securely:

export DEVICE2SMS_API_KEY="your_api_key_here"

✉️ Sending an SMS (E2EE)

from device2sms_sdk import Device2SmsClient

client = Device2SmsClient(
    base_url="https://api.device2sms.ie",
    api_key="YOUR_API_KEY",
)

result = client.send_sms(
    to="+353000000000",
    message="Hello from Device2SMS!",
    idempotency_key="order-123"
)

print(result)

Response example

{
  "job_id": "f1d1b4e6-3c9a-4d6a-8b9e-1c8a9e2d1234",
  "status": "queued"
}

🔐 How End-to-End Encryption Works

  1. The SDK calls /v1/sms/prepare.
  2. The backend selects an online device and returns its public encryption key.
  3. The SDK encrypts the message locally using Google Tink.
  4. Only ciphertext is sent to the backend.
  5. The Android device decrypts the message and sends the SMS.

Plaintext message content is never transmitted to or stored by the Device2SMS backend. Only encrypted ciphertext and non-reversible message metadata are processed server-side.


🧪 Idempotency

To safely retry requests, pass an idempotency_key:

client.send_sms(
    to="+353000000000",
    message="Hello again",
    idempotency_key="order-123"
)

Repeated requests with the same key will not send duplicate messages.


⚠️ System Messages

Verification and test messages may be sent without E2EE for operational reasons. All user-initiated SMS messages sent via the SDK are always end-to-end encrypted.


🧯 Error Handling

All SDK errors raise Device2SmsError:

from device2sms_sdk import Device2SmsClient, Device2SmsError

try:
    client.send_sms(...)
except Device2SmsError as e:
    print("SMS failed:", e)

📚 Documentation & Support


🛡 Security Model Summary

Component Access to plaintext
Your application ✅ Yes
Device2SMS backend ❌ No
Android device ✅ Yes
Database / logs ❌ No

Metadata

Release files for device2sms-sdk 0.1.2

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

Source distribution (sdist)

Source distribution for device2sms-sdk 0.1.2
File Size Uploaded Provenance Actions
device2sms_sdk-0.1.2.tar.gz 5.9 kB Without provenance Details for device2sms_sdk-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for device2sms-sdk 0.1.2
File Interpreter ABI Platform Actions
device2sms_sdk-0.1.2-py3-none-any.whl Python 3 none any Details for device2sms_sdk-0.1.2-py3-none-any.whl

Total release size: 11.5 kB

Release files / device2sms_sdk-0.1.2.tar.gz

Download URL device2sms_sdk-0.1.2.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b451dfbca07c82da13437f0195265037e4221af3dc77169e4cec29b8cfd3e772
BLAKE2b-256 checksum
How to use checksums
0153a028cd410f74a3e9cc6cd58fef2e882e41f2603e86740997cdc7da4acf6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / device2sms_sdk-0.1.2-py3-none-any.whl

Download URL device2sms_sdk-0.1.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65dfd9b4bf35081fe94185265f7b44567b9e79d2e31536f0f0c0bef2381ce3ae
BLAKE2b-256 checksum
How to use checksums
d811aa0a7c519cdbba340f858f5bd9b083f0c1f3993b448560b419411246342c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for device2sms-sdk 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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