How to Take a Website Screenshot with Node.js
If you are building link previews, monitoring dashboards, or visual testing tools in Node.js, a screenshot API gives you a clean HTTP-based workflow without browser orchestration. This version is t...

Source: DEV Community
If you are building link previews, monitoring dashboards, or visual testing tools in Node.js, a screenshot API gives you a clean HTTP-based workflow without browser orchestration. This version is tuned for the Dev.to audience and keeps the examples focused on the most common production use cases. Prerequisites Node.js 18+ (for built-in fetch) or any version with axios A Site-Shot API key (sign up here) Using Built-in Fetch (Node.js 18+) const fs = require('fs'); async function captureScreenshot(url, outputPath = 'screenshot.png') { const params = new URLSearchParams({ url, userkey: 'YOUR_API_KEY', width: '1280', height: '1024', format: 'png', }); const response = await fetch( `https://api.site-shot.com/?${params.toString()}` ); if (!response.ok) { throw new Error(`API returned ${response.status}`); } const buffer = Buffer.from(await response.arrayBuffer()); fs.writeFileSync(outputPath, buffer); console.log(`Screenshot saved to ${outputPath}`); } captureScreenshot('https://example.com')