Skip to main content

drin

Official Python SDK for the Drin transactional email API. Zero dependencies (standard library only), typed, Python 3.8+.

Install

pip install drin

Quick start

from drin import DrinClient

drin = DrinClient(api_key="drin_...")  # or os.environ["DRIN_API_KEY"]

res = drin.emails.send({
    "from": {"email": "you@send.drin.run", "name": "Acme"},
    "to": [{"email": "user@example.com"}],
    "subject": "Welcome",
    "html": "<h1>Welcome</h1>",
    "text": "Welcome",
})
print(res["id"], res["status"])

The client defaults to https://api.drin.run; override with base_url. Request bodies are plain dicts whose keys match the REST API; responses are parsed JSON.

Tenant-wide keys

A tenant-wide key must name the sender (its externalId):

drin = DrinClient(api_key, sender="customer_42")
# or per request:
drin.emails.send(body, sender="customer_42")

Idempotency

drin.emails.send(body, idempotency_key="order-1234")  # honored 24h, per sender

Pagination

Every list endpoint returns {"data": [...], "nextCursor": ...}. Use paginate(...) to walk every page lazily:

for message in drin.emails.paginate({"status": "delivered"}):
    print(message["id"])

Typed errors

from drin import DrinRateLimitError, DrinSuppressedError, DrinError

try:
    drin.emails.send(body)
except DrinRateLimitError as e:
    time.sleep(e.retry_after or 1)
except DrinSuppressedError:
    ...  # all recipients suppressed
except DrinError as e:
    print(e.type, e.status, e.code)

Webhook verification

Verify the Drin-Signature header on inbound webhooks. Pass the raw request body. Pure local check — no network call.

from drin import verify_webhook, DrinWebhookVerificationError

# e.g. in a Flask/Django/FastAPI handler:
raw_body = request.get_data(as_text=True)        # the exact bytes received
signature = request.headers["Drin-Signature"]

try:
    result = verify_webhook(raw_body, signature, signing_secret, tolerance_seconds=300)
    event = result.payload  # trusted only AFTER verification
except DrinWebhookVerificationError:
    abort(400)

Resources

drin.emails · drin.domains · drin.inboxes · drin.threads · drin.inbound · drin.webhooks · drin.suppressions · drin.api_keys · drin.metrics · drin.templates · drin.contacts · drin.forms — one method per /v1 endpoint.

A first-party TypeScript SDK is also available: npm install @drin/sdk.

License

MIT

Metadata

Release files for drin 0.1.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 drin 0.1.0
File Size Uploaded Provenance Actions
drin-0.1.0.tar.gz 19.0 kB Without provenance Details for drin-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for drin 0.1.0
File Interpreter ABI Platform Actions
drin-0.1.0-py3-none-any.whl Python 3 none any Details for drin-0.1.0-py3-none-any.whl

Total release size: 36.6 kB

Release files / drin-0.1.0.tar.gz

Download URL drin-0.1.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
def9d80a07407e2d3c89dac94ce2cb9324c33f64ce50269615c3eed69a3dad98
BLAKE2b-256 checksum
How to use checksums
379d8570250d2f03b115e53b1d6f00addbcc7f8e6cd131be25c6fd3e5362b5cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / drin-0.1.0-py3-none-any.whl

Download URL drin-0.1.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbe2eb6303baff6c1bcd5cc0510254615e1a6ce0c00be8d31ae0a69eb02ffbd3
BLAKE2b-256 checksum
How to use checksums
5f0f24f35bd6e7b0e6e288e26afbab17cd4f91bdf3b49046be4688085594b818
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for drin 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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