Use ApiFlash’s /v1/urltoimage endpoint from PHP, passing a valid access key and a fully qualified page URL. ApiFlash returns image bytes by default; check the HTTP response before writing those bytes to a file so an API error is not saved as a broken screenshot.
Make a basic ApiFlash screenshot request in PHP
The official endpoint is https://api.apiflash.com/v1/urltoimage. Get an access key from your ApiFlash dashboard and keep it on the server. The target URL must include its protocol, such as https://.
As an Amazon Associate I earn from qualifying purchases.
This production-oriented example uses PHP’s cURL extension so it can inspect the HTTP status and distinguish a successful image response from an error response:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →<?php
$accessKey = getenv('APIFLASH_ACCESS_KEY');
$url = 'https://example.com';
$outputFile = __DIR__ . '/screenshot.jpeg';
if (!$accessKey) {
throw new RuntimeException('Set the APIFLASH_ACCESS_KEY environment variable.');
}
$params = [
'access_key' => $accessKey,
'url' => $url,
];
$endpoint = 'https://api.apiflash.com/v1/urltoimage?' . http_build_query($params);
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 90,
]);
$body = curl_exec($ch);
if ($body === false) {
$error = curl_error($ch);
curl_close($ch);
throw new RuntimeException('ApiFlash transport error: ' . $error);
}
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($ch);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("ApiFlash returned HTTP $status: $body");
}
if (strpos($contentType, 'image/') !== 0) {
throw new RuntimeException('Expected image data, received Content-Type: ' . $contentType);
}
if (file_put_contents($outputFile, $body) === false) {
throw new RuntimeException('Could not write screenshot to ' . $outputFile);
}
echo "Saved screenshot to $outputFilen";
Set the key in the process environment before running the script, for example export APIFLASH_ACCESS_KEY='your-key' on a Unix-like shell, then run php screenshot.php. The cURL extension must be enabled. The URL query is built with http_build_query(), which encodes values such as the target URL.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Minimal version using PHP streams
ApiFlash publishes this shorter PHP pattern. It is useful for a quick script, but it does not explicitly validate the status code or response type before saving the body:
<?php
$params = http_build_query(array(
"access_key" => "YOUR_ACCESS_KEY",
"url" => "https://example.com",
));
$image_data = file_get_contents("https://api.apiflash.com/v1/urltoimage?" . $params);
file_put_contents("screenshot.jpeg", $image_data);
?>
With this approach, ensure PHP can make URL-aware file requests and handle a failed file_get_contents() call. For an application or public endpoint, the status-checking version is safer.
Choose the response and image format
The default response is the image itself, with suitable content-type and content-length headers. Save it with an extension that matches the selected format.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated 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 matchRank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
| Need | Setting | What to expect |
|---|---|---|
| Standard screenshot file | Omit response_type |
Image bytes in the response body. |
| JSON result with screenshot URL | response_type=json |
JSON rather than image bytes; parse the response instead of writing it directly as an image. |
| JPEG | Default format | JPEG image; quality applies. |
| PNG | Set the documented PNG format option | PNG image. |
| WebP | Set the documented WebP format option | WebP image; quality applies, with additional dimension limits after scaling. |
ApiFlash’s API documentation describes the accepted parameter names and format constraints. When switching to JSON mode, update your code to decode JSON and use its screenshot URL; do not mistake JSON text for image data. JSON mode also supports extraction URLs when extraction options are enabled, and extract_html and extract_text require JSON response mode.
Set viewport, full-page capture, and rendering waits
Viewport versus full page
The documented default viewport is 1920 × 1080. Set width and height when a particular viewport is needed, observing the API’s pixel and maximum-area limits. WebP has a further width and height limit after applying scale_factor.
Use full_page=true to capture the page’s full height. In full-page mode, height and thumbnail_width are ignored, and an element capture is ignored as well. If you need one element only, do not combine that expectation with full-page mode.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Wait for content to render
ApiFlash’s FAQ says the service waits for network idle by default. For pages that populate content late or load images as the page scrolls, use a more specific readiness condition where appropriate:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →wait_forwaits for a CSS selector to appear. If it does not appear, the request aborts after 15 seconds.wait_untillets you select a documented page-loading milestone.delayadds a fixed wait of up to 10 seconds. The documentation recommends a reliable wait condition where possible rather than relying on a fixed delay.scroll_page=truecan trigger animations or lazy-loaded elements before capture.
For example, add wait_for with the selector for the page’s main content when a request otherwise captures an empty shell. Encode parameters with http_build_query() rather than concatenating an unescaped selector or URL into the query string.
Control caching and freshness
ApiFlash documents a default screenshot cache TTL of 86,400 seconds, with an accepted TTL range of 0 to 2,592,000 seconds. Use fresh=true when you need to bypass a cached screenshot. Choose cache behavior based on the task: reuse can avoid repeated captures of an unchanged page, while a fresh capture is more appropriate when page updates must appear promptly.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Handle errors, quota, and request limits
Check the HTTP status before treating a response as an image. ApiFlash documents these response codes:
| Status | Documented meaning | What to check |
|---|---|---|
| 400 | Invalid parameters or an uncapturable target | Confirm parameter names and values, and verify the target is reachable and complete with a protocol. |
| 401 | Invalid or revoked access key | Check the server-side key configuration and dashboard status. |
| 402 | Monthly quota exceeded | Check account usage and the documented quota information. |
| 403 | The plan does not support requested parameters | Review the plan and remove or replace the unsupported option. |
| 429 | Rate limited | Reduce request frequency and retry with backoff appropriate to your application. |
| 500 | API-side capture failure | Do not save the error body as an image; retry cautiously and log the response for diagnosis. |
The API documentation also describes a quota endpoint and a quota-related response header; its example quota response is illustrative, not a current limit for every account. The documentation says identical requests that fail to capture a screenshot are limited to five per hour.
ApiFlash’s concurrent-request guide, last updated January 25, 2023, says there is no limit on concurrent requests, while requests are rate-limited per second. That concurrency guidance does not remove the per-second rate limit; pace bursts and respond to HTTP 429 rather than assuming parallel calls are unrestricted.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Protect the access key and constrain public use
Keep the access key in server-side configuration, such as an environment variable or secret store. ApiFlash warns that frontend calls expose the key to end users and are appropriate only in trusted or internal situations. If you expose your own screenshot endpoint to users, validate and restrict target URLs and apply your own rate limits; an unrestricted proxy can be abused to capture arbitrary URLs and consume quota.
For authenticated pages, ApiFlash’s FAQ describes passing session cookies through the cookies parameter after normal authentication; its guides also describe secret URL or header approaches. Only capture pages the requester is authorized to access, and handle credentials, cookies, and resulting screenshots as sensitive data. Creating a screenshot does not grant rights to republish the page’s third-party content; consult the ApiFlash terms of service for its treatment of user data and screenshot deliverables.
Or skip the browser setup
For a one-call screenshot API, ScreenshotNeo accepts a URL and returns a PNG, JPEG, WebP, or PDF. Cookie banners are accepted and removed before the shot, along with known consent platforms, newsletter popups, and chat widgets; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Free tools Windows power users keep installed
One-click scans. No signup required.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for request options, including full-page shots, element capture, waits, custom headers, PDF settings, and asynchronous or bulk capture. Start with 1,000 free screenshots a month, with no card required.
Frequently asked questions
Can I use GET or POST with ApiFlash?
Yes. ApiFlash documents both GET requests with query parameters and POST requests with form data. This example uses GET and URL-encodes its parameters.
Why did my saved file contain text instead of a screenshot?
The response may be an API error or JSON. Inspect the HTTP status and content type, and use response_type=json only when your code is prepared to parse JSON.
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.




