API Reference

Renderfy Docs

A stateless REST API that converts HTML, Tailwind, Markdown, code, charts, diagrams, and LaTeX math into PNG, JPEG, WebP, or PDF — in a single HTTP request.

Quickstart

Get your first render in under 2 minutes.

  1. Sign up — 100 free credits, no card needed.
  2. Go to Dashboard → API Keys and create a key.
  3. Make your first request:
curl -X POST https://renderfy.io/api/v1/render \
  -H "Authorization: Bearer rfy_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "tailwind",
    "content": "<div class=\"flex h-full items-center justify-center bg-zinc-900 text-white text-4xl font-bold\">Hello, Renderfy</div>",
    "options": { "format": "png", "dimensions": "og-image" }
  }' \
  --output hello.png

Authentication

All requests must include your API key in the Authorization header as a Bearer token.

Authorization: Bearer rfy_live_YOUR_API_KEY

Keys begin with rfy_live_. Create and revoke keys from your dashboard. A missing or invalid key returns 401. An insufficient credit balance returns 402.

POST /api/v1/render

Renders the provided content to the specified output format. Returns the binary image or PDF directly in the response body. Synchronous — no polling required.

POSThttps://renderfy.io/api/v1/render

Content-Type

application/json

Response

image/png · image/jpeg · image/webp · application/pdf

Request body

All fields are top-level JSON properties.

typestringrequired

The input engine to use. One of: tailwind, html, markdown, code, chart, diagram, math.

contentstringrequired

The source content to render. For tailwind/html: an HTML string. For markdown: a Markdown string. For code: raw source code. For chart: a JSON string (see chart schema). For diagram: Mermaid syntax. For math: a LaTeX expression.

optionsobjectrequired

Output options object. Required fields: format. Optional: dimensions, scale, quality.

options.format"png" | "jpeg" | "webp" | "pdf"required

Output format. png, jpeg, and webp cost 1 credit. pdf costs 3 credits. JPEG is always opaque (white background). WebP preserves transparency and is typically 30–50% smaller than PNG.

options.dimensionsstring

Output size. Named presets: og-image (1200×630), square (1080×1080), story (1080×1920), a4, letter. Or a custom string: "1400x990". Defaults to og-image if omitted.

options.scalenumber

Device pixel ratio for image output. Default 2 (retina). Higher values produce larger, sharper images. No effect on PDF output.

options.qualitynumber

JPEG quality, 1–100. Default 90. Only applies when format is jpeg.

langstring

For type: "code" only. The programming language for syntax highlighting. Defaults to typescript. Any Shiki-supported language identifier is valid (e.g. python, rust, go, sql).

themestring

For type: "code" only. The syntax highlight theme. Defaults to one-dark-pro. Any Shiki-supported theme name is valid.

Input types

tailwindTailwind / HTML

An HTML string using Tailwind utility classes. The full Tailwind v4 utility set is available on the PDF path. The image path uses a compatible subset — flexbox, typography, colors, and spacing all work. Note: gap-* utilities and color shades above 900 are not supported on the image path; use margin utilities and shade 900 instead.

{ "type": "tailwind", "content": "<div class=\"flex h-full items-center justify-center bg-zinc-900 text-white text-4xl font-bold\">Hello</div>", "options": { "format": "png", "dimensions": "og-image" } }
htmlPlain HTML

A raw HTML string without Tailwind classes. Uses inline styles or embedded <style> blocks. Behaves identically to the tailwind type on the PDF path (full Chromium render); on the image path, only inline styles are applied.

{ "type": "html", "content": "<div style=\"background:#000;color:#fff;padding:40px;font-size:32px;font-weight:bold\">Hello</div>", "options": { "format": "png" } }
markdownMarkdown

A Markdown string. Converted to styled HTML and rendered. Supports GFM (GitHub Flavored Markdown): tables, fenced code blocks, task lists, strikethrough. On the PDF path, nested lists and tables render fully; on the image path, deeply nested lists may render imperfectly.

{ "type": "markdown", "content": "# Release Notes\n\n## v2.0\n\n- New feature A\n- Fixed bug B", "options": { "format": "pdf", "dimensions": "a4" } }
codeCode

Raw source code. Rendered with Shiki syntax highlighting in a macOS-style window frame. Supports 100+ languages via the lang parameter. Theme is configurable via the theme parameter.

{ "type": "code", "content": "const greet = (name: string) => `Hello, ${name}!`;", "lang": "typescript", "theme": "one-dark-pro", "options": { "format": "png" } }
chartChart

A JSON string with the chart definition. Schema: { type: "line" | "bar" | "pie", labels: string[], datasets: [{ label?: string, data: number[], color?: string, colors?: string[] }], title?: string }. Rendered using Chart.js.

