Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

URL2PNG Screenshot API in PHP: A Practical Guide

A PHP guide to URL2PNG’s v6 screenshot request, token construction, capture options, caching, and common integration fixes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate a URL2PNG screenshot in PHP, build a query string from the target page and capture options, create the v6 token as md5($query_string . $URL2PNG_SECRET), then place the API key and token in the request URL. Keep the secret on your server. The example below follows URL2PNG’s official quickstart; check that documentation for any changes before deploying.

Build and sign a URL2PNG screenshot request

URL2PNG’s v6 API returns a screenshot URL constructed from your API key, a token, and an encoded query string. The token must be calculated from the complete query string followed by your secret. Do not put a real secret in browser-side JavaScript or publish it in a page or repository.

<?php
// Load these from server-side environment/configuration, not from user input.
$apiKey = getenv('URL2PNG_API_KEY');
$secret = getenv('URL2PNG_SECRET');

if (!$apiKey || !$secret) {
    throw new RuntimeException('Set URL2PNG_API_KEY and URL2PNG_SECRET first.');
}

$pageUrl = 'https://example.com/';
$options = [
    'fullpage' => 'true',
    'viewport' => '1280x900',
];

// Encode the target URL as a query parameter, alongside the capture options.
$params = ['url' => $pageUrl] + $options;
$queryString = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
$token = md5($queryString . $secret);

$requestUrl = 'https://api.url2png.com/v6/'
    . rawurlencode($apiKey) . '/' . $token . '/png/?' . $queryString;

header('Content-Type: text/plain; charset=utf-8');
echo $requestUrl;

Use the generated URL as the image source or request it from your server, depending on your application. The URL2PNG documentation’s sample uses a function that returns the screenshot URL. The code above builds the same essential pieces: options and target URL in a query string, an MD5 token from that exact string plus the secret, and the v6 endpoint path. Confirm the precise endpoint and parameter conventions in the current docs if you change the output format or request options.

Encoding and token pitfalls

  • Generate the token only after the final query string is assembled. Changing, adding, removing, or re-encoding a parameter after signing can produce a token mismatch.
  • Use the same encoded query string in both the token calculation and request URL. In PHP, http_build_query with PHP_QUERY_RFC3986 encodes spaces as %20; if you adapt the official sample or use another encoder, make sure the bytes used for signing match the bytes sent.
  • Keep the API key and secret in server-side configuration. Do not accept a caller-supplied secret or let untrusted input choose arbitrary capture options without validation.
  • The example prints a URL for clarity; in an application, avoid logging URLs if they contain sensitive page parameters.

Choose the capture options you need

URL2PNG documents the following controls for its v6 requests. Option names and accepted values should be checked against the current API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
  • Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
  • CanaKit Turbine Black Case for the Raspberry Pi 5
  • CanaKit Low Noise Bearing System Fan
  • Mega Heat Sink - Black Anodized
Option What it changes When to use it
fullpage Requests a capture of the full document rather than only the visible browser viewport. The documented default is false. Use fullpage=true for long articles or pages where content below the fold matters.
viewport Sets the browser viewport dimensions. The documented default is 1480×1037; the docs give 500x500 as an example. Set a viewport that matches the layout you need to inspect or display.
thumbnail_max_width Constrains or scales the screenshot width. Use it when you need a smaller-width output for a thumbnail or preview.
unique Can force a fresh screenshot instead of reusing the cached result; the docs suggest a timestamp-like value. Vary it when the target has changed and you need a new capture.
ttl Sets cache lifetime in seconds. The documented default is 2,592,000 seconds (30 days). Choose a shorter or longer cache lifetime when freshness requirements differ.
delay Adds a delay before capture. Allow time for page content that appears shortly after initial load.
say_cheese Provides a DOM condition for the capture. Use a documented condition when capture should wait for a particular page state.
custom_css_url Applies custom CSS from a URL. Use it to adjust page presentation before capture.
user_agent Sets the browser user-agent value used for the request. Use it when you need to request a particular user-agent-dependent layout.
accept_languages Sets accepted language preferences. Use it when the page varies by language preference.

Understand caching, freshness, and plan usage

