Skip to main content

inkrelay-sdk-python

Python client for the InkRelay cloud printing API.

Install

pip install inkrelay

The distribution is named inkrelay; the import package is inkrelay. Python 3.10 or newer.

Usage

from inkrelay import InkRelay

ir = InkRelay("ir_test_...")  # or set INKRELAY_API_KEY

job = ir.print_jobs.create_and_wait(
    {
        "printerId": "0192f1a0-7c00-7000-8000-0000000000bb",
        "title": "Invoice 1042",
        "contentType": "pdf_uri",
        "content": "https://example.com/invoice-1042.pdf",
    },
    timeout_s=60,
)
print(job["state"])

for printer in ir.printers.iterate(limit=100):
    print(printer["id"], printer["name"])

Resources: computers, printers, print_jobs and webhooks have list, iterate and get; events has list and iterate. print_jobs.create always sends an Idempotency-Key (a random one unless you pass idempotency_key=), so retries never print twice. The client retries 429 responses, and 5xx or network errors for replay safe requests, up to max_retries (default 3). Errors raise InkRelayError with status, code and request_id.

ir.raw is the generated, fully typed client (inkrelay._generated) sharing the same retrying connection:

from inkrelay._generated.api.account import get_whoami

who = get_whoami.sync(client=ir.raw)

Caveats: only the sync functions on ir.raw itself retry. ir.raw.with_headers(...) (and with_cookies, with_timeout) adds the change to the shared client but returns a copy that builds its own httpx client without retries, and the asyncio variants use a separate async client that does not retry.

Async

AsyncInkRelay has the same resources as InkRelay with awaitable methods; iterate is an async generator, and sleep (default asyncio.sleep) is awaited between retries and polls.

import asyncio
from inkrelay import AsyncInkRelay

async def main():
    async with AsyncInkRelay("ir_test_...") as ir:  # or call `await ir.aclose()`
        job = await ir.print_jobs.create_and_wait(
            {
                "printerId": "0192f1a0-7c00-7000-8000-0000000000bb",
                "title": "Invoice 1042",
                "contentType": "pdf_uri",
                "content": "https://example.com/invoice-1042.pdf",
            }
        )
        print(job["state"])
        async for printer in ir.printers.iterate(limit=100):
            print(printer["id"], printer["name"])

asyncio.run(main())

On the async client, ir.raw is bound to the same retrying async httpx client, so use the generated asyncio and asyncio_detailed functions with it (for example await get_whoami.asyncio(client=ir.raw)). The same copy caveat applies to with_headers, with_cookies and with_timeout.

Webhooks

Verify each request with the endpoint's signing secret before trusting it. Pass the raw body, not parsed JSON:

from inkrelay import WebhookVerificationError, webhooks

try:
    webhooks.verify(request.body, request.headers, "whsec_...")
except WebhookVerificationError:
    return 400

Rotate an endpoint's signing secret, optionally keeping the old one valid for overlap_seconds so receivers can switch, and send a test delivery:

endpoint = ir.webhooks.rotate_secret("0192f1a0-...", overlap_seconds=3600)
print(endpoint["secret"])  # the new secret, shown only once

delivery = ir.webhooks.ping("0192f1a0-...")  # queues a test delivery

Development

uv sync
uv run openapi-python-client generate --path openapi/openapi.json --config openapi-python-client.yml --meta none --output-path src/inkrelay/_generated --overwrite
uv run ruff check && uv run pytest
uv build

openapi/openapi.json is synced from inkrelay-api, and src/inkrelay/_generated is generated from it; do not edit either by hand. CI regenerates the client on every push and fails a pull request whose generated code is stale.

Releasing

Set version in pyproject.toml, merge, then push a matching tag (git tag v0.2.0 && git push origin v0.2.0). The release workflow checks that the tag matches the version, runs the tests, builds and publishes to PyPI through trusted publishing (GitHub environment pypi, PyPI project inkrelay).

License

MIT

Metadata

Release files for inkrelay 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inkrelay 0.3.0
File Size Uploaded Provenance
inkrelay-0.3.0.tar.gz 104.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for inkrelay 0.3.0
File Interpreter ABI Platform
inkrelay-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 231.1 kB

Release files / inkrelay-0.3.0.tar.gz

Download URL inkrelay-0.3.0.tar.gz
Size 104.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0a66b3573e71da0c523b2c5deb6831cdaef5ef709d9db6a6098915ce55d572f1
BLAKE2b-256 checksum
How to use checksums
7a8b3945383fca9c18cea04fff3f3507c5974952bb3f93faf7094799896d9cf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / inkrelay-0.3.0-py3-none-any.whl

Download URL inkrelay-0.3.0-py3-none-any.whl
Size 127.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ecae96dd52ecdd0e1c3028da05cdc1547d577ac771cb24dfef85c06ebf34b7
BLAKE2b-256 checksum
How to use checksums
f4fcd4f4f58746e3b624e98cdcb088c39ff151fb94834777fde7e4685b2a47e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Security for inkrelay 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for inkrelay-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page