Skip to main content

Official Python SDK for the a11yfy PDF accessibility remediation API

Project description

a11yfy Python SDK

Official Python SDK for the a11yfy PDF accessibility remediation API. Upload a PDF, get back a PDF/UA-compliant, screen-reader-friendly document — with a verifiable compliance certificate.

Installation

pip install a11yfy

Requires Python 3.10+.

Quickstart

from a11yfy import A11yfy

client = A11yfy(token="ak_live_...")  # or set A11YFY_API_KEY env var

result = client.remediate("document.pdf")   # upload + poll + result, one call
print(result.output_url)                    # presigned URL of the remediated PDF
if result.certificate:
    print(result.certificate.download_url)  # compliance certificate PDF
    print(result.certificate.verify_url)    # public verification page

remediate() raises JobFailedError when the job fails and RemediationTimeoutError when the wait budget (default 30 min) elapses — the job keeps running server-side and can still be polled.

Low-level API

job = client.jobs.create_job(file=("doc.pdf", pdf_bytes))
status = client.jobs.get_job(job.job_id)             # pending|processing|done|failed|partial
result = client.jobs.get_job_result(job.job_id)

page = client.jobs.list_jobs(limit=50)               # newest first, cursor pagination
more = client.jobs.list_jobs(cursor=page.next_cursor)

certs = client.certificates.find_certificates(job_id=job.job_id)
certs = client.certificates.find_certificates(output_sha256="<sha256-of-output-pdf>")
pdf_bytes = b"".join(client.certificates.download_certificate(certs.certificates[0].certificate_id))

balance = client.billing.get_balance()
usage = client.billing.get_usage()

Async

from a11yfy import AsyncA11yfy

client = AsyncA11yfy(token="ak_live_...")
result = await client.remediate("document.pdf")

Webhooks

Pass webhook_url to get an HMAC-signed callback when the job finishes, then verify it with the Stripe-style helper:

from a11yfy import Webhook, WebhookVerificationError

@app.post("/a11yfy-webhook")
def handle(request):
    try:
        event = Webhook.construct_event(
            payload=request.body,                                # RAW bytes!
            signature_header=request.headers["X-A11yfy-Signature"],
            secret=os.environ["A11YFY_WEBHOOK_SECRET"],
        )
    except WebhookVerificationError:
        return Response(status=400)
    if event.is_success:
        download(event.output_url)
    return Response(status=200)

Configuration

Option Default Notes
token A11YFY_API_KEY env var ak_live_... / ak_test_...
base_url https://a11yfy.com override for sandbox environments
timeout 60 s per request HTTP timeout
remediate(poll_interval=) 5 s fixed-interval status polling
remediate(timeout=) 1800 s overall wait budget

Duplicate submissions are deduplicated automatically: remediate() sends the file's SHA-256 as Idempotency-Key, so retrying the same file within 24h returns the same job instead of billing twice.

Docs

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

a11yfy-0.1.0.tar.gz (51.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a11yfy-0.1.0-py3-none-any.whl (79.7 kB view details)

Uploaded Python 3

File details

Details for the file a11yfy-0.1.0.tar.gz.

File metadata

  • Download URL: a11yfy-0.1.0.tar.gz
  • Upload date:
  • Size: 51.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for a11yfy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 62bad36bb8c42c072b0fb9c8b3003fbf4c1e928cc1fd93e63a41c0cd71fbfccd
MD5 9bbac53334626235fe4d4cfc10f12968
BLAKE2b-256 69e30bd6474b4be3b7e9b6a927aae9b4b5416f3a5612b924f42b845c6ad29382

See more details on using hashes here.

File details

Details for the file a11yfy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: a11yfy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 79.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for a11yfy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b534a9349b5d2890958b3aca220375c7b3ebef6b0f26a641c576d2418965308
MD5 a4503bfcf60c1646691f6808f0b31ba6
BLAKE2b-256 9fca198a6cae4bb9fa5e81e7251854320344a26d1336088cc907b35b52903dbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page