Skip to main content

Kamy PDF generation API — Python SDK

Project description

Kamy — Python SDK

Official Python SDK for the Kamy PDF generation API.

pip install kamy-sdk

Distribution name on PyPI is kamy-sdk (the kamy name was unavailable). The import path is still from kamy import Kamy — the directory under site-packages/ is named kamy/, so module imports look the way you'd expect.

Quick start

from kamy import Kamy

kamy = Kamy(api_key="kamy_pk_...")  # or set KAMY_API_KEY in the env

pdf = kamy.render(
    template="invoice",
    data={
        "invoiceNumber": "INV-001",
        "from": {"name": "Acme Inc."},
        "to": {"name": "Globex Corp."},
        "lineItems": [
            {"description": "Consulting", "quantity": 10, "unitPrice": 150, "amount": 1500},
        ],
        "subtotal": 1500,
        "total": 1500,
        "currency": "USD",
    },
)

print(pdf.url)  # signed URL valid for 1 hour

Async (FastAPI / asyncio)

from kamy import AsyncKamy

async with AsyncKamy(api_key="kamy_pk_...") as kamy:
    pdf = await kamy.render(template="invoice", data={...})

Other modes

# Inline HTML
kamy.render(html="<h1>Hello {{name}}</h1>", data={"name": "world"})

# URL mode (paid plans only — fetches the URL server-side)
kamy.render(url="https://example.com/invoice/123")

# Word (.docx) output instead of PDF
kamy.render_docx(template="invoice", data={...})

# Batch — up to 100 items, partial failures don't abort
results = kamy.render_batch([
    {"template": "receipt", "data": order1},
    {"template": "receipt", "data": order2},
])

Render options

from kamy import Kamy, RenderOptions, FormFieldSpec

kamy = Kamy()

pdf = kamy.render(
    template="invoice",
    data={...},
    options=RenderOptions(
        format="a4",
        orientation="portrait",
        page_numbers=True,
        pdf_a="2b",  # archival output
        form_fields=[  # fillable AcroForm widgets
            FormFieldSpec(
                name="signature",
                type="signature",
                page=1,
                x=100, y=100,
                width=200, height=40,
            ),
        ],
    ),
)

Error handling

from kamy import Kamy
from kamy import RateLimitError, QuotaExceededError, ValidationError

kamy = Kamy()
try:
    pdf = kamy.render(template="invoice", data={...})
except ValidationError as e:
    print("Bad payload:", e.details)  # {"field.name": ["reason"]}
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after_seconds}s")
except QuotaExceededError:
    print("Monthly quota hit. Upgrade or wait until next billing cycle.")

Documentation

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

kamy_sdk-0.6.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

kamy_sdk-0.6.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file kamy_sdk-0.6.0.tar.gz.

File metadata

  • Download URL: kamy_sdk-0.6.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kamy_sdk-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7aa7c89a690359551f0f08a1fa06caa270b8d05d519e93b05b1acafb0301f0ff
MD5 bbb39e486079c4335bbdb6e1cd6db1a8
BLAKE2b-256 b1725d0e9c630103cd69143c10d10ca8af371c3315a8ec7bc619d01ec9113d7a

See more details on using hashes here.

File details

Details for the file kamy_sdk-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: kamy_sdk-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kamy_sdk-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1b690f05a2a8dc8639337db32269ffb210e9e0e5aeefd4ea5fa6e858d4dfe6e
MD5 8f3d9809667f0e064b933f4956b7edd7
BLAKE2b-256 68bdbd1a6bc8aa0d20a566e353a734c4ddab7ab5f7dc9e44a99ee6b0cf7fa06d

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