Navigation

Python

Signed URLs in Python

Generate a signed URL with the Python SDK. The URL renders a template image when someone opens it.

generate_image_signed_url builds a link that renders an image when someone opens it. It makes no network request: the SDK signs the URL on your machine with your API key.

Request

#template_idstrrequired

The template id, for example tpl_xxx.

#modificationslist[dict]

The values to put into the template’s layers. They travel in the URL, so keep them short. Modifications lists the fields each layer accepts.

#formatstrdefault: png

The image format: png, jpeg, or webp. The method raises ValueError for any other value.

#nocachebooldefault: False

Skip the cache. Every request renders a new image and counts toward your quota.

url = client.generate_image_signed_url(
    "tpl_xxx",
    modifications=[{"name": "headline", "text": "Hello, Ada"}],
    format="jpeg",
)

Response

The method returns a string:

https://api.bannerify.co/v1/templates/signedurl?apiKeyHashed=2f5a...&format=jpeg&modifications=%5B...%5D&templateId=tpl_xxx&sign=ce2d...

apiKeyHashed tells Bannerify which key signed the URL. sign is an HMAC-SHA256 of the other parameters, keyed with your API key. Nobody can change the template or the modifications in a signed URL without breaking the signature, so you can put the URL in a page, an email, or a meta tag.

html = f'<img src="{url}" alt="Welcome banner">'

Bannerify caches the rendered image for up to 7 days. Signed URLs explains caching, quota, and limits.