{ "type": "chart", "content": "{\"type\":\"bar\",\"labels\":[\"Q1\",\"Q2\",\"Q3\"],\"datasets\":[{\"data\":[120,145,98],\"color\":\"#00e676\"}],\"title\":\"Revenue\"}", "options": { "format": "png", "dimensions": "1200x800" } }
diagramDiagram

Mermaid diagram syntax. Supports flowcharts, sequence diagrams, class diagrams, ERDs, Gantt charts, state diagrams, and pie charts. Flowchart shorthand (without a header line) is auto-prefixed with flowchart TD. PDF output embeds the SVG as vector.

{ "type": "diagram", "content": "flowchart TD\n  A[Client] --> B(API)\n  B --> C[Database]", "options": { "format": "png", "dimensions": "1200x800" } }
mathMath (LaTeX)

A LaTeX math expression. Rendered with KaTeX in display mode (block equation). PNG output has a transparent background — suitable for compositing onto any document. PDF output uses a white print-ready background.

{ "type": "math", "content": "\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}", "options": { "format": "png" } }

Dimensions

Named presets and custom sizes.

PresetSizeUse case
og-image1200 × 630 pxOpen Graph / social share cards
square1080 × 1080 pxInstagram, Twitter square posts
story1080 × 1920 pxInstagram/TikTok story format
a4794 × 1123 pxA4 print-ready PDF
letter816 × 1056 pxUS Letter print-ready PDF
1400x9901400 × 990 pxCustom — replace with any WxH

For a custom size, pass a string in "WxH" format: "600x200", "1600x900", etc.

Response

A successful render returns 200 OK with the binary image or PDF as the response body.

Content-Type

image/png · image/jpeg · application/pdf depending on the requested format

X-Credits-Charged

Number of credits deducted for this render (1 for PNG/JPEG/WebP, 3 for PDF)

X-Credits-Remaining

Your credit balance after this render

Error codes

StatusMeaning
400 Bad RequestInvalid or missing request body fields. Check the error message for details.
401 UnauthorizedMissing or invalid API key. Ensure the Authorization header is present and the key is active.
402 Payment RequiredInsufficient credits. Top up or upgrade your plan.
429 Too Many RequestsRate limit exceeded (guest endpoint only).
500 Internal Server ErrorRender failed — invalid input content, unsupported syntax, or internal error. Credits are refunded automatically on failure.

All error responses return a JSON body: { "error": "message" }

Examples

Node.js / TypeScript

async function render(content: string, type = 'tailwind') {
  const res = await fetch('https://renderfy.io/api/v1/render', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.RENDERFY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      type,
      content,
      options: { format: 'png', dimensions: 'og-image' },
    }),
  });

  if (!res.ok) {
    const { error } = await res.json();
    throw new Error(`Render failed: ${error}`);
  }

  return Buffer.from(await res.arrayBuffer());
}

Python

import requests
import os

def render(content: str, type: str = "tailwind") -> bytes:
    response = requests.post(
        "https://renderfy.io/api/v1/render",
        headers={
            "Authorization": f"Bearer {os.environ['RENDERFY_API_KEY']}",
            "Content-Type": "application/json",
        },
        json={
            "type": type,
            "content": content,
            "options": {"format": "png", "dimensions": "og-image"},
        },
    )
    response.raise_for_status()
    return response.content

PHP

function renderfy(string $content, string $type = 'tailwind'): string {
    $ch = curl_init('https://renderfy.io/api/v1/render');
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_HTTPHEADER     => [
            'Authorization: Bearer ' . $_ENV['RENDERFY_API_KEY'],
            'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS     => json_encode([
            'type'    => $type,
            'content' => $content,
            'options' => ['format' => 'png', 'dimensions' => 'og-image'],
        ]),
    ]);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result; // binary PNG
}

cURL

curl -X POST https://renderfy.io/api/v1/render \
  -H "Authorization: Bearer rfy_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "tailwind",
    "content": "<div class=\"flex h-full items-center justify-center bg-zinc-900 text-white text-4xl font-bold\">Hello</div>",
    "options": { "format": "png", "dimensions": "og-image" }
  }' \
  --output output.png

TypeScript SDK

Skip the raw HTTP layer — the official SDK gives you typed methods, autocomplete, and built-in error handling.

$npm install @renderfy/sdk
import { Renderfy } from "@renderfy/sdk";

const renderfy = new Renderfy({ apiKey: process.env.RENDERFY_API_KEY! });

const { data } = await renderfy.tailwind(
  `<div class="flex h-full items-center justify-center bg-zinc-900 text-white text-4xl font-bold">
     Hello, Renderfy
   </div>`,
  { format: "png", dimensions: "1200x630" }
);
View full SDK docs →

Ready to start rendering?

100 free credits. No card needed.

Get API key