ScreenshotNeo

BlogHow-to

How to Capture a Website with ScreenshotMachine CLI After JavaScript Loads

ScreenshotMachine’s documented CLI workflow is Bash and curl calling its screenshot API. Learn how to tune its fixed delay, save captures, and handle common errors.

By the ScreenshotNeo team4 October 20267 min read

ScreenshotMachine’s documented command-line workflow is a Bash script that uses curl to call its HTTP screenshot API; the reviewed documentation does not describe a separately installed ScreenshotMachine CLI binary. To give JavaScript-rendered content more time to appear, set the API’s delay parameter to a longer supported wait, save the response, and inspect the image. This is a fixed elapsed-time wait, not a signal that JavaScript or network activity has finished. ScreenshotMachine API documentation.

1. Capture a page with the ScreenshotMachine Bash and curl workflow

Get a customer key, choose a target URL and capture settings, then run this Bash example. It follows the vendor’s documented request pattern and uses a 2,000 millisecond delay. Replace the key and URL before running it.

#!/usr/bin/env bash
set -euo pipefail

CUSTOMER_KEY="YOUR_CUSTOMER_KEY"
SECRET_PHRASE="" # Set this only if a secret phrase is enabled for the account.
URL="https://example.com"
DIMENSION="1366x768"
DEVICE="desktop"
FORMAT="png"
CACHE_LIMIT="0"
DELAY="2000"
ZOOM="100"
OUTPUT="output.png"

ARGS=(
  --data-urlencode "key=$CUSTOMER_KEY"
  --data-urlencode "dimension=$DIMENSION"
  --data-urlencode "device=$DEVICE"
  --data-urlencode "format=$FORMAT"
  --data-urlencode "cacheLimit=$CACHE_LIMIT"
  --data-urlencode "delay=$DELAY"
  --data-urlencode "zoom=$ZOOM"
  --data-urlencode "url=$URL"
)

if [[ -n "$SECRET_PHRASE" ]]; then
  HASH=$(printf '%s' "$URL$SECRET_PHRASE" | md5sum | cut -d ' ' -f 1)
  ARGS+=(--data-urlencode "hash=$HASH")
fi

curl -fGs "https://api.screenshotmachine.com" "${ARGS[@]}" -o "$OUTPUT"
printf 'Saved screenshot to %s\n' "$OUTPUT"

The required inputs are key and url. The remaining fields control the rendering and response. --data-urlencode encodes values so reserved characters in a page URL or selector do not break the query. Keep credentials out of source control and public client-side code.

2. Tune the wait for JavaScript-rendered content

The vendor documents a default delay of 200 ms and discrete accepted values of 0, 200, 400, 600, 800, 1,000, then 2,000 through 10,000 ms in 1,000 ms steps. Start with 2,000 ms for a page that renders content after its initial response, then compare captures at longer accepted waits if the expected content is still missing.

  1. Run the same URL and viewport with a 2,000 ms delay.
  2. Open the output image and identify what is missing: application content, an image, a post-animation state, or a full-page section.
  3. Increase the delay to another supported value and capture again. Treat this as tuning, not a guarantee that all asynchronous work has completed.
  4. When comparing results, keep other settings and the target state consistent so the effect of the delay is clear.

A longer wait can give client-side rendering, animations, and late images more time. It also adds waiting to each capture. ScreenshotMachine documents elapsed delay before capture, not a JavaScript-ready, DOM-ready, or network-idle condition. If content depends on login, a cookie, or an interaction, time alone may not make it appear.

3. Choose dimensions, device, format, and cache behavior

Parameter What it controls Usage notes
dimension Viewport width and height, written as widthxheight, or full-page height Documented width range is 100–1,920 and height range is 100–9,999. Use full as the height for a full-page capture, for example 1366xfull.
device Rendering context: desktop, phone, or tablet Match the intended layout. Documented examples include desktop 1024×768, phone 480×800, and tablet 800×1280.
format Response image format Supported values are jpg, png, and gif; the documented default is JPG. Make the output filename’s extension match the selected format.
delay Fixed time to wait before capture, in milliseconds Default is 200 ms; use a documented accepted value up to 10,000 ms when the page needs more time.
cacheLimit Maximum acceptable screenshot age Accepted range is 0–14 days, including decimal values for sub-day freshness. Set it to 0 when requesting a fresh capture.
zoom Screenshot zoom setting The vendor’s Bash example uses 100. Keep it at the intended value when comparing delays.

