Skip to main content
The Python SDK is published on PyPI as inkrelay and imported as inkrelay. It offers the same helpers as the TypeScript SDK: retries with backoff, automatic idempotency keys, pagination iterators, webhook verification and create_and_wait.
Responses are plain dictionaries with the same camelCase keys as the API. create_and_wait creates the job and polls until it reaches done, error, cancelled or expired, then returns it. Check job["state"] and job["stateMessage"] rather than expecting an exception for a failed print.

Configuration

The constructor raises ValueError when neither api_key nor INKRELAY_API_KEY is set. The SDK retries 429 responses (waiting for Retry-After when present), and retries 5xx responses and network errors with exponential backoff, but only for replay-safe requests: GET, PATCH, DELETE, and print job creation (which carries an idempotency key). Other POST requests are not retried on 5xx errors. print_jobs.create and create_and_wait send an Idempotency-Key automatically and reuse it on every retry. Pass idempotency_key="..." to create to use your own key.

Errors

A non-2xx response that survives the retries raises InkRelayError with status, code and request_id. create_and_wait raises InkRelayTimeoutError when the job is still not in a final state after timeout_s seconds (default 60); its job attribute holds the last known job.
See Errors for the codes the API returns.

Pagination

list(**params) returns one page as {"data": [...], "hasMore": ..., "nextCursor": ...}. iterate(**params) follows nextCursor for you and yields every item:
computers, printers, print_jobs and webhooks have list, iterate and get. events (and webhook deliveries) have list and iterate only, with no get. Pass after and dir="asc" to events.list to poll for new events.

Webhooks

inkrelay.webhooks.verify(body, headers, secret) checks the signature of a request and raises WebhookVerificationError if it is invalid or older than 5 minutes. Pass the raw body, not parsed JSON.
The client also manages endpoints: ir.webhooks.create, update, delete, deliveries(id) and replay(delivery_id). create returns the signing secret once. See Webhooks for a full receiver.

Rotate a secret and send a test event

From version 0.3.0, rotate_secret replaces the signing secret and ping queues a test delivery:
overlap_seconds is how long the old secret keeps signing, from 0 to 604800; leave it out for the default of 24 hours. See Rotate the secret.

Async client

From version 0.3.0, AsyncInkRelay is an async client with the same resources and options as InkRelay. Use it as an async context manager, await single calls and use async for over iterate():

Generated client

The convenience methods sit on top of a client generated from the OpenAPI spec. ir.raw is that client, already configured with your key, base URL and the retrying transport. Use it for an endpoint the wrapper has no helper for.