How to Hide Cookie Banners in ApiFlash Screenshots
Set ApiFlash’s no_cookie_banners=true option to hide cookie banners and popups. Learn CSS and JavaScript fallbacks, troubleshooting, and a one-call alternative.
Set no_cookie_banners=true in your ApiFlash screenshot request. The option defaults to false; enabling it tells ApiFlash to prevent cookie banners and popups from appearing in the screenshot. The API accepts GET query parameters and POST form data. If the built-in option misses a site-specific banner, inject CSS for a selector you have confirmed on that page.
1. Enable ApiFlash’s built-in banner removal
Add no_cookie_banners=true to the screenshot request. For a GET request, include it as a query parameter; for a POST request, include it as form data. Use a query or form encoder for parameter values, especially when the target URL contains its own query string.
GET with cURL
curl -G 'https://api.apiflash.com/v1/urltoimage' \
--data-urlencode 'access_key=YOUR_API_KEY' \
--data-urlencode 'url=https://example.com' \
--data 'no_cookie_banners=true' \
-o screenshot.png
Use the endpoint and required authentication parameters shown in your ApiFlash account or the current API documentation. The option of interest is no_cookie_banners=true.
POST form data
curl 'https://api.apiflash.com/v1/urltoimage' \
--data-urlencode 'access_key=YOUR_API_KEY' \
--data-urlencode 'url=https://example.com' \
--data 'no_cookie_banners=true' \
-o screenshot.png
POST form fields avoid manually building a query string. Follow the endpoint and authentication details in ApiFlash’s current documentation.
Python
import requests
endpoint = "https://api.apiflash.com/v1/urltoimage"
params = {
"access_key": "YOUR_API_KEY",
"url": "https://example.com",
"no_cookie_banners": "true",
}
response = requests.get(endpoint, params=params, timeout=90)
response.raise_for_status()
with open("screenshot.png", "wb") as image:
image.write(response.content)
Requests encodes the query parameters, including the target URL. Keep the API key out of source control and avoid logging the full request URL if it includes credentials.
Node.js
const endpoint = new URL("https://api.apiflash.com/v1/urltoimage");
endpoint.search = new URLSearchParams({
access_key: "YOUR_API_KEY",
url: "https://example.com",
no_cookie_banners: "true",
});
const response = await fetch(endpoint);
if (!response.ok) {
throw new Error(`ApiFlash request failed: ${response.status} ${response.statusText}`);
}
const image = Buffer.from(await response.arrayBuffer());
await import("node:fs/promises").then(({ writeFile }) =>
writeFile("screenshot.png", image)
);
For production code, set a request timeout appropriate to your workload and handle non-image error responses according to the API response format.
2. Add a page-specific CSS fallback
If the built-in setting does not remove a particular banner, inspect that site’s DOM and identify the specific banner container. ApiFlash documents a css parameter for injecting CSS. Encode the CSS with a standard URL encoder; do not assume a generic selector such as .cookie-banner exists on every site.
curl -G 'https://api.apiflash.com/v1/urltoimage' \
--data-urlencode 'access_key=YOUR_API_KEY' \
--data-urlencode 'url=https://example.com' \
--data 'no_cookie_banners=true' \
--data-urlencode 'css=[data-testid="consent-banner"] { display: none !important; }' \
-o screenshot.png
Replace [data-testid="consent-banner"] with a selector verified on the target page. A broad selector can hide legitimate content or parts of the page. Test the resulting screenshot for every relevant domain and viewport.
3. Use JavaScript only when CSS is not enough
ApiFlash’s JavaScript injection option can run code before capture, and the code must be URL-encoded. Its guide demonstrates injecting JavaScript, but does not establish a universal cookie-banner-removal script. A page can render consent UI dynamically, use changing selectors, or place it inside an iframe or shadow root, so any custom script must be developed and verified against the actual page.
Use the documented js parameter only for a specific page behavior you understand. Do not treat a generic script that removes elements containing the word “cookie” as safe: it can remove unrelated content, miss localized text, or run before the banner appears.
4. Choose the right capture framing
| Control | What it changes | When it helps |
|---|---|---|
no_cookie_banners |
Requests that cookie banners and popups be prevented from appearing. | Use this first for the general case. |
css |
Injects page-specific CSS. | Use a confirmed selector when the built-in option does not handle a site. |
js |
Injects JavaScript before capture. | Use for a narrowly scoped page-specific customization you can validate. |
element |
Captures the first element matching a CSS selector. | When the desired output is one page element rather than the full page. |
crop |
Captures a specified image area. | When you need a specific region of the page. |
element and crop affect framing; they do not guarantee that a cookie banner is removed elsewhere on the page. Use the banner option or a targeted CSS fallback for removal.
5. Verify output across pages and viewports
- Capture a representative URL with
no_cookie_banners=true. - Inspect the image at the viewport sizes you use in production. A banner may appear differently on mobile and desktop.
- If it remains, inspect the page DOM and verify whether the banner is a normal element, an iframe, or another embedded component.
- Try a targeted CSS rule only after confirming its selector on that page.
- Keep a small regression set of URLs for important sites and review the actual image after changing capture options.
The reviewed ApiFlash documentation does not publish a universal selector, detection coverage rate, or success guarantee. Banner implementations vary, so output verification is part of a reliable workflow.
6. Troubleshooting
| Symptom | Likely cause | What to try |
|---|---|---|
| The banner still appears. | The parameter is missing, misspelled, not encoded or not being sent as a recognized request parameter; the page may also use a banner the built-in behavior does not handle. | Confirm the request includes no_cookie_banners=true. If it does, inspect the page and try CSS using a confirmed selector. |
| The screenshot is an API error document instead of an image. | The request failed or returned an error response. | Check the HTTP status and the API’s error response before saving the body as an image. Verify the access key, endpoint, and required fields against current documentation. |
| The CSS rule has no effect. | The selector does not match the page, the markup differs at capture time, or the banner is in an iframe or shadow root. | Inspect the live DOM at the capture viewport. Use the actual container selector and verify that the CSS parameter is URL-encoded. |
| Legitimate page content disappears. | The injected selector is too broad. | Scope the rule to the banner’s specific container and recapture. Avoid selectors that target generic dialog, fixed, or overlay elements without checking their effect. |
| The banner appears only on some runs. | The site may render the banner asynchronously or change its display based on stored consent, region, or session state. | Compare captures under the same request conditions and inspect the page’s behavior. Use a page-specific customization only after establishing when and where the banner appears. |
| A custom script runs but the banner remains. | The script may execute before the banner is created, target the wrong element, or fail against embedded UI. | Re-check the selector and timing against the page. The documented injection feature does not make any particular removal script universal. |
7. Performance, reliability, and cost
Start with the built-in option because it requires only one request parameter. Custom CSS or JavaScript adds page-specific maintenance: selectors and page markup can change, so keep rules narrow and recheck important captures after site changes.
For reliable output, check the HTTP response before treating it as an image and inspect captures across the viewports and pages your workflow depends on. Neither the reviewed documentation nor this guide establishes a capture-speed benchmark or guaranteed banner-removal rate.
ApiFlash’s homepage displayed a free tier of 100 screenshots per month and paid plans of $7/month for 1,000, $35/month for 10,000, and $180/month for 100,000 when reviewed on October 3, 2026. These quotas and prices can change; check the current ApiFlash site before choosing a plan.
8. Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot or PDF, and its clean-shot workflow accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets. Each of those steps can be turned off.
Here is a direct call using the documented endpoint; see the ScreenshotNeo API documentation for options and setup.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://example.com \
-o shot.webp
With ScreenshotNeo, bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in its X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.
9. FAQ
Is no_cookie_banners on by default?
No. ApiFlash documents the default as false, so set it to true on requests where you want the option enabled.
Does the option remove every popup on every website?
The documentation describes preventing cookie banners and popups, but does not promise universal coverage. Verify the output and use a site-specific fallback when needed.
Can I use the option with POST?
Yes. ApiFlash documents both GET query parameters and POST form data.
Can I hide a banner by cropping it out?
A crop can exclude a region from the output, but it changes framing and does not remove the banner from the page. Use the banner option or page-specific CSS when removal is the goal.
Where can I check ApiFlash pricing?
Check the current ApiFlash site before purchasing; displayed quotas and prices can change.


