Skip to content

PHP Metadata API

Extract title, description, image and logo from any URL with one HTTP request in PHP — no HTML parsing, no tag soup, no browser to maintain.

Extract metadata in PHP

No package and no parser — the Microlink REST API turns any URL into normalized metadata with a single HTTP GET. Here it is with file_get_contents and the cURL extension that ship with PHP.
Step 01 · Extract any URL
A one-liner with file_get_contents — no Composer package to add. Point it at a page and read the metadata from the JSON response.
extract.php
<?php
$query = http_build_query(['url' => 'https://microlink.io']);

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

echo $data['title'];        // 'Microlink | The web, transformed'
echo $data['description'];  // 'A single API for turning any URL into data…'
echo $data['image']['url']; // absolute, CDN-hosted
echo $data['logo']['url'];  // absolute, CDN-hosted
Step 02 · Pick the fields you need
Title, description, publisher, author, date, lang, image and logo all come back in one call — build exactly the object your product needs.
fields.php
<?php
$query = http_build_query(['url' => 'https://microlink.io']);

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

$preview = [
  'title' => $data['title'],
  'description' => $data['description'],
  'publisher' => $data['publisher'],
  'author' => $data['author'],
  'date' => $data['date'],
  'lang' => $data['lang'],
  'image' => $data['image']['url'] ?? null,
  'logo' => $data['logo']['url'] ?? null,
];
Step 03 · Render JavaScript pages
Tags injected by client-side JavaScript only exist after the page renders — prerender with a real browser and wait for them, still one request.
spa.php
<?php
$query = http_build_query([
  'url' => 'https://app.example.com',
  'prerender' => 'true',     // render JS in a real browser first
  'waitForSelector' => 'h1', // wait until the content exists
]);

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

echo $res['data']['title'];
Step 04 · Build a link preview
Image and logo come back as absolute, CDN-hosted URLs — drop them straight into an img tag and you have a link preview.
link-preview.php
<?php
$query = http_build_query(['url' => 'https://microlink.io']);

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

$image = $data['image']['url'] ?? $data['logo']['url'] ?? '';

echo "<a href='{$data['url']}' class='card'>
  <img src='$image' alt='' />
  <strong>{$data['title']}</strong>
  <p>{$data['description']}</p>
</a>";

Drop it into your framework

A Laravel route, a Symfony controller, or a WordPress shortcode — the same request becomes your own metadata endpoint for link previews and embeds.
  • Laravel
  • Symfony
  • WordPress
  • Plain PHP
<?php
namespace App\Controller;

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

class PreviewController
{
    // GET /preview?url=https://microlink.io
    #[Route('/preview')]
    public function show(HttpClientInterface $client): JsonResponse
    {
        $res = $client->request('GET', 'https://api.microlink.io', [
            'query' => ['url' => $_GET['url']],
        ])->toArray();

        $data = $res['data'];

        return new JsonResponse([
            'title' => $data['title'],
            'description' => $data['description'],
            'image' => $data['image']['url'] ?? null,
        ]);
    }
}

Skip the tag-parsing maintenance

Rolling your own means fetching HTML, parsing Open Graph and Twitter Cards with DOMDocument, merging JSON-LD and oEmbed, and adding Panther for JavaScript-injected tags. The API gives you normalized metadata from any page without any of the moving parts.

DIY tag parsing

  • Fetch the HTML and parse og, twitter and meta tags yourself
  • Merge JSON-LD, oEmbed and microdata by hand — every site differs
  • Resolve relative image and logo URLs against redirects yourself
  • JavaScript-injected tags need a headless browser — a 300 MB binary
  • Each browser eats hundreds of MB of RAM per worker
  • You build the caching, retries and autoscaling

Microlink for PHP

  • One HTTP request — cURL or file_get_contents, no extension to add
  • Open Graph, Twitter Cards, JSON-LD and oEmbed merged for you
  • Image and logo as absolute, CDN-hosted URLs
  • JavaScript-injected tags captured with prerender=true
  • Cached responses from a global edge network
  • Autoscaled fleet with a 99.95% 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 Laravel app. Read the API overview to go deeper.

  • No HTML Parsing

    No tag soup, no regex, no DOM library to install. One HTTP GET returns a normalized JSON object.
  • 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.
  • Every Source Merged

    Open Graph, Twitter Cards, JSON-LD, oEmbed, microdata and plain HTML tags are merged into a single normalized response.
  • CDN-Hosted Assets

    Image and logo come back as absolute URLs on a global CDN — hot-link them directly, no downloading or proxying.
  • JavaScript Rendering

    Tags injected by client-side JavaScript are captured too, with prerender=true and waitForSelector.
  • Link Preview Ready

    Title, description, image, logo and publisher are exactly the fields a link preview card needs — one call, one card.
  • Framework Friendly

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

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

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

    No tag soup, no regex, no DOM library to install. One HTTP GET returns a normalized JSON object.
  • 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.
  • Every Source Merged

    Open Graph, Twitter Cards, JSON-LD, oEmbed, microdata and plain HTML tags are merged into a single normalized response.
  • CDN-Hosted Assets

    Image and logo come back as absolute URLs on a global CDN — hot-link them directly, no downloading or proxying.
  • JavaScript Rendering

    Tags injected by client-side JavaScript are captured too, with prerender=true and waitForSelector.
  • Link Preview Ready

    Title, description, image, logo and publisher are exactly the fields a link preview card needs — one call, one card.
  • Framework Friendly

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

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

    Start with 25 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 metadata response before you write a line of PHP.

PHP Metadata API FAQ

Everything PHP developers ask before integrating the Microlink metadata API.

Which metadata sources are covered?

Open Graph, Twitter Cards, JSON-LD, oEmbed, microdata, RDFa and plain HTML tags — all merged and normalized into a single JSON response, so you never parse tag soup yourself.

Do I need to install a Composer package?

No. The examples use file_get_contents and the cURL extension that ship with PHP. If you already use Guzzle or Laravel’s HTTP client, the same request translates directly.

What about tags rendered by JavaScript?

Pass prerender=true and the page is rendered in a real browser before extraction, so tags injected by React, Vue or any client-side framework are captured too. Combine it with waitForSelector to wait for specific content.

Are image and logo URLs ready to use?

Yes. They come back as absolute URLs hosted on a global CDN — resolve-relative-URL bugs included — so you can hot-link them directly in an img tag or store them as-is.

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

The free tier gives you 25 requests per day with no account, no credit card, and no API key. Just call the endpoint and start extracting.
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 fresh is the metadata?

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

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