How to Add a Custom Delay to ScreenshotMachine CLI Screenshots
Add Screenshot Machine’s delay parameter to a curl screenshot request. Learn the millisecond values, common pitfalls, and when a fixed wait may not be enough.
To add a custom delay to a Screenshot Machine screenshot request, pass the API’s delay parameter in milliseconds. In the documented Bash and curl workflow, set a value such as 2000 for two seconds, URL-encode it in the request arguments, and save the image response to a file. Screenshot Machine documents this API parameter; the cited documentation does not establish a separate ScreenshotMachine CLI executable or a dedicated CLI flag.
DELAY="2000"
ARGS+=(--data-urlencode "delay=$DELAY")
curl -Gs "https://api.screenshotmachine.com" "${ARGS[@]}" > output.png
This short form assumes ARGS already contains the required customer key and target URL. The complete example below shows the request end to end. See Screenshot Machine’s API documentation for the vendor’s request options and delay details.
1. Build a complete Bash and curl request
Set your customer key, target URL, and delay, then pass them as URL-encoded query parameters. Replace the placeholder key and URL before running the command.
#!/usr/bin/env bash
set -euo pipefail
CUSTOMER_KEY="YOUR_CUSTOMER_KEY"
TARGET_URL="https://example.com"
DELAY="2000"
OUTPUT="output.png"
ARGS=(
--data-urlencode "key=$CUSTOMER_KEY"
--data-urlencode "url=$TARGET_URL"
--data-urlencode "delay=$DELAY"
)
curl --fail --silent --show-error -G \
"https://api.screenshotmachine.com" \
"${ARGS[@]}" \
--output "$OUTPUT"
printf 'Saved screenshot to %s\n' "$OUTPUT"
-G tells curl to send the supplied data as query parameters on a GET request. --data-urlencode encodes parameter values, including URLs that contain characters such as &. --fail --silent --show-error makes HTTP failures return a nonzero status while still showing an error message. The documented vendor example redirects the response to a file; --output does the same without mixing image bytes with terminal output.
2. Choose a delay value
The delay is a fixed wait before capture, measured in milliseconds. The documented default is 200 ms. Screenshot Machine lists these values: 0, 200, 400, 600, 800, 1000, and each additional 1000 ms from 2000 through 10000.
| Value | Wait time | When to consider it |
|---|---|---|
0 |
Immediate | Use when the page is already ready at navigation. |
200 |
0.2 seconds | Documented default. |
400–1000 |
0.4–1 second | A modest extra wait for pages that render shortly after navigation. |
2000 |
2 seconds | A reasonable starting point when images or animations need more time. |
3000–10000 |
3–10 seconds | Try a longer documented wait if the target page visibly needs it. |
For full-length pages with more images or animations, Screenshot Machine suggests a higher delay, giving 2000 ms or more as an example. This is not a guarantee that all images, scripts, or other page activity have finished. The parameter is a timer, not a wait-until-ready condition.
3. Use delay from Python or Node.js
The same API parameter can be sent from application code. The examples below use the documented Screenshot Machine endpoint and millisecond value. Store credentials outside source control in a secret or environment variable in real deployments.
Python
import os
import requests
customer_key = os.environ["SCREENSHOTMACHINE_KEY"]
target_url = "https://example.com"
delay_ms = 2000
response = requests.get(
"https://api.screenshotmachine.com",
params={"key": customer_key, "url": target_url, "delay": delay_ms},
timeout=90,
)
response.raise_for_status()
with open("output.png", "wb") as image_file:
image_file.write(response.content)
Node.js
const customerKey = process.env.SCREENSHOTMACHINE_KEY;
if (!customerKey) throw new Error("Set SCREENSHOTMACHINE_KEY first");
const params = new URLSearchParams({
key: customerKey,
url: "https://example.com",
delay: "2000",
});
const response = await fetch(
`https://api.screenshotmachine.com?${params.toString()}`
);
if (!response.ok) {
throw new Error(`Screenshot request failed: HTTP ${response.status}`);
}
const image = Buffer.from(await response.arrayBuffer());
await import("node:fs/promises").then(({ writeFile }) =>
writeFile("output.png", image)
);
These examples set a 90-second Python request timeout and use Node’s fetch response status before writing the bytes. Adjust the client timeout to suit your application and the vendor’s response behavior; a longer delay increases the time the request may take.
4. Check the result and handle errors
- The result still shows a loader or missing images: increase the delay using a documented value, such as
2000or more. A fixed delay cannot guarantee readiness if the page loads unpredictably. - The request fails before producing an image: check the customer key, endpoint, connectivity, and target URL. Use curl’s
--fail --show-erroroptions so HTTP failures are visible rather than saved as if they were image data. - The saved file is not a viewable image: inspect the HTTP response and confirm the request succeeded. An error response saved with an image filename is still an error response.
- A URL with query parameters behaves incorrectly: pass it as one value with
--data-urlencode "url=$TARGET_URL"; do not concatenate it into the request URL by hand. - A chosen delay is rejected or behaves unexpectedly: use one of the values listed in Screenshot Machine’s API documentation and express it in milliseconds. For example,
2000means two seconds, not 2000 seconds. - The request takes too long: remember that the delay adds waiting time before capture. Keep it as low as the page allows and set a client-side timeout that accommodates the wait plus navigation and image transfer.
5. Reliability, speed, and cost considerations
A custom delay can improve captures of pages whose content appears shortly after navigation, but it trades latency for that extra time. Start with the smallest documented value that produces the needed result, then increase it for pages with slow images or animation. If readiness depends on a specific element or network activity, a timer alone is inherently less reliable because page load time varies.
The research sources do not specify Screenshot Machine pricing, billing treatment for delays, or a performance benchmark, so this guide makes no cost or speed claims beyond the direct effect of waiting longer. For production use, handle non-success HTTP responses, set a bounded request timeout, and avoid logging API credentials.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. Its one-request API handles the capture without setting up a browser locally; its options include waits by delay, selector, or network idle. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a 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
Is there a ScreenshotMachine CLI flag for delay?
The cited official instructions document a Bash and curl API request with a delay query parameter. They do not establish a dedicated CLI executable or flag.
Does a 2000 ms delay mean the page is fully loaded?
No. It means the capture waits two seconds. It does not certify that every image, animation, or script has finished.
Can I set delay to zero?
Yes. Screenshot Machine lists 0 as an available value for an immediate capture.


