Screenshot API vs Browser Automation API for Webpage Captures
Choose a screenshot API for a defined capture request; choose browser automation when you must interact with the page or keep state before capturing it.
A screenshot API is the better fit when you can describe the capture in one request: the page or HTML to render, when it is ready, the viewport, and the output format. A browser automation API or session is the better fit when you must log in, click, fill a form, inspect what changed, make a decision, or preserve state across several steps.
For a single configured capture, an HTTP screenshot endpoint keeps the integration small. For a workflow that depends on what the page shows after each action, use browser control. Some providers offer both: Browserless documents REST endpoints as stateless, single-action requests, and recommends browser sessions or connections for persistent interactive work. Browserless REST API overview
1. What each API does
| Question | Screenshot API | Browser automation API or session |
|---|---|---|
| Primary job | Render a URL or supplied HTML and return an image. | Control a browser to carry out one or more actions; a screenshot can be one result. |
| State | Usually scoped to one request. Persistence depends on the provider and endpoint. | A live context can retain cookies, storage, open pages, and other state while the session stays active. |
| Interaction | Often supports configured waits, selectors, and capture settings, but not live branching. | Can navigate, click, fill forms, inspect results, and choose the next action in code. |
| Integration | Usually an HTTP request and a binary response. | Usually browser-control code connected to a local or managed browser. |
| Typical output | PNG, JPEG, WebP, or sometimes PDF. | Whatever the workflow requests, including a screenshot after setup. |
“API” alone does not mean that a browser session persists. Browserless says its REST calls launch a browser for one task and discard state after the response; its browser connections support interactive Playwright or Puppeteer work. That behavior is specific to its documented interfaces, so check the provider and endpoint you plan to use. Browserless REST API limitations · Browserless connection URLs
2. Choose by the work that happens before the screenshot
Use a screenshot API when
- The target URL or HTML is known in advance.
- The capture can be fully described with settings such as viewport, full-page mode, format, selector, and a readiness condition.
- You are generating previews, snapshots, reports, or images as one step in a larger service.
- You do not need to observe intermediate page states or decide what to do based on them.
Use browser automation when
- You must authenticate through a user-visible flow or use a stateful browser context.
- You need to click a control, fill a field, submit a form, or move through a multi-step workflow before capturing.
- The next action depends on content observed after navigation or interaction.
- You need to inspect the page between steps, handle conditional dialogs, or debug a complicated interaction.
If the page only needs a known wait or selector before capture, a screenshot endpoint may already cover it. Confirm the exact endpoint’s settings against the workflow. If you need a live decision after the page changes, use automation. Browserless, for example, says its REST API cannot click a button, fill a form, and scrape the result as a multi-step operation in one request. Browserless REST API limitations
3. Screenshot API example: capture a page with Browserless
The following request sends a URL and screenshot settings to Browserless’s documented REST endpoint. It writes the binary image response to a file. Replace the token with your own and choose a URL you are authorized to capture. Browserless Screenshot API documentation
curl -X POST \
"https://production-sfo.browserless.io/screenshot?token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/","options":{"fullPage":true,"type":"png"}}' \
--output screenshot.png
A small Python version that checks the response before saving it:
import requests
endpoint = "https://production-sfo.browserless.io/screenshot"
response = requests.post(
endpoint,
params={"token": "YOUR_API_TOKEN"},
headers={"Content-Type": "application/json"},
json={
"url": "https://example.com/",
"options": {"fullPage": True, "type": "png"},
},
timeout=90,
)
response.raise_for_status()
with open("screenshot.png", "wb") as image_file:
image_file.write(response.content)
A Node.js version using the built-in fetch API (Node.js 18 or newer):
import { writeFile } from "node:fs/promises";
const endpoint = new URL("https://production-sfo.browserless.io/screenshot");
endpoint.searchParams.set("token", process.env.BROWSERLESS_TOKEN ?? "YOUR_API_TOKEN");
const response = await fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://example.com/",
options: { fullPage: true, type: "png" },
}),
signal: AbortSignal.timeout(90_000),
});
if (!response.ok) {
throw new Error(`Screenshot request failed: ${response.status} ${await response.text()}`);
}
await writeFile("screenshot.png", Buffer.from(await response.arrayBuffer()));
Settings to decide before calling
- Viewport or full page: A viewport capture records what is visible at a specific size. A full-page capture records the page’s document height, subject to provider limits and page behavior.
- Selector or clip: Capture a specific element when the endpoint supports a selector; use a fixed clip rectangle when you know the coordinates. Browserless documents both selector and clip options.
- Readiness: Choose a selector, event, network condition, or delay that corresponds to the content you need. A page load event alone may precede data rendered by client-side code.
- Format and dimensions: Select PNG, JPEG, or WebP according to fidelity, file size, and downstream support. Set viewport and device scale deliberately so captures are comparable.
- Inline HTML: Some endpoints accept HTML instead of a URL. Browserless documents that its
htmlfield should not be combined withurlin the same request. - Long and lazy-loaded pages: Scrolling can trigger content that is loaded only when it approaches the viewport. ScreenshotOne documents scroll-and-stitch capture and recommends adjusting scroll distance or delay when lazy-loaded elements are missing. ScreenshotOne full-page screenshot guide
- Motion: Animated images, canvas, video, and JavaScript animation can produce different pixels across captures. Reduced-motion settings are best-effort and do not guarantee identical output. ScreenshotOne full-page screenshot guide
4. Browser automation example: interact, then capture
When the screenshot depends on an action or observed state, use a browser-control library. This Playwright example connects to a managed Browserless browser, opens a page, clicks a known button, waits for the resulting content, and saves a screenshot. Set BROWSERLESS_TOKEN in the environment first. Selectors and URLs are examples; adapt them to the page you own or are permitted to automate.
import { chromium } from "playwright";
const token = process.env.BROWSERLESS_TOKEN;
if (!token) throw new Error("Set BROWSERLESS_TOKEN first");
const browser = await chromium.connectOverCDP(
`wss://production-sfo.browserless.io/chromium/playwright?token=${token}`
);
try {
const context = browser.contexts()[0] ?? await browser.newContext();
const page = context.pages()[0] ?? await context.newPage();
await page.goto("https://example.com/account", { waitUntil: "domcontentloaded" });
await page.getByLabel("Email").fill(process.env.TEST_EMAIL ?? "user@example.com");
await page.getByLabel("Password").fill(process.env.TEST_PASSWORD ?? "replace-me");
await page.getByRole("button", { name: "Sign in" }).click();
await page.getByRole("heading", { name: "Dashboard" }).waitFor();
await page.screenshot({ path: "dashboard.png", fullPage: true });
} finally {
await browser.close();
}
Install Playwright with npm install playwright. Use test credentials and an authorized test environment; do not hard-code real credentials into source control. Browserless documents Playwright connections through a WebSocket URL. Browserless connection URLs
Keep the workflow reliable
- Wait for a meaningful result, such as a heading or application state, instead of relying only on an arbitrary sleep.
- Set timeouts for navigation and selectors; fail with a useful error if the expected state never appears.
- Keep browser contexts isolated between users or jobs when cookies and storage must not be shared.
- Close the browser or release the managed session in a
finallyblock so failures do not leave sessions consuming resources. - Make actions idempotent where possible, and retry only failures that are safe to repeat. A click that submits payment or creates data should not be blindly retried.
- Capture a diagnostic screenshot or log the failed step when debugging, while protecting credentials and personal data.
5. A practical decision table
| Requirement | Start with | Reason |
|---|---|---|
| Capture a public URL once at a chosen size | Screenshot API | The request already describes the work. |
| Capture a page after a predictable selector appears | Screenshot API, if it supports selector waits | A configured wait may be sufficient without a live session. |
| Capture a logged-in page with an existing, supported profile | Either; verify session support | Some screenshot services can reuse profiles, while many single-action endpoints do not preserve state by default. |
| Log in, change a setting, then capture the result | Browser automation | The workflow has multiple dependent actions. |
| Inspect a response and branch on what appeared | Browser automation | The next step depends on live page state. |
| Capture a long page with lazy images | Either, with scroll behavior configured | Verify that the capture process triggers lazy loading and handles sticky or virtualized content. |
| Run high-volume recurring snapshots | Compare providers using your workload | Measure your actual regions, pages, concurrency, output sizes, and failure cases. |
6. Or skip the browser setup
If the task is a defined screenshot request, ScreenshotNeo provides a website screenshot API and an MCP server for developers. One GET request returns an image or PDF. The example below saves a WebP capture; see the ScreenshotNeo API documentation for request options and response details.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await import('node:fs/promises').then(({ writeFile }) =>
writeFile('shot.webp', Buffer.from(await res.arrayBuffer()))
);
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every plan includes the features: 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.
7. Performance, reliability, and cost
- Request size and output size: Full-page and high-density captures can create large images. Pick only the dimensions and detail your downstream use needs; consider JPEG or WebP when transparency is unnecessary and smaller files help.
- Waits trade speed for completeness: A longer readiness condition can avoid capturing incomplete content but increases the time each job occupies a browser. Prefer a specific state signal over a large fixed delay.
- Automation has more moving parts: Sessions, navigation, selectors, authentication, and cleanup create more failure points than a single screenshot request. Use it when those capabilities solve a real requirement.
- Page behavior affects repeatability: Personalized content, A/B tests, geolocation, current data, animation, and bot checks can change the result. Fix relevant inputs where possible and compare captures in the same environment.
- Measure costs on representative jobs: Providers may meter requests, browser time, concurrency, or other resources differently. The reviewed official documentation does not establish a comparable speed, reliability, or cost winner. Run representative pages through the exact configuration before choosing.
- Cache deliberately: Caching may reduce repeated work when the page has not changed, but it can return stale captures. Set the freshness policy based on how often the page changes and whether each request must reflect current state.
8. Troubleshooting
| Symptom | Likely cause | What to check |
|---|---|---|
| HTTP error instead of an image | Invalid credentials, malformed request, unavailable endpoint, or request limit. | Check the status and response body before saving bytes as an image. Confirm the endpoint, token, JSON body, and account limits. |
| File exists but will not open as an image | An error response was written to the image path. | Check HTTP status and content type before writing the response. Log a short error body safely. |
| Blank, CAPTCHA, or access-denied page | The target may be blocking automated browsers. | Treat it as a failed capture of the intended content. Browserless lists blank captures, CAPTCHA pages, access-denied responses, and missing elements as signs of blocking. Do not assume a screenshot endpoint guarantees access. Browserless screenshot troubleshooting |
| Page is captured before its content appears | The chosen navigation event does not represent application readiness. | Wait for a page-specific selector or state. Increase a delay only if the site has no reliable readiness signal. |
| Images are missing below the fold | Lazy loading was not triggered before capture. | Enable the provider’s full-page scrolling or scroll-and-stitch mode; adjust scroll distance and pauses. ScreenshotOne full-page capture guidance |
| Element selector times out | Wrong selector, content not loaded, element inside a frame, or consent overlay. | Confirm the selector in a normal browser, wait for the relevant frame or state, and handle overlays if interaction is required. |
| Automation cannot find the page or context | The connection or session setup differs from the library’s expected mode. | Verify the WebSocket URL and token, library compatibility, and whether the provider expects a new context or an existing one. |
| Two captures differ unexpectedly | Dynamic data, motion, personalization, responsive layout, or timing changed. | Fix viewport, locale, timezone, and data where possible; wait for a stable state and account for animations. Pixel-identical rendering is not guaranteed for moving content. |
| Capture is cut off or extremely tall | Full-page behavior may not suit a virtualized or endlessly loading page. | Capture a bounded region, a specific element, or a known scroll range. Define what “full page” means for the application. |
9. Frequently asked questions
Can I take a screenshot with an API?
Yes. A screenshot endpoint accepts a request and returns an image. Browserless’s documented endpoint uses a POST to /screenshot with a URL and optional screenshot settings. Browserless Screenshot API
Is a screenshot API the same as a browser automation API?
No. A screenshot API focuses on producing a capture from a configured request. Browser automation exposes browser actions and observations that can prepare the page first. A provider can offer both kinds of interface.
Can a screenshot API capture a page after login?
Sometimes. It depends on whether the service supports authenticated profiles, cookies, or other persisted state for that endpoint. If the workflow requires performing login actions during the job, browser automation is the more direct fit.
Which approach should I use for visual regression testing?
Use the simplest interface that can reliably reach the exact state under test. If pages are already accessible and deterministic, a screenshot endpoint may be enough. If setup steps or conditional UI must run first, automate those steps and capture afterward.
Does browser automation guarantee that a site will allow the capture?
No. The target can still serve a challenge, denial page, or different content to automated traffic. Inspect the result and handle access failures as failures rather than treating the returned pixels as the requested page.
