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.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
| 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
- 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.
Rank #3
- 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
- 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-Afterheader. 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 aRetry-Afterheader 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.
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.
Example using Node.js fetch (the API key stays on the server):
Best Value
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.
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.
Quick Recap
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.




