Metadata-Version: 2.5
Name: exx-sh
Version: 0.2.0
Summary: Python SDK for the exx.sh email API
Project-URL: Homepage, https://exx.sh
Project-URL: Source, https://github.com/souravsspace/exx.sh/tree/main/sdks/python
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: attrs>=23.1
Requires-Dist: httpx<1,>=0.27
Description-Content-Type: text/markdown

# exx-sh

Python SDK for the [exx.sh](https://exx.sh) email API (Python 3.11+), synchronous and
asyncio, plus SMTP.

```sh
pip install exx-sh
```

```python
from exx import Exx

exx = Exx()  # EXX_API_KEY
sent = exx.emails.send({
    "from": "Acme <hi@acme.com>",
    "to": "user@example.com",
    "subject": "Hello",
    "html": "<p>It works.</p>",
})
print(sent.id)
```

`AsyncExx` has the same methods as coroutines (`async with AsyncExx() as exx: ...`).
API errors raise `exx.ExxError` with `name` (the API's error name, for server errors too),
`message` and `status_code`. An answer that is not the API's (a proxy's HTML page) is
`application_error` with its status; no answer at all is `application_error` with
`status_code` `None`.

- Resources: `emails` (send, get, list, update, cancel, attempts, transcript),
  `batch.send`, `domains`, `api_keys`, `webhooks`, `suppressions`. Sends take
  `idempotency_key=` and `stream=` (`"transactional"` or `"distributional"`).
- Options: `Exx(api_key=None, *, base_url=None, retries=2, timeout=30.0)`; `timeout` applies
  to each phase of an attempt (connect, read, write).
- Retries: 429 except a spent quota; 5xx and lost answers when a replay cannot act twice
  (every request but a POST without an `Idempotency-Key`; sends get one
  made for you while retries are on); `409 concurrent_idempotent_requests` while the
  server still runs a keyed send.
- Answers are typed models (`exx.models`).

## SMTP

```python
from exx import ExxSmtp

smtp = ExxSmtp()  # EXX_API_KEY; smtp.exx.sh:465, TLS
sent = smtp.send({"from": "hi@acme.com", "to": "user@example.com", "subject": "Hi", "text": "hi"})
print(sent.id)  # the same id the API and webhooks use
```

`ExxSmtp(api_key=None, *, host=None, port=None, timeout=30.0, ssl_context=None,
implicit_tls=None)` (defaults `EXX_SMTP_HOST`, `EXX_SMTP_PORT`). Port 465 is TLS from the
start, any other port STARTTLS; a refusal raises `exx.SmtpError` with `smtp_code`. Tags,
scheduling and attachment paths need the API.

## Webhooks

```python
from exx import verify_webhook

event = verify_webhook(request.body, request.headers, secret)
```

Docs: https://docs.exx.sh/sdks/python. MIT licensed.
