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.
- Sign up — 100 free credits, no card needed.
- Go to Dashboard → API Keys and create a key.
- 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.pngAuthentication
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.
https://renderfy.io/api/v1/renderContent-Type
application/jsonResponse
image/png · image/jpeg · image/webp · application/pdfRequest body
All fields are top-level JSON properties.
typestringrequiredThe input engine to use. One of: tailwind, html, markdown, code, chart, diagram, math.
contentstringrequiredThe 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.
optionsobjectrequiredOutput options object. Required fields: format. Optional: dimensions, scale, quality.
options.format"png" | "jpeg" | "webp" | "pdf"requiredOutput 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.dimensionsstringOutput 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.scalenumberDevice pixel ratio for image output. Default 2 (retina). Higher values produce larger, sharper images. No effect on PDF output.
options.qualitynumberJPEG quality, 1–100. Default 90. Only applies when format is jpeg.
langstringFor 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).
themestringFor type: "code" only. The syntax highlight theme. Defaults to one-dark-pro. Any Shiki-supported theme name is valid.
Input types
tailwindTailwind / HTMLAn 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 HTMLA 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" } }markdownMarkdownA 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" } }codeCodeRaw 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" } }chartChartA 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" } }diagramDiagramMermaid 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.
| Preset | Size | Use case |
|---|---|---|
| og-image | 1200 × 630 px | Open Graph / social share cards |
| square | 1080 × 1080 px | Instagram, Twitter square posts |
| story | 1080 × 1920 px | Instagram/TikTok story format |
| a4 | 794 × 1123 px | A4 print-ready PDF |
| letter | 816 × 1056 px | US Letter print-ready PDF |
| 1400x990 | 1400 × 990 px | Custom — 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-Typeimage/png · image/jpeg · application/pdf depending on the requested format
X-Credits-ChargedNumber of credits deducted for this render (1 for PNG/JPEG/WebP, 3 for PDF)
X-Credits-RemainingYour credit balance after this render
Error codes
| Status | Meaning |
|---|---|
| 400 Bad Request | Invalid or missing request body fields. Check the error message for details. |
| 401 Unauthorized | Missing or invalid API key. Ensure the Authorization header is present and the key is active. |
| 402 Payment Required | Insufficient credits. Top up or upgrade your plan. |
| 429 Too Many Requests | Rate limit exceeded (guest endpoint only). |
| 500 Internal Server Error | Render 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.contentPHP
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.pngTypeScript SDK
Skip the raw HTTP layer — the official SDK gives you typed methods, autocomplete, and built-in error handling.
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 →