October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Call a Website Screenshot API from a Node.js App

A practical Node.js guide to calling a screenshot API with fetch, handling JSON or binary output, protecting credentials, and troubleshooting common failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Node.js’s built-in fetch to send a screenshot provider’s documented request, check the HTTP status, and then parse the response in the format that provider returns. Keep the API key on your server: providers differ in endpoint, authentication, option names, output type, quotas, and retention, so adapt the request and response handling to the service you choose.

Call a screenshot API with Node.js fetch

This example follows Screenshot API’s documented REST contract: POST to its screenshot endpoint with Bearer authentication and a JSON body, then read a JSON response containing screenshotUrl. It is provider-specific, not a universal screenshot API format. The example was not executed; confirm the selected service’s current endpoint, response schema, timeout behavior, and error format before deploying it. Screenshot API documentation.

const apiKey = process.env.SCREENSHOT_API_KEY;
if (!apiKey) throw new Error('Set SCREENSHOT_API_KEY in the server environment');

const response = await fetch('https://api.screenshot-api.org/api/v1/screenshot', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com',
    viewport: { width: 1280, height: 720 },
    format: 'png',
    fullPage: true,
  }),
});

if (!response.ok) {
  const detail = await response.text();
  throw new Error(`Screenshot request failed (${response.status}): ${detail}`);
}

const result = await response.json();
console.log(result.screenshotUrl);

Run this in a server-side Node.js environment that supports global fetch. Set SCREENSHOT_API_KEY through your deployment’s environment or secret manager; never place it in frontend JavaScript, a public repository, or a client-visible URL. If the provider returns a URL, treat that URL as sensitive if it embeds credentials, and check how long the provider retains the image.

Adapt the request and response to your provider

Do not assume that another provider accepts this endpoint, field names, authentication scheme, or JSON response. Read its API reference and make the request body and parser match that contract.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Contract detail What to verify
Endpoint and method Whether it uses GET or POST, and the exact route.
Authentication Whether the key belongs in a Bearer header, an API-key header, or another documented location.
Request options Exact names and supported values for URL, viewport, format, full-page capture, waits, and selectors.
Success response Whether the result is JSON with an image URL, raw image bytes, a redirect, or another documented type.
Limits and storage Current rate limits, quota reset and overage behavior, retention period, and failure or refund semantics.

When the response is an image rather than JSON

For a provider that documents raw image bytes, do not call response.json(). Read response.arrayBuffer() and save or upload those bytes using your application’s storage flow. For example, with a provider-specific request already stored in response:

const bytes = Buffer.from(await response.arrayBuffer());
await import('node:fs/promises').then(({ writeFile }) =>
  writeFile('screenshot.png', bytes)
);

Use the file extension and content type documented by the provider; the sample filename assumes the response is actually PNG.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Other documented Node.js patterns

Screenshot Scout documents a Node.js SDK and a JSON mode where the image URL is at response.result.screenshotUrl; its default capture flow can return image bytes. screenshotapis.org documents a direct POST using X-Api-Key or Bearer authentication and raw image bytes on success. These contracts are not interchangeable with the JSON example above. Screenshot Scout documentation; screenshotapis.org API reference.

Choose capture settings and wait behavior

Start with the smallest set of options your use case needs, then add controls supported by the provider. Commonly documented options include viewport width and height, PNG/JPEG/WebP format, full-page capture, device scale factor, selector capture, wait strategy, extra delay, dark mode, and injected CSS or JavaScript. Names, constraints, and availability can differ; some advanced controls may be POST-only.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Viewport and full page: Set dimensions for the intended layout. Full-page captures may be taller and larger than viewport captures.
  • Wait strategy: Prefer a documented selector or page-state condition when you know what must appear. Network-idle waits can help with dynamic pages but may not suit pages with ongoing network activity.
  • Fixed delay: A delay can accommodate late UI, but increases request time and does not guarantee the expected content loaded.
  • Selector capture: Useful for a specific component, but depends on the selector remaining valid as the page changes.
  • Output format: Choose a format the API supports and that fits your downstream use, then parse the corresponding response type.

Screenshot API documents network-idle options, selector waiting, delays, and selector capture controls. Check the provider’s current reference for exact values and limits rather than copying an option from another API. Screenshot API documentation.

Handle failures, limits, and remote URL access

Check response.ok before parsing success data. A non-2xx result may mean invalid credentials, invalid input, rate limiting, exhausted quota, or a rendering failure. Interpret status codes and error bodies using the selected API’s documentation; no universal quota or retry policy applies.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
  • Rate limiting: For a documented 429 response, follow that provider’s retry guidance and any Retry-After header. Avoid tight retry loops. Screenshot API documents 429 rate-limit or quota errors and response headers; screenshotapis.org says its rate window is per API key and documents a Retry-After header when limited. Screenshot API documentation; screenshotapis.org API reference.
  • Unreachable page: A remote renderer may not be able to reach a local, staging, or private-network URL. screenshotapis.org documents rejecting private and reserved IP destinations as an SSRF safeguard. screenshotapis.org API reference.
  • Logged-in content: Do not assume the remote browser inherits your local browser session or cookies. screenshot-api.net says its cloud service is unsuitable for pages available only in a logged-in local browser session. screenshot-api.net.
  • Durability: If your application needs long-term access, copy the returned image to storage you control and verify the provider’s retention terms. One getting-started page documents 24-hour retention; do not assume that period applies to other services. ScreenshotAPI getting-started documentation.

Use bounded timeouts and concurrency appropriate to your application, and record status codes and provider error details without logging API secrets. Provider limits and rendering behavior vary, so check current account terms before setting retry, queue, or capacity assumptions. No latency, image-quality, or reliability benchmarks are established here.

Troubleshoot common integration problems

  • 401 or 403: Confirm the key is present, active, and sent using the provider’s exact authentication header or parameter.
  • 400 or validation error: Compare request field names, required fields, allowed formats, and option values against that service’s reference.
  • 429: Reduce request frequency or concurrency, check quota and reset rules, and honor documented retry headers rather than retrying continuously.
  • JSON parsing fails: The provider may have returned binary image data, an error body, or a different JSON schema. Check status and documented content type before selecting a parser.
  • Screenshot is blank or incomplete: Confirm the target is reachable by the remote renderer, select an appropriate wait condition, and verify any requested selector exists on the rendered page.
  • Private or authenticated page cannot load: Confirm remote access is supported and explicitly configure any provider-supported authentication mechanism. Do not expose session cookies or credentials to an untrusted target.
  • URL works locally but not in the API: The API renders remotely, so it does not automatically share local DNS, network access, or browser session state.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a PNG, JPEG, WebP, or PDF; its parameter names also work with those used by other screenshot APIs, which can make switching easier. Cookie banners are accepted and 60+ known consent platforms, newsletter popups, and chat widgets are removed before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example using Node.js fetch (the API key stays on the server):

const q = new URLSearchParams({ access_key: process.env.SCREENSHOTNEO_API_KEY, url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`ScreenshotNeo request failed (${res.status})`);
const bytes = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(({ writeFile }) => writeFile('shot.webp', bytes));

See the ScreenshotNeo API documentation for request options and response details. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Every feature is on every plan. Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Can I call a screenshot API directly from browser-side JavaScript?

Make the request from your backend so the API key is not exposed to visitors.

Does a screenshot API return a hosted URL or image bytes?

Either is possible; check the selected provider’s documented response and parse it accordingly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can a remote screenshot API capture localhost or a page I am logged into?

Not necessarily. Remote services may not reach private addresses or inherit your local browser session.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.