Skip to main content
The screenshot tool captures a fully javascript-rendered screenshot of a given webpage using Chromium, without writing any automation code. Call POST /v1/tools/screenshot with the target url, and the API returns the captured image as a PNG. The tool can run standalone or against an existing browser session — pass an optional sessionId query parameter to execute it on a running session (for example, to capture a page behind authentication).
PDF URLs are not supported by the screenshot tool.

Request options

  • url: The URL of the webpage to capture.
  • width / height: Browser viewport dimensions in pixels.
  • image_quality: Quality of the output image, on the range 1-100. 100 will not perform any compression.
  • wait: Duration in milliseconds to wait after the page has loaded, mainly used for sites with JS animations.
  • scroll_all_content: If true, scrolls the page and captures all visible content.
  • capture_full_height: If true, captures the entire height of the page, ignoring the viewport height.
  • s3_target_address: Presigned S3 url target to upload the image to.
See the full API reference for details.

Code example

const fs = require('fs');

const apiKey = process.env.ANCHOR_API_KEY;

const res = await fetch('https://api.anchorbrowser.io/v1/tools/screenshot', {
  method: 'POST',
  headers: {
    'anchor-api-key': apiKey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://news.ycombinator.com',
    width: 1440,
    height: 900,
    capture_full_height: true,
  }),
});
if (!res.ok) {
  throw new Error(`screenshot failed: ${res.status} ${await res.text()}`);
}
const buffer = Buffer.from(await res.arrayBuffer());
fs.writeFileSync('screenshot.png', buffer);
console.log('saved screenshot.png');