Use Case Guide ยท Updated February 2026

Generate Social Media Cards & OG Images with API

When someone shares your blog post on Twitter, LinkedIn, or Slack, the Open Graph image determines whether they click. A generic fallback image gets ignored. A dynamic, well-designed social card with the post title, author, and branding gets engagement. The problem? Creating unique OG images for every page is tedious โ€” unless you automate it.

SnapAPI lets you generate dynamic OG images by rendering HTML templates or markdown as screenshots. Design your card once, then generate unique images for every blog post, product page, or user profile with a single API call.

๐ŸŽจ Dynamic OG Images in One API Call

Render HTML or Markdown to pixel-perfect social cards. 200 free/month.

Get Free API Key โ†’

How Dynamic OG Image Generation Works

The approach is simple: create an HTML template for your social card, inject dynamic data (title, author, date), and use SnapAPI to screenshot it at 1200ร—630 pixels โ€” the standard OG image size. The result is a unique, branded image for every piece of content.

Method 1: Markdown Rendering

SnapAPI can render markdown directly to images โ€” perfect for text-heavy social cards without hosting an HTML template.

curl -X POST "https://api.snapapi.pics/v1/screenshot" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "markdown": "# My Blog Post Title\n\nBy **John Doe** ยท February 2026\n\n> A deep dive into building scalable APIs",
    "width": 1200,
    "height": 630,
    "format": "png"
  }' \
  -o og-image.png

Method 2: HTML Template Screenshot

Host an HTML template that accepts query parameters and screenshot it:

curl "https://api.snapapi.pics/v1/screenshot?url=https://yoursite.com/og-template?title=My+Post&author=John&width=1200&height=630&format=png" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o og-image.png

Node.js โ€” Generate OG Image on Publish

async function generateOGImage(post) {
  const templateUrl = `https://yoursite.com/og-template?` +
    `title=${encodeURIComponent(post.title)}` +
    `&author=${encodeURIComponent(post.author)}` +
    `&date=${encodeURIComponent(post.date)}`;

  const response = await fetch(
    `https://api.snapapi.pics/v1/screenshot?url=${encodeURIComponent(templateUrl)}&width=1200&height=630&format=png`,
    { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
  );

  const buffer = Buffer.from(await response.arrayBuffer());
  // Upload to S3, CloudFlare R2, etc.
  await uploadToStorage(`og-images/${post.slug}.png`, buffer);
  return `https://cdn.yoursite.com/og-images/${post.slug}.png`;
}

Python โ€” Batch Generate Cards

import requests

def generate_social_card(title, author, slug):
    template_url = f"https://yoursite.com/og-template?title={title}&author={author}"
    response = requests.get(
        'https://api.snapapi.pics/v1/screenshot',
        params={
            'url': template_url,
            'width': 1200,
            'height': 630,
            'format': 'png'
        },
        headers={'Authorization': 'Bearer YOUR_API_KEY'}
    )
    with open(f'og-images/{slug}.png', 'wb') as f:
        f.write(response.content)
    return f'og-images/{slug}.png'

# Generate for all posts
for post in posts:
    generate_social_card(post['title'], post['author'], post['slug'])

API vs DIY: OG Image Generation

ApproachDIY (Puppeteer / Satori / Canvas)SnapAPI
Setup complexityHigh โ€” browser or canvas renderingOne API call
Font supportManual font installationFull web font support
CSS supportLimited (Satori) or heavy (Puppeteer)Full CSS โ€” it's a real browser
Server resources500MB+ RAM for headless ChromeZero โ€” API call
Build time impactSeconds per image during buildOffloaded to API
Markdown supportNeed custom rendererBuilt-in

Common Social Card Use Cases

๐Ÿ“ Blog Posts

Generate unique OG images with post title, author photo, and category โ€” automatically on publish.

๐Ÿ›๏ธ Product Pages

Dynamic cards showing product name, price, and image for e-commerce social sharing.

๐Ÿ‘ค User Profiles

GitHub-style profile cards with avatar, name, and stats for social platforms.

๐Ÿ“Š Dashboards

Share charts and metrics as social images โ€” great for weekly reports and public stats.

Best Practices for OG Images

Start Generating OG Images

Beautiful social cards for every page. No design tools needed.

Get Free API Key โ†’

FAQ

What image formats are supported for OG images?

SnapAPI supports PNG, JPEG, WebP, and AVIF. For social cards, PNG gives the best text quality. WebP offers a good balance of quality and file size.

Can I use custom fonts in my OG image templates?

Yes. SnapAPI renders pages in a real Chromium browser, so any web font (Google Fonts, Adobe Fonts, self-hosted) works perfectly.

How do I set the og:image meta tag dynamically?

Generate the image at build time or on first request, upload to your CDN, then set <meta property="og:image" content="https://cdn.yoursite.com/og/your-post.png"> in your page head.

What's the ideal file size for OG images?

Under 1MB is recommended. Most SnapAPI-generated PNGs at 1200ร—630 are 200-500KB. Use WebP format to reduce size by 30-50%.

Related: Link Preview API ยท Free Screenshot API ยท API Documentation

Ready to Get Started?

Start capturing screenshots for free โ€” no credit card required.

Start Free โ†’ 200 Screenshots/Month