Skip to main content

Node.js SDK

The official Pictify SDK for Node.js provides a type-safe, promise-based interface for the Pictify API — generate images, PDFs, and GIFs from raw HTML, live URLs, and reusable templates.

Installation

Quick Start

Configuration

The client is constructed with a config object. apiKey is required; every request is sent with an Authorization: Bearer <API_KEY> header.
Keep your API key secret. Read it from an environment variable (PICTIFY_API_KEY) and never expose it in client-side code or public repositories.

Render an Image from HTML

renderHtml(options)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 is mapped to the endpoint’s fileExtension.

Screenshot a Live URL

renderUrl(options)POST /image with url. Returns { url, id, createdAt }.

Render a Template

render(options)POST /templates/:uid/render. Returns a results[] envelope with a convenience url getter (results[0]?.url).
The response shape:

Render a Specific Layout

Pass a single layout to render one named variant.

Render Multiple Layouts

renderLayouts(options)POST /templates/:uid/render with layouts (max 20). Templates can have layout variants (e.g. square, story) created via AI Resize in the Pictify editor. Use default for the base layout. Missing or invalid layouts come back in errors[] rather than throwing.

Render an Animated GIF

renderGif(options)POST /gif. Provide exactly one source: html, url, or templateId. The API’s nested { gif: {...} } envelope is flattened to { url, uid, width, height, animationLength }.
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)

renderBatch(options)POST /templates/:uid/batch-render. Returns immediately (HTTP 202) with a batchId; poll getBatchResults(batchId) (GET /templates/batch/:batchId/results) to track progress.
Rendered URLs are not returned by the poll endpoint. getBatchResults reports per-item { index, success, variables } (and error on failures). Final image URLs are delivered via the render.completed webhook — subscribe to webhooks to collect batch output.

Templates

Get a Template

getTemplate(templateId)GET /templates/:uid. Unwraps the { template } envelope.

List Templates

listTemplates(options)GET /templates. Returns { templates, pagination }.

Create a Template

createTemplate(options)POST /templates. Variables are auto-discovered from {{variableName}} tokens in the HTML body.

Error Handling

All API errors throw a typed subclass of PictifyError.

Error Types

Only 5xx and network failures are retried (with exponential backoff); 4xx responses are never retried.

CommonJS Support

TypeScript Support

The SDK is written in TypeScript and exports all types:

Next.js Integration

Route Handler (OG image)

Express.js OG-image route

Video Templates

Render MP4 video — or animated GIF — from video templates, generate new templates with AI, or upload a Remotion scene you wrote. Video renders wait for the finished file (up to a few minutes); the SDK raises the per-call timeout automatically.

API Reference

See the API Reference for full endpoint documentation.