URL2PNG says screenshots are cached for 30 days by default and retrieval of a cached screenshot does not count against a plan. Its documentation gives the default TTL as 2,592,000 seconds, also 30 days. Set ttl to control cache lifetime; use a changing unique value when you want to force a fresh screenshot. These are service settings, not a guarantee that every target page will render identically over time.

URL2PNG’s plans page says the service does not offer free accounts and lists paid quotas, prices, and overage rates. Those details can change, so consult the current plans page when estimating ongoing usage rather than relying on a copied price table.

Rank #2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
  • Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
  • Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
  • CanaKit Premium High-Gloss Raspberry Pi 4 Case with Integrated Fan Mount, CanaKit Low Noise Bearing System Fan
  • CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply (US Plug) with Noise Filter, Set of Heat Sinks, Display Cable - 6 foot (Supports up to 4K60p)
  • CanaKit USB-C PiSwitch (On/Off Power Switch for Raspberry Pi 4)

Troubleshoot common PHP integration problems

  • Token rejected: Rebuild the query string once, then calculate the token from that exact string concatenated with the secret. Check that no parameter was added or encoded differently in the URL after signing.
  • Screenshot shows only the first screen: Set fullpage=true; the documented default captures the viewport rather than the full page.
  • Screenshot appears stale: The service caches by default. Adjust ttl for the cache lifetime or vary unique to request a fresh capture.
  • Page is captured before a delayed element appears: Consider the documented delay or say_cheese condition, where appropriate for the target.
  • Unexpected language or layout: Check the target’s language and user-agent behavior; URL2PNG documents accept_languages and user_agent controls.
  • Credentials missing in PHP: Verify the server process can read the environment variables and that they contain the URL2PNG API key and secret. Do not work around this by embedding the secret in public frontend code.

Or skip the browser setup:

If you want a screenshot API without constructing a browser workflow, ScreenshotNeo offers a one-GET API request for PNG, JPEG, WebP, or PDF output. Its clean-shot flow accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be switched off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status in headers. It also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

Example PHP request:

<?php
import requests;
$r = requests.get("https://api.screenshotneo.com/v1/shot", params=["access_key" => "YOUR_API_KEY", "url" => "https://stripe.com"], timeout=90);
file_put_contents("shot.webp", $r->body);

See the ScreenshotNeo API documentation for request details. Its Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Can I use URL2PNG from a PHP application hosted in India?

The documented integration is a server-side HTTP request and the reviewed URL2PNG material does not specify India-only API behavior. Check URL2PNG’s current documentation and plan terms for your deployment.

Rank #3
ELECROW CrowPi Case Kit for Raspberry Pi 5, 9-Inch Display
  • Not including the Raspberry Pi 5 (8GB), the Crowpi advanced version comes with the Raspberry Pi 5
  • ELECROW Black Case for the Raspberry Pi 5, CrowPi is equipped with a 9-inch HD touchscreen along with a camera; All the regular components used in DIY electronics are packed into the CrowPi development board, such as LCD, LED matrix, buzzer, light sensor, PIR sensor, ultrasonic sensor, IR sensor, etc
  • Raspberry Pi Sensors: The Crowpi raspberry pi 5 programming kit is jam-packed with lots of buttons such as 19 different sensors in a tidy easy to use package; You don't have to wait and wire things
  • Build Quality: Solid ABS shell and well made components in one place make it strong and convenient to travel
  • Programming Lessons: This raspberry pi 5 learning kit ships with step by step instructions and provides 21 lessons to take you through identifying components reading code and running it in the terminal

Does URL2PNG offer a free account?

URL2PNG’s plans page says it does not offer free accounts; see its current plans page for available paid options.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM); Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
$159.99
Bestseller No. 4
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
Fully assembled for plug-and-play operation; Includes Raspberry Pi 5 with 8GB RAM; 256 GB PCIe Pi NVMe SSD (Pre-loaded with Pi 64-Bit OS)
$339.97
Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
  • 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
  • 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
  • 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
  • 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
Rank #4
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
  • Fully assembled for plug-and-play operation
  • Includes Raspberry Pi 5 with 8GB RAM
  • 256 GB PCIe Pi NVMe SSD (Pre-loaded with Pi 64-Bit OS)
  • M.2 HAT+
  • CanaKit Turbine Black Case for the Pi 5

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.