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:
- Create an HTML template β Design your OG card layout (1200Γ630px) with CSS. Use query parameters for dynamic content.
- Call SnapAPI β Pass the template URL to the screenshot endpoint. SnapAPI renders it in a real Chromium browser.
- Serve the image β Use the returned PNG as your
og:imagemeta tag, or cache it on your CDN.
Code Example
Screenshot an OG Template
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:
<!-- 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?
- Real browser rendering β Full CSS support, custom fonts, gradients, SVGs. No template language limitations.
- EU-hosted, GDPR compliant β All rendering happens on servers in Germany. No data leaves the EU.
- Fast β Typical render times under 2 seconds. Cache the result and serve instantly.
- Simple API β One POST request, one image back. No SDKs required.
Start Generating OG Images
Try SnapAPI free in the playground β no signup needed.
Get Your API Key β