Node.js client for SnapAPI — capture screenshots, extract metadata, generate PDFs, and pull text from any URL.
Zero dependencies. Uses native fetch (Node 18+).
Live Demo · API Docs · OpenAPI Spec · Free Website Audit
npm install snapapiconst { SnapAPI } = require('snapapi');
const snap = new SnapAPI('snap_your_api_key');
// Take a screenshot
const { buffer } = await snap.screenshot('https://github.com');
fs.writeFileSync('github.png', buffer);
// Extract metadata (OG tags, Twitter cards, etc.)
const { data } = await snap.metadata('https://github.com');
console.log(data.title, data.og, data.twitter);
// Generate a PDF
const pdf = await snap.pdf('https://example.com', { format: 'Letter' });
fs.writeFileSync('page.pdf', pdf.buffer);
// Extract text
const text = await snap.text('https://example.com');
console.log(text.data.text, text.data.word_count);
// Check usage
const usage = await snap.usage();
console.log(`${usage.used}/${usage.limit} requests used this month`);Sign up at snap.michaelcli.com or use the client directly:
const { SnapAPI } = require('snapapi');
const { key } = await SnapAPI.signup('you@example.com', 'Your Name');
console.log(key); // snap_...Free tier includes 50 requests/month.
| Parameter | Type | Description |
|---|---|---|
apiKey |
string |
Your API key (starts with snap_) |
options.baseUrl |
string |
Override the API URL (default: https://snap.michaelcli.com) |
Capture a PNG or JPEG screenshot of any webpage.
| Option | Type | Default | Description |
|---|---|---|---|
width |
number |
1280 |
Viewport width (320--3840) |
height |
number |
720 |
Viewport height (240--2160) |
full_page |
boolean |
false |
Capture full scrollable page |
format |
'png' | 'jpeg' |
'png' |
Image format |
Returns { buffer: Buffer, contentType: string, usage: { used, limit } }
Extract Open Graph tags, Twitter Cards, meta tags, and favicon from a URL.
Returns:
{
data: {
url, title, description, favicon,
og: { title, description, image, ... },
twitter: { card, title, description, ... },
meta_tags: [{ name, content }, ...]
},
usage: { used, limit }
}Generate a PDF from any webpage.
| Option | Type | Default | Description |
|---|---|---|---|
format |
'A4' | 'Letter' | 'Legal' | 'A3' |
'A4' |
Page size |
landscape |
boolean |
false |
Landscape orientation |
Returns { buffer: Buffer, contentType: string, usage: { used, limit } }
Extract clean, readable text content from a webpage.
Returns:
{
data: { url, title, text, word_count },
usage: { used, limit }
}Get current month's usage statistics.
Returns { tier, used, limit, remaining }
Static method. Creates a free API key -- no authentication required.
Returns { key, name, tier, message }
All methods throw SnapAPIError on non-2xx responses:
const { SnapAPI, SnapAPIError } = require('snapapi');
try {
await snap.screenshot('https://example.com');
} catch (err) {
if (err instanceof SnapAPIError) {
console.error(err.status); // HTTP status code
console.error(err.message); // Error message from API
console.error(err.detail); // Additional detail (if any)
}
}| Status | Meaning |
|---|---|
400 |
Invalid request (bad URL, invalid parameters) |
401 |
Missing or invalid API key |
429 |
Monthly rate limit exceeded |
500 |
Server-side failure |
MIT