Skip to main content

Official Python SDK for the DocRenders API

Project description

docrenders-sdk (Python)

Official Python SDK for the DocRenders API. No dependencies — uses the standard library only.

Installation

pip install docrenders-sdk

Usage

import os
from docrenders import DocRendersClient, RenderRequest, RenderFileRequest, RenderOptions

client = DocRendersClient(os.environ["PDFGEN_API_KEY"])

# Render to raw bytes
pdf = client.render(RenderRequest(
    markdown="# Invoice\n\nDue: **$1,200**",
    template="invoice",
    options=RenderOptions(format="A4"),
))

# Render and get a signed download URL (expires in 15 min)
result = client.render_signed_url(RenderRequest(markdown="# Report"))
print(result.url)

# Upload a file
with open("invoice.md", "rb") as f:
    pdf = client.render_file(RenderFileRequest(
        filename="invoice.md",
        content=f.read(),
    ))

# Check usage
usage = client.usage()
print(f"{usage.renders_used} / {usage.renders_limit} renders used")

Error handling

from docrenders import DocRendersClient, DocRendersError, RenderRequest

try:
    pdf = client.render(RenderRequest(markdown="# Hello"))
except DocRendersError as e:
    print(e.code, str(e))  # e.g. "quota_exceeded"

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

docrenders_sdk-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

docrenders_sdk-0.1.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file docrenders_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: docrenders_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for docrenders_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a08cda0a0e9a5257103f967bda3b36387026e303c58129a32abe548d94c58c33
MD5 83fbddcc3dd118976ed44f2cf1f295c1
BLAKE2b-256 97fc19b51b1fe63c0c23b0157951c862d51e55684948ad436c12c3adef1f7b2b

See more details on using hashes here.

File details

Details for the file docrenders_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for docrenders_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 511b09cdfc1b416fc2bfeb18f3184a63c3449f3b5bfe1cb8a93ba8f8733a6a84
MD5 cb8239d374d9eab2cd398a4c7867327a
BLAKE2b-256 4dc2cba606e024c72a5c88c0cbf075c0921eeffaf52eaec2b8d04b2164829ddd

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