We use cookies

We use cookies to enhance your experience and analyse site usage.

Node.js Integration

Screenshot API for Node.js

Capture website screenshots in Node.js with a single HTTP request. No Puppeteer, no Chrome binary, no headless browser to manage. Just fetch and get an image back.

  • No Puppeteer or Chrome install — zero system dependencies
  • Works in AWS Lambda, Vercel Edge, and any serverless runtime
  • Native fetch in Node.js 18+ — no extra packages needed
  • TypeScript types included in the API response contract
  • Handles rendering, timeouts, and retries on the server side
  • Free tier: 100 screenshots/month, no credit card required
JavaScript
import fs from 'fs/promises'

const API_KEY = process.env.WEBCAPTURE_API_KEY

async function screenshot(url) {
  const params = new URLSearchParams({ url, format: 'png', width: '1280' })

  const res = await fetch(
    `https://api.webcaptureapi.com/api/screenshot?${params}`,
    { headers: { 'x-api-key': API_KEY } }
  )

  if (!res.ok) {
    const body = await res.json()
    throw new Error(`${res.status}: ${body.error}`)
  }

  return Buffer.from(await res.arrayBuffer())
}

const buffer = await screenshot('https://example.com')
await fs.writeFile('screenshot.png', buffer)

More examples

Common patterns for Node.js apps.

Full-page capture

JavaScript
// Full-page screenshot (captures entire scrollable page)
const params = new URLSearchParams({
  url: 'https://example.com',
  format: 'jpeg',
  quality: '85',
  width: '1440',
  full_page: 'true',
})

const res = await fetch(
  `https://api.webcaptureapi.com/api/screenshot?${params}`,
  { headers: { 'x-api-key': process.env.WEBCAPTURE_API_KEY } }
)

AWS Lambda handler

JavaScript
// AWS Lambda handler
export const handler = async (event) => {
  const { url } = JSON.parse(event.body)

  const params = new URLSearchParams({ url, format: 'jpeg', quality: '85' })
  const res = await fetch(
    `https://api.webcaptureapi.com/api/screenshot?${params}`,
    { headers: { 'x-api-key': process.env.WEBCAPTURE_API_KEY } }
  )

  if (!res.ok) return { statusCode: res.status }

  const buffer = Buffer.from(await res.arrayBuffer())

  return {
    statusCode: 200,
    headers: { 'Content-Type': 'image/jpeg' },
    body: buffer.toString('base64'),
    isBase64Encoded: true,
  }
}

TypeScript

TypeScript
interface ScreenshotOptions {
  url: string
  format?: 'png' | 'jpeg'
  width?: number
  height?: number
  full_page?: boolean
  quality?: number
  delay?: number
}

async function screenshot(options: ScreenshotOptions): Promise<Buffer> {
  const params = new URLSearchParams(
    Object.entries(options)
      .filter(([, v]) => v !== undefined)
      .map(([k, v]) => [k, String(v)])
  )

  const res = await fetch(
    `https://api.webcaptureapi.com/api/screenshot?${params}`,
    { headers: { 'x-api-key': process.env.WEBCAPTURE_API_KEY! } }
  )

  if (!res.ok) {
    const body = await res.json() as { error: string }
    throw new Error(`Screenshot failed (${res.status}): ${body.error}`)
  }

  return Buffer.from(await res.arrayBuffer())
}

What you can build

OG image generation

Generate dynamic open graph images for social sharing by screenshotting a rendered template URL.

Visual regression tests

Screenshot your app before and after deploys to catch unintended layout changes automatically.

PDF reports

Capture dashboard or report pages and assemble them into PDF documents for clients.

Thumbnail previews

Generate link preview thumbnails for bookmarking tools, CMS editors, or browser extensions.

Competitor monitoring

Schedule recurring captures of competitor pages and get notified when their content changes.

Website archiving

Preserve the visual state of web pages at a point in time for audits or compliance records.

Start capturing screenshots in Node.js

Free tier — 100 screenshots/month, no credit card required.

Get your free API key