Official Python SDK for GenieOS — sync + async clients, typed responses, idempotency-aware retries, webhook verification.
Project description
genieos — Python SDK
The official Python SDK for GenieOS. Sync and async clients, typed responses (Pydantic), automatic idempotency, retry-on-429/5xx with exponential back-off, and webhook signature verification.
Install
pip install genieos
Requires Python 3.9+ and httpx>=0.27, pydantic>=2.6.
Quickstart (sync)
from genieos import GenieOS
with GenieOS(api_key="gos_live_...") as mg:
ws = mg.workspace.get()
print(ws.name, "on", ws.plan)
send = mg.templates.send(
"welcome",
to="aki@example.com",
variables={"firstName": "Aki"},
)
print("queued:", send.id)
The API key is also picked up from the GENIEOS_API_KEY env var,
matching the Node SDK and CLI.
Quickstart (async)
import asyncio
from genieos import AsyncGenieOS
async def main():
async with AsyncGenieOS() as mg: # MAILGENIUS_API_KEY env var
await mg.events.emit(
"subscription.cancelled",
email="aki@example.com",
traits={"tier": "pro", "reason": "moving to weekly"},
)
asyncio.run(main())
Webhook verification (Flask)
from flask import Flask, request, abort
from genieos import verify_webhook, WebhookSignatureError
app = Flask(__name__)
@app.post("/genieos/webhook")
def webhook():
try:
delivery = verify_webhook(
request.get_data(as_text=True),
request.headers,
secret=os.environ["MAILGENIUS_WEBHOOK_SECRET"],
)
except WebhookSignatureError as e:
abort(400, str(e))
if delivery.type == "send.delivered":
... # handle it
return "", 204
verify_webhook rejects out-of-window timestamps (default ±5 min) and
performs constant-time signature comparison. The same module exposes
sign_webhook for local testing.
Error handling
from genieos import (
GenieOSRateLimitError,
GenieOSValidationError,
GenieOSAuthError,
)
try:
mg.events.emit("checkout.completed", email="aki@example.com")
except GenieOSRateLimitError as e:
time.sleep(e.retry_after_seconds)
except GenieOSValidationError as e:
log.warning("422: %s", e.body)
except GenieOSAuthError:
rotate_my_key()
All SDK errors inherit from GenieOSError and expose .code,
.status, .request_id, .body.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genieos-0.1.0.tar.gz.
File metadata
- Download URL: genieos-0.1.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2763396faf961a754d3f37dd0a65069735c231b5686ba2f217c4bf851cae3aab
|
|
| MD5 |
c464a2e1cd577be7368e65159d742fc2
|
|
| BLAKE2b-256 |
4cc42e206d3ffb3aebbbb75dfca3ba2df4997b112b4cc2116e2be678458a8a48
|
Provenance
The following attestation bundles were made for genieos-0.1.0.tar.gz:
Publisher:
release.yml on GenieOS-0/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genieos-0.1.0.tar.gz -
Subject digest:
2763396faf961a754d3f37dd0a65069735c231b5686ba2f217c4bf851cae3aab - Sigstore transparency entry: 1908846277
- Sigstore integration time:
-
Permalink:
GenieOS-0/sdk-python@892d6455cce5205aae70be589b6e9089b0ada6d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/GenieOS-0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@892d6455cce5205aae70be589b6e9089b0ada6d8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file genieos-0.1.0-py3-none-any.whl.
File metadata
- Download URL: genieos-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
337096a36f10b6185996b99fa403f53ca79e5d89b43c3602d87e6221d6324e53
|
|
| MD5 |
1bedc17b7c62f2f3f1bc438d07567466
|
|
| BLAKE2b-256 |
9b509c966bdb7aa662b2c063f41ca2540c803881fd261f24bd6378594c601840
|
Provenance
The following attestation bundles were made for genieos-0.1.0-py3-none-any.whl:
Publisher:
release.yml on GenieOS-0/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genieos-0.1.0-py3-none-any.whl -
Subject digest:
337096a36f10b6185996b99fa403f53ca79e5d89b43c3602d87e6221d6324e53 - Sigstore transparency entry: 1908846393
- Sigstore integration time:
-
Permalink:
GenieOS-0/sdk-python@892d6455cce5205aae70be589b6e9089b0ada6d8 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/GenieOS-0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@892d6455cce5205aae70be589b6e9089b0ada6d8 -
Trigger Event:
push
-
Statement type: