Skip to content

Overview

Microlink SDK is the official way to consume Microlink API programmatically. It's published on npm as microlink.io and organizes the API into products — one method per product — so you call microlink.screenshot(url) instead of composing query strings by hand.
npm install microlink.io
Create a client once and call any product from it:
import createClient from 'microlink.io'

const microlink = createClient()

const { title, description } = await microlink.metadata('https://vercel.com')
CommonJS is supported too:
const createClient = require('microlink.io')
const microlink = createClient()
The same code runs in Node.js 24 or later, browsers, and Deno, returning the same responses everywhere. The package ships TypeScript definitions, so every method, option, and result is typed out of the box.

Authentication

createClient() works without an API key on the free plan out of the box. Pass an apiKey to unlock pro quotas — it travels as the x-api-key header and switches the client to the pro endpoint:
const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})
search is the exception: it requires an apiKey on every request.
Any other option passed to createClient is merged into every API call, which makes it the right place for defaults such as ttl or prerender. See options for the full list.

Methods

Every product is a method on the client. URL-based methods share the method(url, options) shape and resolve to the product's result directly, with no envelope to unwrap. search takes a query string instead:
  • metadata — unified metadata from Open Graph, Twitter Cards, JSON-LD, and HTML.
  • screenshot — any URL as a hosted image, or a short video recording.
  • pdf — any URL printed to a hosted PDF document.
  • markdown — the page as clean Markdown, ready for LLM context windows.
  • html — the fully rendered HTML, captured after JavaScript runs.
  • text — readable plain text with the markup stripped out.
  • logo — the brand logo behind any URL.
  • embed — oEmbed-style iframe HTML for rich cards.
  • extract — typed values pulled with your own CSS selector rules.
  • function — your own JavaScript executed against a live page, with full Puppeteer access.
  • search — Google results as structured data, with a type per surface (news, images, shopping, …), pagination, and per-result expansion.
  • video — the primary video of a page as a direct, playable asset.
  • audio — the primary audio track of a page as a direct, playable asset.
  • links — every link on a page, as an array of absolute URLs.
  • images — every image on a page, as an array of absolute URLs.
  • videos — every video source on a page, as an array of absolute URLs.
  • audios — every audio source on a page, as an array of absolute URLs.
  • emails — every email address on a page, as an array.
  • technologies — the tech stack powering a site.
  • lighthouse — a full Lighthouse report.
Every method throws a typed MicrolinkError when the API call fails, so one try/catch covers the whole client.

How it fits together

Every method is a call to Microlink API with the right parameters set for you and the result unwrapped; HTTP, authentication, retries, errors, and compression are handled underneath, so the whole client behaves the same way.
Custom data extraction is part of the SDK too: write the rules and pass them to extract, or as the data option of metadata. The extract pages cover the rules grammar — selector, attr, type, nested and fallback rules — shared by extract, the content methods, and the collections.
Installing the package also ships a microlink binary where every product is a subcommand.

Runtimes

The package is built on Web Standard APIs — fetch, URL, URLSearchParams — so one build runs everywhere, with the same import in CommonJS and ESM:
  • Node.js — any version above v24; we recommend the active LTS.
  • Edge runtimesCloudflare Workers, Vercel Edge Functions, Deno, or any provider that supports WinterCG, with nothing extra to configure.
  • Browsers — through any bundler, with the same import.
A worker that returns extracted data as JSON:
import createClient from 'microlink.io'

const microlink = createClient({ apiKey: MICROLINK_API_KEY })

export default {
  async fetch (request) {
    const { title, image } = await microlink.metadata('https://example.com')
    return Response.json({ title, image })
  }
}
Keep your apiKey out of browser code: requests from a page run on the free tier of the API, and the x-api-key header belongs on a server you control.
Looking for the drop-in link preview component for React, Vue, and vanilla JavaScript? That's a different product: see link preview.