Generate Open Graph Images via API

Automatically generate Open Graph preview images for any URL or custom HTML. SnapAPI captures pages at the exact 1200×630 dimensions social platforms expect — Twitter, LinkedIn, Slack, Discord, iMessage. Use the screenshot endpoint for URL-based OG images or the render endpoint for fully custom HTML cards.

Code Examples

cURL
Node.js
Python
# OG image from a URL (1200x630)
curl "https://snapapi.tech/v1/screenshot?url=https://example.com&width=1200&height=630&format=png" \
  -H "x-api-key: YOUR_KEY" -o og.png

# OG image from custom HTML template
curl -X POST "https://snapapi.tech/v1/render" \
  -H "x-api-key: YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"html":"<div style=\"background:#0070f3;color:#fff;font:bold 48px sans-serif;display:flex;align-items:center;justify-content:center;width:1200px;height:630px\">My Article Title</div>","width":1200,"height":630}' \
  -o og-custom.png
// Dynamic OG image for a blog post
const title = "How to Build a Screenshot API";
const html = `<!DOCTYPE html>
<html><head><style>
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { width: 1200px; height: 630px; display: flex; align-items: center; justify-content: center;
         background: linear-gradient(135deg, #0070f3, #7928ca); font-family: sans-serif; color: #fff; padding: 60px; }
  h1 { font-size: 52px; line-height: 1.2; }
  .tag { font-size: 18px; opacity: 0.7; margin-top: 20px; }
</style></head><body>
<div><h1>${title}</h1><div class="tag">snapapi.tech</div></div>
</body></html>`;

const res = await fetch("https://snapapi.tech/v1/render", {
  method: "POST",
  headers: { "x-api-key": "YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ html, width: 1200, height: 630, format: "png" })
});
require("fs").writeFileSync("og.png", Buffer.from(await res.arrayBuffer()));
import requests

# Capture a URL as an OG image
resp = requests.get(
    "https://snapapi.tech/v1/screenshot",
    params={"url": "https://example.com", "width": 1200, "height": 630, "format": "png"},
    headers={"x-api-key": "YOUR_KEY"}
)

with open("og.png", "wb") as f:
    f.write(resp.content)
Get Your Free API Key Read the Docs

Try It Live

Capturing screenshot...

Why SnapAPI?

No Browser Setup

We run Chromium so you don't have to. No Puppeteer, no Selenium, no drivers.

PNG, JPEG, WebP

Choose your format. Set quality. Get optimized output.

Mobile Emulation

9 device presets — iPhone, Pixel, iPad, desktop. One parameter.

Full Page Capture

Scroll the entire page and stitch into one image. Automatic.

Element Selector

Capture a specific element by CSS selector instead of the whole page.

Dark Mode

Emulate prefers-color-scheme: dark to capture dark-themed pages.

Built For

How It Works

1. Sign up for a free API key — 100 screenshots/month, no credit card required.

2. Make a GET request to /v1/screenshot with your URL and API key.

3. Receive a pixel-perfect screenshot as a binary image, or JSON with metadata if meta=true.

That's it. No browser installation, no Chromium management, no headless infrastructure to maintain.