Python SDK
Install the arbiro package for Python 3.10+. Sync and async clients, idempotent retries, evidence upload, webhook verification and exact money helpers.
arbiro is the official Python client. Its only dependency is httpx. It has a synchronous client for scripts and Django, and an async one for FastAPI, Starlette and any asyncio code. Both have the same resources.
pip install arbiro
uv add arbiro
Client
import os
from arbiro import Arbiro
arbiro = Arbiro(api_key=os.environ["ARBIRO_API_KEY"]) # arb_test_... or arb_live_...
session = arbiro.checkout_sessions.create(
amount="49990000", # 49.99 USDC, in atomic units
token="USDC",
category="digital",
success_url="https://shop.example/thanks",
idempotency_key="order-1042",
)
print(session["hosted_url"])
import os
from arbiro import AsyncArbiro
async with AsyncArbiro(api_key=os.environ["ARBIRO_API_KEY"]) as arbiro:
session = await arbiro.checkout_sessions.create(
amount="49990000",
token="USDC",
category="digital",
success_url="https://shop.example/thanks",
)
Methods return the API's JSON as plain dicts and lists, exactly as documented in the API reference.
| Resource | Methods |
|---|---|
account |
retrieve |
payment_links |
create, list, retrieve |
checkout_sessions |
create |
payments |
list, retrieve, export_csv; iter_payments() on the client walks every page |
deliveries |
redeem_token |
disputes |
list, retrieve, list_evidence, create_evidence_upload, complete_evidence_upload, appeal; upload_evidence() on the client does all three steps |
webhook_endpoints |
create, list, disable, send_test, deliveries |
events |
list, retrieve, trigger (Test Mode), deliveries, resend |
Retries and errors
- Retries: every POST carries an
Idempotency-Key(a UUID unless you passidempotency_key), and retries reuse it. Network errors, 429 and 5xx are retried with exponential backoff, honouringRetry-After(max_retries=2by default). Retrying never creates a second object. - Errors: anything else raises
ArbiroErrorwithstatus, a stablecodeand therequest_id. Quote therequest_idto support, or find the request in Dashboard, Developers, Logs.
from arbiro import ArbiroError
try:
arbiro.payments.retrieve(payment_id)
except ArbiroError as error:
print(error.status, error.code, error.request_id)
Amounts
Amounts are strings of whole atomic units (6 decimals) and never floats: a float cannot hold 0.1 exactly. arbiro.money converts in both directions with Decimal and refuses floats.
from decimal import Decimal
from arbiro import money
money.to_atomic("49.99") # "49990000"
money.from_atomic("49990000") # Decimal("49.99")
money.to_atomic(49.99) # TypeError: never float
Webhooks
Verify the Arbiro-Signature header against the raw body, before parsing it. Signatures older than five minutes are rejected.
from fastapi import FastAPI, HTTPException, Request
from arbiro import WebhookSignatureError, webhooks
app = FastAPI()
@app.post("/arbiro")
async def arbiro_webhook(request: Request) -> dict[str, bool]:
body = await request.body() # the raw bytes
try:
event = webhooks.construct_event(SECRET, body, request.headers.get("Arbiro-Signature"))
except WebhookSignatureError:
raise HTTPException(status_code=400) from None
if event["type"] == "payment.locked":
... # fulfil the order
return {"received": True}
from django.http import HttpResponse, HttpResponseBadRequest
from django.views.decorators.csrf import csrf_exempt
from arbiro import WebhookSignatureError, webhooks
@csrf_exempt
def arbiro_webhook(request):
try:
event = webhooks.construct_event(SECRET, request.body, request.headers.get("Arbiro-Signature"))
except WebhookSignatureError:
return HttpResponseBadRequest()
...
return HttpResponse(status=200)
Evidence
upload_evidence declares the file (its size, type and SHA-256 are bound into a presigned URL), sends the bytes straight to storage and marks the upload complete so verification starts. Arbiro never sees the file through its API servers.
with open("delivery-note.pdf", "rb") as file:
item = arbiro.upload_evidence(
dispute_id, file_name="delivery-note.pdf", content_type="application/pdf", data=file.read()
)
Updated