delivrie 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
delivrie-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 South Circle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: delivrie
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Delivrie: send transactional email, broadcasts and automations, and verify webhooks.
5
+ Author-email: South Circle <support@delivrie.io>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://delivrie.io
8
+ Project-URL: Documentation, https://delivrie.io/docs/python
9
+ Project-URL: Source, https://github.com/codeddesigner/delivrie/tree/main/sdk/python
10
+ Project-URL: Changelog, https://delivrie.io/changelog
11
+ Keywords: email,transactional email,email api,smtp,webhooks,delivrie,resend alternative
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Communications :: Email
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Delivrie for Python
25
+
26
+ The official Python SDK for [Delivrie](https://delivrie.io), the email API for transactional email, broadcasts, automations and a shared inbox.
27
+
28
+ - No dependencies: the standard library only
29
+ - Python 3.10+, sync and async (`AsyncDelivrie`)
30
+ - Safe retries: rate limits, server errors and network errors are retried, and sends only with an idempotency key, so an email is never sent twice
31
+ - Webhook signature verification built in
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ pip install delivrie
37
+ ```
38
+
39
+ ## Send an email
40
+
41
+ Create an API key at [delivrie.io/api-keys](https://delivrie.io/api-keys) and set it as `DELIVRIE_API_KEY`.
42
+
43
+ ```python
44
+ from delivrie import Delivrie
45
+
46
+ client = Delivrie() # reads DELIVRIE_API_KEY
47
+
48
+ email = client.emails.send(
49
+ from_="Acme <hello@mail.acme.com>",
50
+ to="ada@example.com",
51
+ subject="Welcome to Acme",
52
+ html="<p>Thanks for signing up.</p>",
53
+ idempotency_key="welcome-ada",
54
+ )
55
+ print(email["id"])
56
+ ```
57
+
58
+ `from` is a Python keyword, so pass `from_`, or send a dict exactly like the REST API:
59
+
60
+ ```python
61
+ client.emails.send({"from": "Acme <hello@mail.acme.com>", "to": ["ada@example.com"], "subject": "Hi", "text": "Hello"})
62
+ ```
63
+
64
+ Python values are converted for you: `datetime` for `scheduled_at`, `bytes` for attachment content, and a dict for `tags`.
65
+
66
+ ```python
67
+ from datetime import datetime, timedelta, timezone
68
+
69
+ client.emails.send(
70
+ from_="Acme <billing@mail.acme.com>",
71
+ to="ada@example.com",
72
+ subject="Your invoice",
73
+ html="<p>Attached.</p>",
74
+ attachments=[{"filename": "invoice.pdf", "content": open("invoice.pdf", "rb").read()}],
75
+ tags={"category": "invoice"},
76
+ scheduled_at=datetime.now(timezone.utc) + timedelta(hours=1),
77
+ )
78
+ ```
79
+
80
+ ### Templates
81
+
82
+ ```python
83
+ client.emails.send(
84
+ from_="Acme <hello@mail.acme.com>",
85
+ to="ada@example.com",
86
+ template={"id": "welcome", "variables": {"first_name": "Ada"}},
87
+ )
88
+ ```
89
+
90
+ ### Batch
91
+
92
+ ```python
93
+ client.emails.batch([
94
+ {"from": "Acme <hello@mail.acme.com>", "to": "ada@example.com", "subject": "Hi Ada", "text": "Hello"},
95
+ {"from": "Acme <hello@mail.acme.com>", "to": "tobi@example.com", "subject": "Hi Tobi", "text": "Hello"},
96
+ ], idempotency_key="digest-2026-11-14")
97
+ ```
98
+
99
+ ## Errors
100
+
101
+ Methods return the API's JSON as a dict and raise `DelivrieError` when something goes wrong:
102
+
103
+ ```python
104
+ from delivrie import DelivrieError
105
+
106
+ try:
107
+ client.emails.send(from_="Acme <hello@mail.acme.com>", to="ada@example.com", subject="Hi", text="Hello")
108
+ except DelivrieError as e:
109
+ print(e.status_code, e.name, e.message) # 422 validation_error The from domain ... is not verified yet
110
+ ```
111
+
112
+ `status_code` is `0` for problems that never reached the API (`network_error` or `timeout`). Every error name is listed at [delivrie.io/docs/errors](https://delivrie.io/docs/errors).
113
+
114
+ ## Async
115
+
116
+ ```python
117
+ from delivrie import AsyncDelivrie
118
+
119
+ client = AsyncDelivrie()
120
+
121
+ @app.post("/signup")
122
+ async def signup(email: str):
123
+ await client.emails.send(from_="Acme <hello@mail.acme.com>", to=email, subject="Welcome", text="Hi!",
124
+ idempotency_key=f"welcome-{email}")
125
+ ```
126
+
127
+ ## Webhooks
128
+
129
+ Verify the signature with the raw body, before parsing it:
130
+
131
+ ```python
132
+ import os
133
+ from delivrie import verify_webhook, WebhookVerificationError
134
+
135
+ # Flask
136
+ @app.post("/webhooks/delivrie")
137
+ def delivrie_webhook():
138
+ try:
139
+ event = verify_webhook(request.get_data(), request.headers, os.environ["DELIVRIE_WEBHOOK_SECRET"])
140
+ except WebhookVerificationError:
141
+ return "", 400
142
+ if event["type"] == "email.bounced":
143
+ ...
144
+ return "", 204
145
+ ```
146
+
147
+ In Django, pass `request.body` and `request.headers`; in FastAPI, `await request.body()` and `request.headers`.
148
+
149
+ ## Everything else
150
+
151
+ The client covers the whole API with the same names as the [Node.js SDK](https://www.npmjs.com/package/delivrie), in snake_case:
152
+
153
+ | | |
154
+ | --- | --- |
155
+ | `client.emails` | `send`, `batch`, `get`, `list`, `list_received`, `update`, `cancel`, `forward` |
156
+ | `client.domains` | `create`, `get`, `verify`, `update`, `list`, `remove` |
157
+ | `client.api_keys` | `create`, `list`, `remove` |
158
+ | `client.webhooks` | `create`, `list`, `deliveries`, `test`, `replay`, `verify` |
159
+ | `client.contacts` | `create`, `get`, `update`, `list`, `remove` |
160
+ | `client.segments` | `create`, `list`, `remove`, `add_contacts` |
161
+ | `client.broadcasts` | `create`, `get`, `list`, `send`, `cancel`, `recipients`, `remove` |
162
+ | `client.templates` | `create`, `get`, `list`, `publish` |
163
+ | `client.suppressions` | `add`, `list`, `remove` |
164
+ | `client.events` | `send`, `list` |
165
+ | `client.automations` | `list`, `get`, `create`, `runs`, `publish`, `pause`, `resume` |
166
+ | `client.inbox.threads` | `list`, `get`, `update`, `reply` |
167
+ | `client.topics`, `client.contact_properties`, `client.inbox.labels` | `list` |
168
+ | `client.metrics`, `client.usage` | `get` |
169
+ | `client.logs` | `list`, `get` |
170
+
171
+ For anything else, `client.request("GET", "/path")` calls the API directly.
172
+
173
+ ## Options
174
+
175
+ ```python
176
+ Delivrie(
177
+ api_key="dlv_...", # default: DELIVRIE_API_KEY
178
+ base_url="https://...", # default: https://delivrie.io/api (or DELIVRIE_BASE_URL)
179
+ timeout=30, # seconds per request
180
+ max_retries=2,
181
+ headers={"X-Request-Source": "billing-service"},
182
+ )
183
+ ```
184
+
185
+ ## Links
186
+
187
+ - [Python guide](https://delivrie.io/docs/python)
188
+ - [API reference](https://delivrie.io/docs/api)
189
+ - [Test addresses](https://delivrie.io/docs/test-mode): send to `delivered@test.delivrie.io` while developing
190
+
191
+ MIT licensed.
@@ -0,0 +1,168 @@
1
+ # Delivrie for Python
2
+
3
+ The official Python SDK for [Delivrie](https://delivrie.io), the email API for transactional email, broadcasts, automations and a shared inbox.
4
+
5
+ - No dependencies: the standard library only
6
+ - Python 3.10+, sync and async (`AsyncDelivrie`)
7
+ - Safe retries: rate limits, server errors and network errors are retried, and sends only with an idempotency key, so an email is never sent twice
8
+ - Webhook signature verification built in
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install delivrie
14
+ ```
15
+
16
+ ## Send an email
17
+
18
+ Create an API key at [delivrie.io/api-keys](https://delivrie.io/api-keys) and set it as `DELIVRIE_API_KEY`.
19
+
20
+ ```python
21
+ from delivrie import Delivrie
22
+
23
+ client = Delivrie() # reads DELIVRIE_API_KEY
24
+
25
+ email = client.emails.send(
26
+ from_="Acme <hello@mail.acme.com>",
27
+ to="ada@example.com",
28
+ subject="Welcome to Acme",
29
+ html="<p>Thanks for signing up.</p>",
30
+ idempotency_key="welcome-ada",
31
+ )
32
+ print(email["id"])
33
+ ```
34
+
35
+ `from` is a Python keyword, so pass `from_`, or send a dict exactly like the REST API:
36
+
37
+ ```python
38
+ client.emails.send({"from": "Acme <hello@mail.acme.com>", "to": ["ada@example.com"], "subject": "Hi", "text": "Hello"})
39
+ ```
40
+
41
+ Python values are converted for you: `datetime` for `scheduled_at`, `bytes` for attachment content, and a dict for `tags`.
42
+
43
+ ```python
44
+ from datetime import datetime, timedelta, timezone
45
+
46
+ client.emails.send(
47
+ from_="Acme <billing@mail.acme.com>",
48
+ to="ada@example.com",
49
+ subject="Your invoice",
50
+ html="<p>Attached.</p>",
51
+ attachments=[{"filename": "invoice.pdf", "content": open("invoice.pdf", "rb").read()}],
52
+ tags={"category": "invoice"},
53
+ scheduled_at=datetime.now(timezone.utc) + timedelta(hours=1),
54
+ )
55
+ ```
56
+
57
+ ### Templates
58
+
59
+ ```python
60
+ client.emails.send(
61
+ from_="Acme <hello@mail.acme.com>",
62
+ to="ada@example.com",
63
+ template={"id": "welcome", "variables": {"first_name": "Ada"}},
64
+ )
65
+ ```
66
+
67
+ ### Batch
68
+
69
+ ```python
70
+ client.emails.batch([
71
+ {"from": "Acme <hello@mail.acme.com>", "to": "ada@example.com", "subject": "Hi Ada", "text": "Hello"},
72
+ {"from": "Acme <hello@mail.acme.com>", "to": "tobi@example.com", "subject": "Hi Tobi", "text": "Hello"},
73
+ ], idempotency_key="digest-2026-11-14")
74
+ ```
75
+
76
+ ## Errors
77
+
78
+ Methods return the API's JSON as a dict and raise `DelivrieError` when something goes wrong:
79
+
80
+ ```python
81
+ from delivrie import DelivrieError
82
+
83
+ try:
84
+ client.emails.send(from_="Acme <hello@mail.acme.com>", to="ada@example.com", subject="Hi", text="Hello")
85
+ except DelivrieError as e:
86
+ print(e.status_code, e.name, e.message) # 422 validation_error The from domain ... is not verified yet
87
+ ```
88
+
89
+ `status_code` is `0` for problems that never reached the API (`network_error` or `timeout`). Every error name is listed at [delivrie.io/docs/errors](https://delivrie.io/docs/errors).
90
+
91
+ ## Async
92
+
93
+ ```python
94
+ from delivrie import AsyncDelivrie
95
+
96
+ client = AsyncDelivrie()
97
+
98
+ @app.post("/signup")
99
+ async def signup(email: str):
100
+ await client.emails.send(from_="Acme <hello@mail.acme.com>", to=email, subject="Welcome", text="Hi!",
101
+ idempotency_key=f"welcome-{email}")
102
+ ```
103
+
104
+ ## Webhooks
105
+
106
+ Verify the signature with the raw body, before parsing it:
107
+
108
+ ```python
109
+ import os
110
+ from delivrie import verify_webhook, WebhookVerificationError
111
+
112
+ # Flask
113
+ @app.post("/webhooks/delivrie")
114
+ def delivrie_webhook():
115
+ try:
116
+ event = verify_webhook(request.get_data(), request.headers, os.environ["DELIVRIE_WEBHOOK_SECRET"])
117
+ except WebhookVerificationError:
118
+ return "", 400
119
+ if event["type"] == "email.bounced":
120
+ ...
121
+ return "", 204
122
+ ```
123
+
124
+ In Django, pass `request.body` and `request.headers`; in FastAPI, `await request.body()` and `request.headers`.
125
+
126
+ ## Everything else
127
+
128
+ The client covers the whole API with the same names as the [Node.js SDK](https://www.npmjs.com/package/delivrie), in snake_case:
129
+
130
+ | | |
131
+ | --- | --- |
132
+ | `client.emails` | `send`, `batch`, `get`, `list`, `list_received`, `update`, `cancel`, `forward` |
133
+ | `client.domains` | `create`, `get`, `verify`, `update`, `list`, `remove` |
134
+ | `client.api_keys` | `create`, `list`, `remove` |
135
+ | `client.webhooks` | `create`, `list`, `deliveries`, `test`, `replay`, `verify` |
136
+ | `client.contacts` | `create`, `get`, `update`, `list`, `remove` |
137
+ | `client.segments` | `create`, `list`, `remove`, `add_contacts` |
138
+ | `client.broadcasts` | `create`, `get`, `list`, `send`, `cancel`, `recipients`, `remove` |
139
+ | `client.templates` | `create`, `get`, `list`, `publish` |
140
+ | `client.suppressions` | `add`, `list`, `remove` |
141
+ | `client.events` | `send`, `list` |
142
+ | `client.automations` | `list`, `get`, `create`, `runs`, `publish`, `pause`, `resume` |
143
+ | `client.inbox.threads` | `list`, `get`, `update`, `reply` |
144
+ | `client.topics`, `client.contact_properties`, `client.inbox.labels` | `list` |
145
+ | `client.metrics`, `client.usage` | `get` |
146
+ | `client.logs` | `list`, `get` |
147
+
148
+ For anything else, `client.request("GET", "/path")` calls the API directly.
149
+
150
+ ## Options
151
+
152
+ ```python
153
+ Delivrie(
154
+ api_key="dlv_...", # default: DELIVRIE_API_KEY
155
+ base_url="https://...", # default: https://delivrie.io/api (or DELIVRIE_BASE_URL)
156
+ timeout=30, # seconds per request
157
+ max_retries=2,
158
+ headers={"X-Request-Source": "billing-service"},
159
+ )
160
+ ```
161
+
162
+ ## Links
163
+
164
+ - [Python guide](https://delivrie.io/docs/python)
165
+ - [API reference](https://delivrie.io/docs/api)
166
+ - [Test addresses](https://delivrie.io/docs/test-mode): send to `delivered@test.delivrie.io` while developing
167
+
168
+ MIT licensed.
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "delivrie"
7
+ dynamic = ["version"]
8
+ description = "Official Python SDK for Delivrie: send transactional email, broadcasts and automations, and verify webhooks."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "South Circle", email = "support@delivrie.io" }]
14
+ keywords = ["email", "transactional email", "email api", "smtp", "webhooks", "delivrie", "resend alternative"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Topic :: Communications :: Email",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = []
25
+
26
+ [project.urls]
27
+ Homepage = "https://delivrie.io"
28
+ Documentation = "https://delivrie.io/docs/python"
29
+ Source = "https://github.com/codeddesigner/delivrie/tree/main/sdk/python"
30
+ Changelog = "https://delivrie.io/changelog"
31
+
32
+ [tool.setuptools.dynamic]
33
+ version = { attr = "delivrie._version.__version__" }
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
37
+
38
+ [tool.setuptools.package-data]
39
+ delivrie = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """Official Python SDK for Delivrie, the email API. https://delivrie.io/docs/python"""
2
+ from ._async import AsyncDelivrie
3
+ from ._client import Delivrie
4
+ from ._errors import DelivrieError, WebhookVerificationError
5
+ from ._version import __version__
6
+ from ._webhooks import verify_webhook
7
+
8
+ __all__ = ["Delivrie", "AsyncDelivrie", "DelivrieError", "WebhookVerificationError", "verify_webhook", "__version__"]
@@ -0,0 +1,44 @@
1
+ """AsyncDelivrie: the same API for asyncio apps (FastAPI, aiohttp, Django async views).
2
+
3
+ Each call runs the standard-library client in a worker thread, so it never blocks the event loop and the package
4
+ stays dependency-free.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import asyncio
9
+ import functools
10
+ from typing import Any
11
+
12
+ from ._client import Delivrie
13
+
14
+
15
+ class _AsyncProxy:
16
+ def __init__(self, target: Any) -> None:
17
+ self._target = target
18
+
19
+ def __getattr__(self, name: str) -> Any:
20
+ attr = getattr(self._target, name)
21
+ if callable(attr):
22
+ @functools.wraps(attr)
23
+ async def call(*args: Any, **kwargs: Any) -> Any:
24
+ return await asyncio.to_thread(attr, *args, **kwargs)
25
+ return call
26
+ if name.startswith("_") or isinstance(attr, (str, int, float, bool, type(None))):
27
+ return attr
28
+ return _AsyncProxy(attr)
29
+
30
+ def __repr__(self) -> str:
31
+ return f"Async{self._target!r}"
32
+
33
+
34
+ class AsyncDelivrie(_AsyncProxy):
35
+ """
36
+ from delivrie import AsyncDelivrie
37
+
38
+ client = AsyncDelivrie()
39
+ email = await client.emails.send(from_="Acme <hello@mail.acme.com>", to="ada@example.com",
40
+ subject="Welcome", html="<p>Hi</p>")
41
+ """
42
+
43
+ def __init__(self, api_key: Any = None, **options: Any) -> None:
44
+ super().__init__(Delivrie(api_key, **options))