Package Exports
- snapforge
- snapforge/dist/index.js
- snapforge/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (snapforge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
snapforge
Official TypeScript SDK for SnapForge — Dynamic OG Image & Screenshot API.
Install
npm install snapforgeQuick Start
import SnapForge from 'snapforge';
const sf = new SnapForge({ apiKey: 'sf_live_your_key' });
// Get a URL for use in meta tags
const url = sf.getOgUrl({
template: 'blog-post',
params: { title: 'Hello World', author: 'Jane Doe' },
});
// → https://api.snapforgehq.com/v1/og?template=blog-post&title=Hello+World&...
// Generate and download an image
const image = await sf.generateOg({
template: 'blog-post',
params: { title: 'Hello World', author: 'Jane Doe' },
});
// → ArrayBuffer (PNG)Templates
| Template | Parameters |
|---|---|
blog-post |
title, subtitle, author, bg_from, bg_to |
social |
title, description, brand, bg_color, accent |
minimal |
title, color, text_color |
product-hunt |
tagline, description, category, upvotes |
github-card |
name, description, stars, language, language_color |
API
new SnapForge(config)
const sf = new SnapForge({
apiKey: 'sf_live_your_key', // Required
baseUrl: 'https://api.snapforgehq.com', // Optional
});sf.generateOg(options) → Promise<ArrayBuffer>
Generate an OG image and return the PNG as an ArrayBuffer.
sf.getOgUrl(options) → string
Get a URL that generates the image on request. Use this in <meta> tags.
sf.screenshot(options) → Promise<ArrayBuffer>
Capture a screenshot. Requires Starter plan or higher.
const screenshot = await sf.screenshot({
url: 'https://example.com',
width: 1280,
height: 720,
});sf.getUsage() → Promise<UsageStats>
Get current usage stats.
sf.getTemplates() → Promise<TemplateInfo[]>
List available templates.