Skip to main content

A client library for accessing Gotenberg

Reason this release was yanked:

Broken multi-file upload

Project description

Python client for Gotenberg

Usage

First, create a client:

from gotenberg_client import Client

client = Client(base_url="http://gotenberg:3000")

If the endpoints you're going to hit require authentication, use AuthenticatedClient instead:

from gotenberg_client import AuthenticatedClient

client = AuthenticatedClient(base_url="http://gotenberg:3000", token="SuperSecretToken")

Now call your endpoint and use your models:

from typing import Any
from gotenberg_client.models import URLConversionRequestBody
from gotenberg_client.api.chromium import post_forms_chromium_convert_url
from gotenberg_client.types import Response

response: Response[Any] = post_forms_chromium_convert_url.sync_detailed(
   client=client, body=URLConversionRequestBody(url="http://example.org")
)
pdf: bytes = response.content

Or do the same thing with an async version:

from typing import Any
from gotenberg_client.models import URLConversionRequestBody
from gotenberg_client.api.chromium import post_forms_chromium_convert_url
from gotenberg_client.types import Response

response: Response[Any] = await post_forms_chromium_convert_url.asyncio_detailed(
   client=client, body=URLConversionRequestBody(url="http://example.org")
)
pdf: bytes = response.content

By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.

client = AuthenticatedClient(
    base_url="https://gotenberg.svc", 
    token="SuperSecretToken",
    verify_ssl="/path/to/certificate_bundle.pem",
)

You can also disable certificate validation altogether, but beware that this is a security risk.

client = AuthenticatedClient(
    base_url="https://gotenberg.svc", 
    token="SuperSecretToken", 
    verify_ssl=False
)

Since Gotenberg returns binary responses (application/pdf), the auto-parsing feature of openapi-python-client is omitted.

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

gotenberg-client-7.0.0.tar.gz (12.7 kB view hashes)

Uploaded Source

Built Distribution

gotenberg_client-7.0.0-py3-none-any.whl (26.5 kB view hashes)

Uploaded Python 3

Supported by

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