Python SDK
tigby for PyPI, generated from the API contract with synchronous and asynchronous clients.
The package is not on PyPI yet; this is the command once it is:
pip install tigby # or: uv add tigbyUntil the package is published, call the API over HTTPS using the API reference. It describes the same endpoints as this package.
Generated from the OpenAPI document, which is itself generated from the running API; the package cannot describe an endpoint the API does not have.
Use it
The examples use orderbot, a reserved example Handle. Replace it with your own available Handle before creating an Identity.
import os
from tigby import TigbyError, create_client
from tigby.api_client.api.identities import create_identity, list_identities
from tigby.api_client.models import CreateIdentityRequest, IdentityResponse
client = create_client(api_key=os.environ["TIGBY_API_KEY"])
created = create_identity.sync(client=client, body=CreateIdentityRequest(handle="orderbot"))
assert isinstance(created, IdentityResponse) # for a type checker; see below
print(created.saga.status) # provisioning has startedThe assert is there for a type checker, not for the running code: every generated function is annotated to return Problem | None beside its answer, though this client raises a TigbyError rather than return a problem and raises on a status the API does not document rather than return None.
create_async_client gives the same client for the awaitable half of every operation (asyncio,
asyncio_detailed). Both default to https://api.tigby.eu; pass base_url="http://localhost:8080"
for a dev stack. Both clients allow 10 seconds to connect and 60 seconds without progress for each
read, write, or wait for a pooled connection. These limits apply per step, so an active download is
not interrupted. Pass timeout=httpx.Timeout(…) to change them.
The key is optional, and the credential goes on per operation rather than onto every request. The operations tigby.PUBLIC_OPERATIONS lists take none, and one of them is how a key is obtained:
import time
from tigby import TigbyError, create_client
from tigby.api_client.api.auth import poll_device_authorization, start_device_authorization
from tigby.api_client.models import DeviceTokenRequest, DeviceTokenResponse, StartDeviceRequest, StartDeviceResponse
anonymous = create_client()
started = start_device_authorization.sync(client=anonymous, body=StartDeviceRequest(name="laptop", client="cli"))
assert isinstance(started, StartDeviceResponse)
print(started.user_code) # confirm this at started.verification_uri
interval = max(1, started.interval_seconds)
while True:
time.sleep(interval)
try:
issued = poll_device_authorization.sync(
client=anonymous, body=DeviceTokenRequest(device_code=started.device_code)
)
break
except TigbyError as error:
if error.code == "slow_down": # the API asking for more room
interval += 1
elif error.code != "authorization_pending":
raise # denied, expired, used or invalid: the flow is over
assert isinstance(issued, DeviceTokenResponse)
print(issued.key) # the Admin Key, shown onceThe poll is a loop because the API answers 200 only on the first poll after the person confirms, and refuses with authorization_pending until then. Poll at started.interval_seconds; started.expires_at is when the code stops being good.
Errors
Every refusal raises TigbyError: the RFC 9457 problem with its Tigby members:
try:
create_identity.sync(client=client, body=CreateIdentityRequest(handle="orderbot"))
except TigbyError as error:
error.code # "handle_taken" – stable, branch on it
error.agent_hint # what to do instead
error.doc_url # where a human reads moreRequest bodies are limited to 1 MiB (1,048,576 bytes), measured as sent. Editing an A2A Card with PATCH /api/identities/{handle}/card permits 2 MiB (2,097,152 bytes), enough for a card with every field at its maximum length.
Larger requests receive status 413 and request_body_too_large before processing. Nothing changes. Reduce the request size before retrying.
Mail sending uses the same 1 MiB limit for the subject, text and HTML together. Larger requests receive status 413 and send no mail.