Python SDK
The official Pictify SDK for Python provides a simple, Pythonic interface for the Pictify API — generate images, PDFs, and GIFs from raw HTML, live URLs, and reusable templates. It ships sync (Pictify) and async (AsyncPictify) clients with an identical surface.
Installation
Quick Start
Async Usage
Configuration
The client is constructed with a keywordapi_key. Every request is sent with an Authorization: Bearer <API_KEY> header.
close():
Render an Image from HTML
render_html(html, *, css=None, width=None, height=None, selector=None, format=None) — POST /image. Returns an ImageResult with url, id, and created_at.
/image endpoint accepts a single html field, so any css you pass is injected into a <style> tag prepended to the HTML. format is mapped to the endpoint’s fileExtension.
Screenshot a Live URL
render_url(url, *, width=None, height=None, selector=None, format=None) — POST /image with url. Returns an ImageResult.
Render a Template
render(template_id, *, variables=None, format=None, quality=None, width=None, height=None, layout=None, layouts=None) — POST /templates/:uid/render.
The response is a results envelope; result.url is a convenience accessor for results[0].url.
Render a Specific Layout
Render Multiple Layouts
render_layouts(template_id, layouts, *, variables=None, format=None, quality=None, width=None, height=None) — POST /templates/:uid/render with layouts (max 20).
Each successful layout appears in results; missing/invalid layouts appear in errors.
Render an Animated GIF
render_gif(*, html=None, url=None, template_id=None, variables=None, width=None, height=None, quality=None) — POST /gif.
Provide exactly one source: html, url, or template_id. The {gif: {...}} envelope is flattened.
The source HTML/URL must contain motion (e.g. a CSS animation). Static content produces no frames and returns a render error (HTTP 422).
Batch Rendering (async)
render_batch(template_id, variable_sets, *, format=None, quality=None, concurrency=None, layout=None, layouts=None) — POST /templates/:uid/batch-render.
Submitting returns immediately (HTTP 202) with a batch_id. Poll get_batch_results for progress.
get_batch_results(batch_id) — GET /templates/batch/:batchId/results.
Templates
Get a Template
get_template(template_id) — GET /templates/:uid.
List Templates
list_templates(*, page=None, limit=None, sort=None) — GET /templates. Returns a ListTemplatesResult with templates and pagination.
Create a Template
create_template(html, *, name=None, width=None, height=None, variable_definitions=None, output_format=None) — POST /templates. Variables are auto-discovered from {{variableName}} tokens.
Error Handling
401 → AuthenticationError, 402 → QuotaExceededError, 404 → TemplateNotFoundError, 422 → RenderError (with field-level errors), 429 → QuotaExceededError when code == "quota_exceeded" else RateLimitError, other 4xx → RenderError, 5xx → ServerError. Only 5xx and network errors are retried.