Generate OG Images & Social Media Previews with a Screenshot API

When you share a link on Twitter, LinkedIn, or Slack, the platform fetches an Open Graph image to display as a preview card. Static OG images are fine for homepages β€” but what about blog posts, user profiles, or product pages that need unique, dynamic preview images?

SnapAPI lets you render any HTML page as a PNG image via a simple API call. Build an HTML template with your title, author, and branding, host it on a URL, and let SnapAPI screenshot it into a pixel-perfect OG image.

How It Works

The workflow is straightforward:

  1. Create an HTML template β€” Design your OG card layout (1200Γ—630px) with CSS. Use query parameters for dynamic content.
  2. Call SnapAPI β€” Pass the template URL to the screenshot endpoint. SnapAPI renders it in a real Chromium browser.
  3. Serve the image β€” Use the returned PNG as your og:image meta tag, or cache it on your CDN.

Code Example

Screenshot an OG Template

Node.js
const response = await fetch('https://snapapi.eu/v1/screenshot', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.SNAPAPI_KEY
  },
  body: JSON.stringify({
    url: 'https://yoursite.com/og-template?title=My+Post&author=Jane',
    width: 1200,
    height: 630,
    format: 'png'
  })
});

const imageBuffer = await response.arrayBuffer();
// Upload to S3, serve from CDN, or return directly

Dynamic Meta Tags

Point your og:image to a serverless function that calls SnapAPI on-the-fly:

HTML
<!-- In your page's <head> -->
<meta property="og:image"
      content="https://yoursite.com/api/og?title=My+Blog+Post" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />

Why Use SnapAPI for OG Images?

Start Generating OG Images

Try SnapAPI free in the playground β€” no signup needed.

Get Your API Key β†’