Skip to content

PHP Screenshot API

Capture pixel-perfect screenshots of any URL with one HTTP request in PHP — no headless Chrome, no extensions to compile, no servers to maintain.
PHP website screenshot API example
https://api.microlink.io?screenshot&url=https://apple.com

Take a screenshot in PHP

No SDK and no headless browser — the Microlink REST API turns any URL into a hosted screenshot with a single HTTP GET. Here it is with file_get_contents and the cURL extension that ship with PHP.
Step 01 · Capture any URL
A one-liner with file_get_contents — no Composer package to add. Point it at a page and read the hosted image URL from the JSON response.
capture.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'screenshot' => 'true',
  'meta' => 'false', // skip metadata extraction for a faster response
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);

echo $res['data']['screenshot']['url'];
Step 02 · Use cURL for more control
When you need timeouts and error handling in production, the bundled cURL extension does the same job.
curl.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'screenshot' => 'true',
  'meta' => 'false',
]);

$ch = curl_init("https://api.microlink.io?$query");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);

echo $res['data']['screenshot']['url'];
Step 03 · Customize the capture
Output format, full-page captures, device emulation, and ad blocking — every Headless Chrome option is just a query field (dot notation for nested ones).
options.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'screenshot.type' => 'jpeg',      // png (default) | jpeg
  'screenshot.fullPage' => 'true',  // capture the entire scrollable page
  'device' => 'iPhone X',           // emulate any device
  'adblock' => 'true',              // strip ads & cookie banners (default)
  'meta' => 'false',
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);

echo $res['data']['screenshot']['url'];
Step 04 · Save it to disk
The response is a hosted image URL on a global CDN. Download it with a second request, or just hand the URL to the browser.
save.php
<?php
$query = http_build_query([
  'url' => 'https://example.com',
  'screenshot' => 'true',
]);

$res = json_decode(file_get_contents("https://api.microlink.io?$query"), true);
$image = $res['data']['screenshot']['url'];

file_put_contents('screenshot.png', file_get_contents($image));

Drop it into your framework

A route, a controller, or a shortcode — the same request becomes your own screenshot endpoint, perfect for dynamic Open Graph images on any host.
  • Laravel
  • Symfony
  • WordPress
  • PHP
<?php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class ScreenshotController
{
    // GET /screenshot?url=https://example.com
    #[Route('/screenshot')]
    public function capture(Request $request, HttpClientInterface $client): RedirectResponse
    {
        $res = $client->request('GET', 'https://api.microlink.io', [
            'query' => [
                'url' => $request->query->get('url'),
                'screenshot' => 'true',
                'meta' => 'false',
            ],
        ])->toArray();

        return new RedirectResponse($res['data']['screenshot']['url']);
    }
}

Skip the headless Chrome maintenance

PHP cannot drive a browser on its own — capturing pages yourself means running Panther or a Node sidecar, shipping a 300 MB browser, and fighting cold starts. The API gives you the same control without any of the infrastructure.

Self-hosted headless Chrome

  • PHP can't drive a browser — you run Panther, ChromeDriver or a Node sidecar
  • Install & maintain Chromium (~300 MB) plus system libraries
  • Each browser eats hundreds of MB of RAM; PHP-FPM workers stall
  • Launching Chromium adds seconds of latency per request
  • You build the process pool, queueing, retries and autoscaling
  • Write your own cookie-banner & ad dismissal scripts

Microlink for PHP

  • One HTTP request — cURL or file_get_contents, no extension to add
  • Runs anywhere: shared hosting, serverless, containers, your laptop
  • Autoscaled managed browser fleet with a 99.95% uptime SLA
  • Sub-second cached responses from 240+ edge locations
  • Built-in adblock removes ads & cookie banners automatically
  • Full-page, device emulation, overlays & DOM interaction included

Built for the way you write PHP.

A REST API that feels native in PHP — one HTTP call, JSON back, and at home on any host from shared hosting to a Laravel app. Read the screenshot guide to go deeper.

  • No Browser to Install

    PHP cannot run a headless browser natively. With the API there is no Chrome, Panther, or ChromeDriver to install or maintain.
  • cURL or file_get_contents

    Use the bundled cURL extension or a one-line file_get_contents — it is a plain HTTP GET, with no Composer package required.
  • Framework Friendly

    Drop it into Laravel, Symfony, or WordPress as a route, controller, or shortcode in a few lines.
  • Runs on Any Host

    Works on shared hosting, serverless, and containers alike — there are no binaries or system libraries to ship.
  • Simple JSON Response

    A single request returns JSON with the hosted image URL. No drivers, no explicit waits, no browser process to babysit.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Built-in Adblock

    Captures arrive clean — GDPR cookie banners, newsletter popups, and injected ads are removed before the shot.
  • Full Browser Control

    Full-page captures, viewport and device emulation, click and wait, plus custom CSS and JavaScript injection.
  • Generous Free Tier

    Start with 50 requests per day — no account, no credit card. Add an API key when you are ready to scale.
  • No Browser to Install

    PHP cannot run a headless browser natively. With the API there is no Chrome, Panther, or ChromeDriver to install or maintain.
  • cURL or file_get_contents

    Use the bundled cURL extension or a one-line file_get_contents — it is a plain HTTP GET, with no Composer package required.
  • Framework Friendly

    Drop it into Laravel, Symfony, or WordPress as a route, controller, or shortcode in a few lines.
  • Runs on Any Host

    Works on shared hosting, serverless, and containers alike — there are no binaries or system libraries to ship.
  • Simple JSON Response

    A single request returns JSON with the hosted image URL. No drivers, no explicit waits, no browser process to babysit.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Built-in Adblock

    Captures arrive clean — GDPR cookie banners, newsletter popups, and injected ads are removed before the shot.
  • Full Browser Control

    Full-page captures, viewport and device emulation, click and wait, plus custom CSS and JavaScript injection.
  • Generous Free Tier

    Start with 50 requests per day — no account, no credit card. Add an API key when you are ready to scale.

Try it live in the playground

Paste a URL and see the exact API request before you write a line of PHP.

PHP Screenshot FAQ

Everything PHP developers ask before integrating the Microlink screenshot API.

Do I need a headless browser or Chrome?

No. PHP cannot drive a browser natively, so normally you would run or a Node sidecar. With the API it is just an HTTP request — the Headless Chrome fleet runs on Microlink's side.

cURL or file_get_contents?

Either works. file_get_contents is a one-liner when allow_url_fopen is enabled; the cURL extension gives you timeouts and richer error handling for production.

Does it work with Laravel, Symfony, and WordPress?

Yes. Because it is just an HTTP call, it drops into a Laravel route, a Symfony controller, or a WordPress shortcode in a few lines — see the tabs above, or the screenshot guide.

Does it run on shared hosting or serverless?

Yes. Because there are no binaries or system libraries to install, it works on shared hosting, serverless functions, and containers alike.
See the API overview for request details.

Is there a free tier or do I need an API key?

The free tier gives you 50 requests per day with no account, no credit card, and no API key. Just call the endpoint and start capturing.
When you need more throughput or caching control, add an apiKey header and requests route to the Pro tier. See pricing for the limits.

How fast is it and how does it scale?

Cached captures return sub-second from a global edge network, and the browser fleet autoscales behind a 99.95% uptime SLA — so a traffic spike does not mean provisioning more servers.
Compare the numbers on the screenshot API benchmarks.

Start capturing in PHP

Get 50 requests/day with zero commitment — no account and no credit card. Send your first request and ship a screenshot in minutes.
No login needed
50 reqs/day free
No credit card