Skip to content

PHP HTML API

Get the fully rendered HTML of any URL with one HTTP request in PHP — real Chromium under the hood, none to maintain.

Get HTML in PHP

No package and no browser — the Microlink REST API renders any URL and returns the HTML with a single HTTP GET. Here it is with the file_get_contents and cURL that ship with PHP.
Step 01 · Extract any URL
A few lines of plain PHP — no Composer package, no Chromium download. Point it at a page and read the rendered HTML from the JSON response.
fetch.php
<?php
$query = http_build_query([
  'url' => 'https://microlink.io',
  'data.html.attr' => 'html'
]);

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

echo strlen($data['html']);        // full rendered document
echo substr($data['html'], 0, 15); // '<!DOCTYPE html>'
Step 02 · Scope to a selector
Return the whole document or only the subtree you need — smaller responses, less parsing and lower token cost downstream.
selector.php
<?php
$query = http_build_query([
  'url' => 'https://microlink.io/blog',
  'data.html.attr' => 'html',
  'data.html.selector' => 'main' // only the <main> subtree
]);

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

// No nav, no footer — just the content you asked for
echo $res['data']['html'];
Step 03 · Render JavaScript pages
Client-rendered apps only produce their markup after JavaScript runs — prerender in a real browser and wait for it, still one request.
spa.php
<?php
$query = http_build_query([
  'url' => 'https://app.example.com',
  'data.html.attr' => 'html',
  'prerender' => 'true',          // render JS in a real browser first
  'waitForSelector' => 'h1'       // capture only when the content exists
]);

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

echo $res['data']['html'];
Step 04 · Serve the raw HTML
Ask for embed=html and the API answers with text/html directly — proxy it straight to a browser or write it to a file.
raw.php
<?php
$query = http_build_query([
  'url' => 'https://microlink.io',
  'data.html.attr' => 'html',
  'embed' => 'html' // respond with text/html, no JSON
]);

$html = file_get_contents("https://api.microlink.io?$query");
// ready to serve or store

Drop it into your framework

A Laravel route, a Symfony controller, or a WordPress shortcode — the same request becomes your own rendering endpoint.
  • Laravel
  • Symfony
  • WordPress
  • Plain PHP
<?php
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class RenderController
{
    #[Route('/render')]
    public function show(HttpClientInterface $http): Response
    {
        $data = $http->request('GET', 'https://api.microlink.io', [
            'query' => [
                'url' => 'https://microlink.io',
                'data.html.attr' => 'html',
            ],
        ])->toArray()['data'];

        return new Response($data['html'], 200, [
            'Content-Type' => 'text/html',
        ]);
    }
}

Skip the browser-farm ops

Rolling your own means running a headless Chromium next to PHP-FPM, writing per-site wait logic, and fighting antibot walls. The API returns the rendered HTML of any page without any of the moving parts.

DIY rendering stack

  • Run and patch your own headless Chromium fleet
  • Write per-site wait logic for JavaScript-rendered pages
  • Fight antibot walls and CAPTCHAs with your own proxy pool
  • Each browser eats hundreds of MB of RAM per worker
  • You build the caching, retries and autoscaling
  • Every Chromium upgrade breaks a selector somewhere

Microlink for PHP

  • One HTTP request — no rendering infrastructure to run
  • Fully rendered HTML from managed Chromium, JS included
  • Selector scoping to return only the subtree you need
  • Antibot and CAPTCHA resolution handled for you
  • Cached responses from a global edge network
  • Autoscaled fleet with a 99.9% uptime SLA

Built for the way you write PHP.

A REST API that feels native in PHP — one call, JSON back, and at home in anything from a script to a WordPress theme. Read the API overview to go deeper.

  • Real Browser Rendering

    Every request runs in managed Chromium, so client-rendered apps return complete markup instead of an empty shell.
  • No Composer Package

    file_get_contents and cURL ship with PHP — the examples work with nothing to install and no browser to manage.
  • Selector Scoping

    Return the full document or a single subtree with a selector — smaller payloads and less parsing downstream.
  • JSON or Raw HTML

    Read data.html from the JSON response, or ask for embed=html and get the document back as text/html — no JSON involved.
  • Readiness You Control

    waitUntil and waitForSelector let you block on network idle or on a specific element before the HTML is captured.
  • One Call, Many Formats

    Request HTML together with markdown, text, metadata, screenshots or PDFs and pay for a single render instead of several.
  • Framework Friendly

    Drop it into Laravel, Symfony, or WordPress as a route, controller or shortcode.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Generous Free Tier

    Sign up for a free API key: 100 requests per month with every Pro feature, no credit card.
  • Real Browser Rendering

    Every request runs in managed Chromium, so client-rendered apps return complete markup instead of an empty shell.
  • No Composer Package

    file_get_contents and cURL ship with PHP — the examples work with nothing to install and no browser to manage.
  • Selector Scoping

    Return the full document or a single subtree with a selector — smaller payloads and less parsing downstream.
  • JSON or Raw HTML

    Read data.html from the JSON response, or ask for embed=html and get the document back as text/html — no JSON involved.
  • Readiness You Control

    waitUntil and waitForSelector let you block on network idle or on a specific element before the HTML is captured.
  • One Call, Many Formats

    Request HTML together with markdown, text, metadata, screenshots or PDFs and pay for a single render instead of several.
  • Framework Friendly

    Drop it into Laravel, Symfony, or WordPress as a route, controller or shortcode.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Generous Free Tier

    Sign up for a free API key: 100 requests per month with every Pro feature, no credit card.

Try it live in the playground

Paste a URL and see the rendered output before you write a line of PHP.

PHP HTML API FAQ

Everything PHP developers ask before integrating the Microlink HTML API.

Do I get the source HTML or the rendered DOM?

Every request runs in a real Chromium instance, so data.html is the fully rendered DOM — JavaScript executed, lazy content loaded. Control the capture point with waitUntil and waitForSelector.

Do I need to install a package or a browser?

No. The examples use file_get_contents and the cURL extension that ship with PHP, and rendering runs on Microlink — no headless Chromium next to PHP-FPM.

How do I control when the HTML is captured?

Use waitUntil to block on network idle or a fixed delay, and waitForSelector to hold the capture until a specific element exists — the HTML comes back exactly when your page is ready, still in one request.

Can I get only part of the page?

Yes. Add a selector to the extraction rule and only that subtree comes back — ideal for articles, product cards or pricing tables, with smaller payloads and less parsing downstream.

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

Yes, and it is free: sign up for an API key and you get 100 requests per month with every Pro feature, no credit card. Add it as x-api-key and start extracting.
When you need more volume, pick a paid plan: same key, bigger quota. See pricing for the limits.

How fresh is the HTML?

Responses are cached at the edge with a sane default TTL, and you control freshness per request — see the API overview for cache parameters.

Start extracting in PHP

Sign up for a free API key: 100 requests per month with every Pro feature, no credit card. Send your first request and get HTML back in minutes.
Free API key
100 requests/month
No credit card