🚀 New v3 API is now live! Faster, more secure, and robust. ⚡
Python SDK

Python SDK

Async-ready Python SDK with full type hints. Compatible with Python 3.8+.

Python 3.8+ pip Async Support

Installation

pip
pip install directsms

Basic Usage (Sync)

Synchronous
from directsms import Client

    # Initialize client
    client = Client("YOUR_API_TOKEN")

    # Get user info
    user = client.user.me()
    print(user.balance)

Async Usage

Asynchronous
import asyncio
    from directsms import AsyncClient

    async def main():
        client = AsyncClient("YOUR_API_TOKEN")

        # Create SMS activation
        activation = await client.sms.create(
            category_id=15,
            country="US"
        )
        print(activation.phone)

        # Wait for SMS code
        sms = await client.sms.wait_for_code(
            activation.id, 
            timeout=120
        )
        print(sms.code)

    asyncio.run(main())

Temp Mail

Email Operations
# Get available domains
    domains = client.temp_mail.domains()

    # Create temporary email
    email = client.temp_mail.create(domain_id=5)
    print(email.address)  # random@domain.com

    # Check messages
    messages = client.temp_mail.messages(email.id)
    for msg in messages:
        print(msg.subject, msg.body)

    # Extend duration
    client.temp_mail.extend(email.id)

    # Discard when done
    client.temp_mail.discard(email.id)

Resources