Full-page captures can take longer to render, especially on pages with late images or animations. The vendor’s guide recommends allowing a longer delay, such as 2,000 ms or more, for long pages with those characteristics. A full-page dimension captures page length; it does not itself verify that every lazy-loaded asset finished loading.

4. Use selectors, cookies, and request settings when needed

The API documents additional inputs for controlling what is captured and how the page is requested. Encode selector values, especially selectors containing #, as well as other reserved characters.

  • click: click a CSS-selected element before capture, when an interaction is needed to reveal content.
  • hide: hide selected elements, such as a cookie dialog, in the resulting capture.
  • selector: capture a single DOM element selected by CSS.
  • crop: crop to a pixel rectangle.
  • cookies: supply cookies when the target page requires them.
  • accept-language and user-agent: set the request language and user-agent when the page response depends on those values.

These controls can address page state or capture scope, but they do not turn delay into a readiness detector. Use the vendor’s parameter documentation for exact request syntax and supported values.

5. Troubleshoot incomplete or failed captures

Symptom or error Likely cause What to check
JavaScript content is absent The fixed wait is too short, or the content requires an interaction, authentication, or other state. Increase delay using an accepted value; inspect whether cookies or a click are required. If the content remains absent, check whether the page is accessible to the capture service.
invalid_key or missing_key The key is invalid or was not sent. Check the account key and the encoded key argument.
invalid_url or missing_url The target URL is malformed or missing. Use a complete URL, including its scheme, and verify the encoded url value.
invalid_hash A secret phrase is configured but the hash is missing or incorrect. Calculate the documented MD5 hash from the URL parameter value concatenated with the secret phrase, and send it as hash. Do not expose the secret phrase.
invalid_selector The CSS selector is invalid or does not match the expected input form. Check selector syntax and URL-encode the value, including reserved characters such as #.
invalid_crop The crop rectangle is invalid. Review the rectangle coordinates and dimensions against the documented crop format.
no_credits The account has no available credits for a fresh screenshot. Review account usage and available capacity.
Saved file contains an error image The API returned an error image rather than the expected screenshot. Inspect the X-Screenshotmachine-Response response header for its error code. Avoid assuming every image response is a successful capture.

6. Improve repeatability, performance, and cost control

  • Use the smallest adequate delay. A longer fixed wait increases capture latency, so tune against the target page and avoid using the maximum by default.
  • Set cache freshness deliberately. Use cacheLimit=0 when the latest page state matters. A positive limit can allow a cached image within the configured age. Screenshot Machine says cached screenshot loads are not billed and describes a 14-day screenshot cache; check the current service terms and pricing for account-specific details.
  • Keep rendering inputs stable. Hold viewport, device, zoom, cookies, language, and cache policy steady when diagnosing differences. Dynamic page content can still vary between captures.
  • Handle credentials as secrets. Do not commit a real key or secret phrase. If a secret phrase is enabled, calculate and send the required hash without publishing the phrase.
  • Check the response, not just the file. Save and inspect the response headers when diagnosing API errors, and visually check that the intended post-JavaScript content appears.

Screenshot Machine’s pricing page, accessed on 2026-10-03, listed a free allowance of 100 fresh screenshots per month, Basic at €9/month for 2,500, Pro at €59/month for 20,000, and Enterprise at €99/month for 50,000, with additional-screenshot rates on paid plans. Pricing and allowances can change, so verify the vendor’s current pricing page before choosing a plan. Its SLA page was last updated in 2020; that dated availability statement is not evidence of current measured uptime.

7. 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. This example saves a PNG response; see the ScreenshotNeo API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.png
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.png", "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 Bun.write('shot.png', res);

ScreenshotNeo accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, and cache hits cost nothing, and response headers say the page verdict and whether the capture was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up free for 1,000 screenshots a month, with no card required.

FAQ

How do I wait for JavaScript to load before taking a screenshot?

Set a longer delay and inspect the output. It is an elapsed-time wait, not confirmation that JavaScript has completed.

How can I take a full-page screenshot after the page finishes loading?

Use full as the height in dimension, and allow enough delay for the page’s content and images to appear. Verify the result because the API does not document a page-finished event for this purpose.

Is ScreenshotMachine CLI a separate program?

The reviewed official example is a Bash script using curl against the HTTP API. The reviewed source does not document a separately installed CLI binary.

What should I do if a longer delay still produces an incomplete page?

Check whether the page requires authentication, cookies, or a click, then confirm it is accessible to the capture service. A fixed delay cannot guarantee completion of arbitrary asynchronous page work.