Go SDK
The official Pictify SDK for Go provides an idiomatic Go interface for the Pictify API — generate images, PDFs, and GIFs from raw HTML, live URLs, and reusable templates.
Installation
Quick Start
API
The SDK talks to the Pictify API at https://api.pictify.io. Every call sends Authorization: Bearer <api-key>.
Configuration
NewClient takes the API key plus functional options.
Keep your API key secret. Read it from an environment variable (e.g. os.Getenv("PICTIFY_API_KEY")) and never expose it in client-side code or public repositories.
Render an Image from HTML
POST /image — returns {URL, ID, CreatedAt}.
The /image endpoint accepts a single html field, so any CSS you pass is injected into a <style> tag prepended to the HTML. Format maps to the endpoint’s fileExtension.
Screenshot a Live URL
POST /image with a url.
Render a Template
POST /templates/{uid}/render — returns a results[] envelope. Use result.URL() for the first result’s URL.
Layout Variants
Templates can have multiple layout variants (e.g. landscape, square, story) created via AI Resize in the Pictify editor. Render several at once with RenderLayouts (max 20). Use "default" for the base layout. Layouts that can’t be rendered are returned in result.Errors rather than failing the whole call.
Render an Animated GIF
POST /gif — provide exactly one source (HTML, URL, or TemplateID). The API’s nested {gif: {...}} envelope is flattened into *GIFResult.
To render a GIF from a template, set TemplateID (and optionally Variables). The source must be animated; a static source returns a render error (HTTP 422).
Batch Rendering (async)
POST /templates/{uid}/batch-render returns immediately (HTTP 202) with a BatchID. The job runs asynchronously — poll GetBatchResults to track progress.
Rendered URLs are not returned by the poll endpoint; they are delivered via the render.completed webhook. The poll response reports each item’s Index, Success, and variable names (plus an Error on failures).
Template Management
Template keys by UID (not id) and declares variables in VariableDefinitions. Any unknown engine-specific fields are preserved in Template.Extra (a map[string]json.RawMessage).
Error Handling
HTTP errors are mapped to typed errors. Each one embeds *PictifyError, so you can match either the concrete type or the base with errors.As. The error message resolves as body.error → body.message → HTTP status text.
Only 5xx and network failures are retried (with exponential backoff); 4xx responses are never retried.
Context Support
All methods take a context.Context for cancellation and timeouts:
Concurrent Requests
The client is safe for concurrent use:
API Reference
See the API Reference for full endpoint documentation.