SDKs
Python SDK
Install dimmi-sdk to call the REST API (sync or async), paginate lists, sign identity tokens, and verify webhooks.
dimmi-sdk requires Python 3.10 or later and imports as dimmi.
pip install dimmi-sdkCreate a client and make a call
Section titled “Create a client and make a call”import os
from dimmi import Dimmi, DimmiError, ValidationError
client = Dimmi(token=os.environ["DIMMI_API_TOKEN"])
try: contact = client.post("/contacts", json={"email": "ada@example.com", "name": "Ada Lovelace"})["data"] print(contact["id"])except ValidationError as error: print(error.fields)except DimmiError as error: print(error.status, error.code, error.message)
for conversation in client.paginate("/conversations", {"filter[status]": "open"}): print(conversation["id"])Set DIMMI_API_TOKEN (or DIMMI_TOKEN) to your API token. Dimmi() reads those environment variables automatically if you omit token=. When self-hosting, pass base_url= or set DIMMI_BASE_URL.
Ways to call the API
Section titled “Ways to call the API”- HTTP helpers:
client.get,post,put,patch,delete, andrequest(method, path)accept any path from the API reference and return decoded JSON. - Pagination:
client.paginate()iterates cursor-paginated lists (meta.next_cursor), andclient.pages()iterates page-numbered lists. Both request 100 items per page unless you setlimit. - Async support: use
async with AsyncDimmi() as client:for async/await code with the same methods. - Generated modules:
dimmi._generated.api.defaultexposes one typed module per operation ID (such asconversations_index.sync(client=client.api)).
Exceptions
Section titled “Exceptions”Every exception inherits from DimmiError with status, code, message, and fields:
| HTTP status | Exception |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 409 | ConflictError |
| 422 | ValidationError |
| 429 | RateLimitError (includes retry_after in seconds) |
| 500+ | ServerError |
Retries and idempotency
Section titled “Retries and idempotency”Dimmi() argument |
Default | What it does |
|---|---|---|
max_retries |
3 |
Retries on 429, 503, or connection errors. |
max_retry_wait |
60.0 |
Max retry delay in seconds (honors Retry-After). |
timeout |
30.0 |
Per-attempt timeout in seconds. |
Every POST automatically sends an Idempotency-Key and reuses it across retries. Pass idempotency_key= to client.post() to set your own.
Webhooks and identity tokens
Section titled “Webhooks and identity tokens”Use dimmi.Webhook to check webhook signatures (see Verify webhook signatures) and dimmi.sign_identity_token() to sign JWTs for identity verification.