Skip to main content

Device2SMS Python SDK (E2EE via Google Tink)

Project description

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

From PyPI (recommended)

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.com",
    api_key="YOUR_API_KEY",
)

result = client.send_sms(
    to="+000000000000",
    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.

At no point does Device2SMS store or log plaintext message content.


🧪 Idempotency

To safely retry requests, pass an idempotency_key:

client.send_sms(
    to="+000000000000",
    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

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

device2sms_sdk-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

device2sms_sdk-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file device2sms_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: device2sms_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for device2sms_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 14bb1edd301f4363334db9d22371ecd18d5a0a84ad3fc9898dfcf19fc05bebf3
MD5 7b721a44c80112b3e8c22e0d4410f04f
BLAKE2b-256 3e166c80927936ed07cbaffe4320cd06643441787407bf0f3f2fa453da1ffba9

See more details on using hashes here.

File details

Details for the file device2sms_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: device2sms_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for device2sms_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5de0187e6af0d5e30ac7c062326f2abc3f3300b18feab7be5154855edb545bf1
MD5 320bf8793f9b72ff060454e7e26b4e25
BLAKE2b-256 9c21e5be61123c3a708d20dae8781028929eeb3ccd90a1fa5cfb91707607532b

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