Fivexer

Python

The Python SDK (fivexer) supports Python 3.9+ and is the most complete SDK after the TypeScript reference.

Install

bash
pip install fivexer

Quickstart

python
from fivexer import Fivexer, CreateTask, UpsertWorker, ListDecisionsQuery

client = Fivexer(base_url="https://api.fivexer.com", api_key="sk_test_...")

client.workers.upsert(UpsertWorker(id="agent_1", tags=["english", "billing"]))
task = client.tasks.create(CreateTask(tags=["english", "billing"], priority=90))
print(task.id, task.status)

decisions = client.decisions.list(ListDecisionsQuery(task_id=task.id))

Async

python
from fivexer import AsyncFivexer

client = AsyncFivexer(base_url="https://api.fivexer.com", api_key="sk_test_...")
worker_id = await client.workers.upsert(UpsertWorker(id="agent_1", tags=["english"]))

Errors and quotas

python
from fivexer import FivexerApiError

try:
    client.tasks.create(CreateTask(tags=["english"]))
except FivexerApiError as e:
    print(e.status_code, e.code)
    print(e.retry_after)
    print(client.quota.task_rate_remaining)

Worker portal

python
from fivexer import FivexerWorker, WorkerLogin

worker = FivexerWorker(base_url="https://api.fivexer.com")
worker.login(WorkerLogin(workspace_id="ws_1", worker_id="agent_1", pin="4821"))
worker.accept(worker.queue().task_ids[0])

Webhooks

python
from fivexer import Webhook

event = Webhook.construct_event(
    payload=raw_body_bytes,
    header=request.headers["x-fivexer-signature"],
    secret="whsec_...",
)

Was this page helpful?