Python SDK for plop.email

The official Python SDK with sync and async clients, Pydantic models, and built-in polling. One line to wait for emails.

Python SDK Documentation

Features

Sync & Async Clients

Use Plop() for synchronous code or AsyncPlop() for async/await. Both share the same API surface.

Built-in Polling

Use wait_for() to poll for emails with configurable timeout and interval. No manual retry loops.

Pydantic Models

All responses are typed Pydantic models with full IDE autocomplete and validation.

pytest Ready

Drop-in pytest fixture included. One decorator to inject a plop client into any test.

Setup

# Install the SDK
pip install plop-sdk

# Set your API key
export PLOP_API_KEY=your_api_key

Wait for an Email

Initialize the client and wait for an email to arrive. One line replaces manual polling loops.

Wait for an Emailtypescript
from plop import Plop

client = Plop(api_key="your_api_key")

# Wait for the latest email (polls automatically)
message = client.wait_for(
    mailbox="qa",
    tag="signup",
    timeout=10.0,
)

# Pydantic model  full autocomplete
print(message.subject)
print(message.text_content)

# Extract OTP from email body
import re
otp = re.search(r"\b\d{6}\b", message.text_content or "")

Async Client & pytest Fixture

Use the async client for high-throughput scenarios and the built-in pytest fixture for testing.

Async Client & pytest Fixturetypescript
import pytest
from plop import AsyncPlop

# Async client for concurrent operations
async def check_emails():
    async with AsyncPlop(api_key="your_api_key") as client:
        messages = await client.messages.list(
            mailbox="qa",
            tag="password-reset",
            limit=5,
        )
        for msg in messages.data:
            print(f"{msg.subject} — {msg.sender}")


# pytest fixture  inject plop into any test
@pytest.fixture
def plop_client():
    return Plop(api_key=os.environ["PLOP_API_KEY"])


def test_welcome_email(plop_client):
    # Trigger your app to send an email...
    msg = plop_client.wait_for(
        mailbox="qa",
        tag="welcome",
        timeout=10.0,
    )
    assert "Welcome" in msg.subject
    assert "Get Started" in msg.text_content

Tips

  • Use wait_for() instead of time.sleep() loops — it handles retries and timeout
  • Use AsyncPlop for FastAPI, aiohttp, or any async Python framework
  • Set PLOP_API_KEY as an environment variable to avoid hardcoding secrets
  • Use the tag parameter to isolate emails per test for parallel execution
  • Use plop.messages.stream() for real-time SSE notifications instead of polling
  • Manage webhooks, mailboxes, and API keys with full CRUD methods

Start testing with Python SDK

Add email verification to your Python SDK tests in minutes.