Skip to content

cwanglab/ogsnap

Repository files navigation

OGSnap — Dynamic OG Image API

Generate beautiful Open Graph images via a simple HTTP API. No headless browser needed — uses Satori + Resvg for fast SVG-to-PNG rendering.

Quick Start

npm install
npm run build
npm start

API

GET /api/og

Parameter Type Default Description
title string required Main heading text
subtitle string Secondary text
template string default default, gradient, or minimal
theme string dark dark or light
fontSize number 64 Title font size (16-128)
width number 1200 Image width (200-2400)
height number 630 Image height (200-1260)
bg string Custom background color (hex)
color string Custom text color (hex)
accent string Custom accent color (hex)

Examples

# Default dark template
curl "http://localhost:3001/api/og?title=My+Blog+Post" -o og.png

# Light gradient template
curl "http://localhost:3001/api/og?title=Launch+Day&subtitle=v2.0+is+here&template=gradient&theme=light" -o og.png

# Custom colors
curl "http://localhost:3001/api/og?title=Custom&bg=%23000&color=%23fff&accent=%23ff6b6b" -o og.png

Use in HTML

<meta property="og:image" content="https://your-domain.com/api/og?title=My+Page" />

Deploy

Render (recommended)

  1. Fork this repo
  2. Go to render.com → New Web Service → Connect repo → Docker → Deploy

Docker

docker build -t ogsnap .
docker run -p 3001:3001 ogsnap

Performance

  • No headless browser — pure SVG rendering via Satori
  • ~50ms per image generation
  • Responses cached for 24 hours via Cache-Control headers
  • Rate limited: 50 requests/hour (free), unlimited with API key

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors