
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
Official JavaScript/TypeScript SDK for SnapAPI - Screenshot & PDF generation API
Official JavaScript/TypeScript SDK for SnapAPI — a fast, reliable Screenshot & PDF generation API powered by headless Chrome.
Free tier available — 5 screenshots free, no credit card required. Get your API key at opspawn.com/snapapi
npm install snapapi-js
const SnapAPI = require('snapapi-js');
const snap = new SnapAPI({ apiKey: 'YOUR_API_KEY' });
const image = await snap.screenshot('https://example.com');
require('fs').writeFileSync('screenshot.png', image);
That's it. Three lines of code to capture any webpage as a PNG.
# npm
npm install snapapi-js
# yarn
yarn add snapapi-js
# pnpm
pnpm add snapapi-js
const SnapAPI = require('snapapi-js');
const fs = require('fs');
const snap = new SnapAPI({ apiKey: 'YOUR_API_KEY' });
// Basic screenshot
const png = await snap.screenshot('https://github.com');
fs.writeFileSync('github.png', png);
// Full-page screenshot in JPEG
const jpg = await snap.screenshot('https://example.com', {
fullPage: true,
format: 'jpeg',
quality: 85,
width: 1440,
height: 900,
});
fs.writeFileSync('full-page.jpg', jpg);
// Screenshot a specific element
const element = await snap.screenshot('https://example.com', {
selector: '#hero-section',
});
fs.writeFileSync('hero.png', element);
const snap = new SnapAPI({ apiKey: 'YOUR_API_KEY' });
// Basic PDF (A4)
const pdf = await snap.pdf('https://example.com');
fs.writeFileSync('page.pdf', pdf);
// Custom PDF options
const report = await snap.pdf('https://my-report.com', {
format: 'Letter',
landscape: true,
marginTop: '20mm',
marginBottom: '20mm',
printBackground: true,
});
fs.writeFileSync('report.pdf', report);
const snap = new SnapAPI({ apiKey: 'YOUR_API_KEY' });
const html = `
<html>
<body style="background: #1a1a2e; color: white; padding: 40px; font-family: sans-serif;">
<h1>Hello from SnapAPI!</h1>
<p>Generated at ${new Date().toISOString()}</p>
</body>
</html>
`;
// Screenshot from HTML
const image = await snap.fromHTML(html);
fs.writeFileSync('from-html.png', image);
// PDF from HTML
const pdf = await snap.fromHTML(html, { type: 'pdf', format: 'A4' });
fs.writeFileSync('from-html.pdf', pdf);
import SnapAPI, { ScreenshotOptions, PDFOptions } from 'snapapi-js';
const snap = new SnapAPI({ apiKey: 'YOUR_API_KEY' });
const options: ScreenshotOptions = {
width: 1280,
height: 800,
fullPage: true,
format: 'png',
};
const buffer: Buffer = await snap.screenshot('https://example.com', options);
new SnapAPI(options)| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your SnapAPI key |
baseUrl | string | 'https://api.opspawn.com' | API base URL |
timeout | number | 30000 | Request timeout in ms |
snap.screenshot(url, options?)Captures a screenshot of the given URL.
Returns: Promise<Buffer> — PNG or JPEG image buffer
| Option | Type | Default | Description |
|---|---|---|---|
width | number | 1280 | Viewport width in pixels |
height | number | 800 | Viewport height in pixels |
format | 'png' | 'jpeg' | 'png' | Output image format |
quality | number | 90 | JPEG quality (1-100) |
fullPage | boolean | false | Capture full scroll height |
selector | string | — | CSS selector for element capture |
delay | number | 0 | Wait delay in ms before capture |
darkMode | boolean | false | Enable dark mode emulation |
deviceScaleFactor | 1 | 2 | 3 | 1 | Device pixel ratio |
snap.pdf(url, options?)Generates a PDF from the given URL.
Returns: Promise<Buffer> — PDF buffer
| Option | Type | Default | Description |
|---|---|---|---|
format | string | 'A4' | Paper format ('A4', 'Letter', 'Legal', 'A3', 'Tabloid') |
landscape | boolean | false | Landscape orientation |
printBackground | boolean | true | Print CSS backgrounds |
marginTop | string | '10mm' | Top margin |
marginBottom | string | '10mm' | Bottom margin |
marginLeft | string | '10mm' | Left margin |
marginRight | string | '10mm' | Right margin |
displayHeaderFooter | boolean | false | Show header/footer |
headerTemplate | string | — | HTML header template |
footerTemplate | string | — | HTML footer template |
delay | number | 0 | Wait delay in ms before capture |
snap.fromHTML(html, options?)Renders a screenshot or PDF from raw HTML content.
Returns: Promise<Buffer> — Image or PDF buffer
Accepts all options from screenshot() and pdf(), plus:
| Option | Type | Default | Description |
|---|---|---|---|
type | 'screenshot' | 'pdf' | 'screenshot' | Output type |
try {
const image = await snap.screenshot('https://example.com');
} catch (err) {
if (err.message.includes('Invalid API key')) {
// Get your key at https://opspawn.com/snapapi
} else if (err.message.includes('Usage limit')) {
// Upgrade your plan at https://opspawn.com/snapapi
} else if (err.message.includes('Rate limit')) {
// Slow down requests or upgrade plan
} else {
console.error(err.message);
}
}
| Plan | Screenshots | Price | |
|---|---|---|---|
| Free | 5/month | 5/month | Free, no credit card |
| Pro | 1,000/month | 1,000/month | $19/month |
| Business | 10,000/month | 10,000/month | $99/month |
Get your API key at opspawn.com/snapapi →
MIT — see LICENSE for details.
Built by OpSpawn — autonomous AI agent infrastructure.
FAQs
Official JavaScript/TypeScript SDK for SnapAPI - Screenshot & PDF generation API
We found that snapapi-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.