SDK

Python SDK

Send Cuitty events from Python — sync or async, with built-in batching and HMAC signing.

Python SDK

Status: Preview. The Python SDK is on the Phase 3 roadmap. Until it ships you can use the wire protocol directly — every Python HTTP client supports the small surface area required.

Planned API

from cuitty import Client

c = Client(
    portal_url="https://app.cuitty.com",
    project_id=PROJECT_ID,
    api_key=API_KEY,
)

c.audit(
    actor="alice@example.com",
    action="secret.rotate",
    resource="stripe.live_key",
)

c.flush()

Wire-protocol equivalent today

import hmac, hashlib, json, os, time
import urllib.request

body = json.dumps({
    "events": [{
        "type": "audit",
        "ts": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
        "data": {"actor": "alice@example.com",
                 "action": "secret.rotate",
                 "resource": "stripe.live_key"},
    }],
}).encode()

sig = hmac.new(os.environ["CUITTY_WEBHOOK_SECRET"].encode(),
               body, hashlib.sha256).hexdigest()

req = urllib.request.Request(
    "https://app.cuitty.com/api/ingest",
    data=body,
    headers={
        "Authorization": f"Bearer {os.environ['CUITTY_API_KEY']}",
        "Content-Type": "application/json",
        "X-Cuitty-Signature": sig,
    },
)
print(urllib.request.urlopen(req).read())

Live performance numbers

See live benchmarks at https://benchmarks.cuitty.com/sdks/python.

See also