snapforge
v0.1.0
Published
Official SDK for SnapForge - Dynamic OG Image & Screenshot API
Downloads
106
Maintainers
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.
