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.1.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.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kamy_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 71d9ce9afb00dbab30cdd19c94d66634ff443790cc8cc9ce1e6928db0157a14f
MD5 7949fcbc7e2ac192b4b3ca5a0d26bfec
BLAKE2b-256 a785d9947b6325bd48ea0f30358824937acda64e17f9aeb9a313a15b07f6b02b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kamy_sdk-0.1.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.12.1

File hashes

Hashes for kamy_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fba96aeea00937d28c9db2b667c52e0a4e539f3a859eeb58e9e43cf2ec65a5c0
MD5 56950d1959fa1cbd11f890ecd89c1ff5
BLAKE2b-256 d2e8f28b1d9ef12267b283d38eb0338cac2aea69b24da23f79df653df91781de

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