# Overview

## Table of Contents

- [Authentication](#authentication)
- [Methods](#methods)
- [How it fits together](#how-it-fits-together)
- [Runtimes](#runtimes)

---

**Microlink SDK** is the official way to consume [Microlink API](https://microlink.io/docs/api/getting-started/overview) programmatically. It's published on npm as [microlink.io](https://www.npmjs.com/package/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.

```bash
npminstallmicrolink.io
```

Create a client once and call any product from it:

```js
importcreateClientfrom'microlink.io'

constmicrolink=createClient()

const{title,description}=awaitmicrolink.metadata('https://vercel.com')
```

CommonJS is supported too:

```js
constcreateClient=require('microlink.io')

constmicrolink=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

Sign up for a free API key at [dashboard.microlink.io](https://dashboard.microlink.io/signup?from=/docs/sdk/getting-started/overview&cta=docs:content): 25 requests per day with every Pro feature. Pass it as `apiKey` — it travels as the [x-api-key](https://microlink.io/docs/api/basics/authentication) header and switches the client to the [pro endpoint](https://microlink.io/docs/api/basics/endpoint):

```js
constmicrolink=createClient({

apiKey:process.env.MICROLINK_API_KEY

})
```

[search](https://microlink.io/docs/sdk/methods/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](https://microlink.io/docs/api/parameters/ttl) or [prerender](https://microlink.io/docs/api/parameters/prerender). See [options](https://microlink.io/docs/sdk/getting-started/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](https://microlink.io/docs/sdk/methods/search) takes a query string instead:

- [metadata](https://microlink.io/docs/sdk/methods/metadata) — unified metadata from Open Graph, Twitter Cards, JSON-LD, and HTML.
- [screenshot](https://microlink.io/docs/sdk/methods/screenshot) — any URL as a hosted image, or a short video recording.
- [pdf](https://microlink.io/docs/sdk/methods/pdf) — any URL printed to a hosted PDF document.
- [markdown](https://microlink.io/docs/sdk/methods/markdown) — the page as clean Markdown, ready for LLM context windows.
- [html](https://microlink.io/docs/sdk/methods/html) — the fully rendered HTML, captured after JavaScript runs.
- [text](https://microlink.io/docs/sdk/methods/text) — readable plain text with the markup stripped out.
- [logo](https://microlink.io/docs/sdk/methods/logo) — the brand logo behind any URL.
- [embed](https://microlink.io/docs/sdk/methods/embed) — oEmbed-style iframe HTML for rich cards.
- [extract](https://microlink.io/docs/sdk/methods/extract) — typed values pulled with your own CSS selector rules.
- [function](https://microlink.io/docs/sdk/methods/function) — your own JavaScript executed against a live page, with full Puppeteer access.
- [search](https://microlink.io/docs/sdk/methods/search) — Google results as structured data, with a `type` per surface ([news](https://microlink.io/docs/sdk/methods/search/news), [images](https://microlink.io/docs/sdk/methods/search/images), [shopping](https://microlink.io/docs/sdk/methods/search/shopping), …), pagination, and per-result expansion.
- [video](https://microlink.io/docs/sdk/methods/video) — the primary video of a page as a direct, playable asset.
- [audio](https://microlink.io/docs/sdk/methods/audio) — the primary audio track of a page as a direct, playable asset.
- [links](https://microlink.io/docs/sdk/methods/links) — every link on a page, as an array of absolute URLs.
- [images](https://microlink.io/docs/sdk/methods/images) — every image on a page, as an array of absolute URLs.
- [videos](https://microlink.io/docs/sdk/methods/videos) — every video source on a page, as an array of absolute URLs.
- [audios](https://microlink.io/docs/sdk/methods/audios) — every audio source on a page, as an array of absolute URLs.
- [emails](https://microlink.io/docs/sdk/methods/emails) — every email address on a page, as an array.
- [technologies](https://microlink.io/docs/sdk/methods/technologies) — the tech stack powering a site.
- [lighthouse](https://microlink.io/docs/sdk/methods/lighthouse) — a full Lighthouse report.

Every method throws a typed [MicrolinkError](https://microlink.io/docs/sdk/getting-started/errors) 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](https://microlink.io/docs/sdk/methods/extract), or as the `data` option of [metadata](https://microlink.io/docs/sdk/methods/metadata). The `extract` pages cover the rules grammar — [selector](https://microlink.io/docs/sdk/methods/extract/selector), [attr](https://microlink.io/docs/sdk/methods/extract/attr), [type](https://microlink.io/docs/sdk/methods/extract/type), [nested](https://microlink.io/docs/sdk/methods/extract/attr#nested-rules) and [fallback](https://microlink.io/docs/sdk/methods/extract#fallback-rules) rules — shared by `extract`, the content methods, and the collections.

Installing the package also ships a [microlink binary](https://microlink.io/docs/sdk/getting-started/cli) 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 runtimes** — [Cloudflare Workers](https://workers.cloudflare.com/), [Vercel Edge Functions](https://vercel.com/features/edge-functions), [Deno](https://deno.com/), or any provider that supports [WinterCG](https://wintercg.org/), with nothing extra to configure.
- **Browsers** — through any bundler, with the same import.

A worker that returns extracted data as JSON:

```js
importcreateClientfrom'microlink.io'

constmicrolink=createClient({apiKey:MICROLINK_API_KEY})

exportdefault{

asyncfetch(request){

const{title,image}=awaitmicrolink.metadata('https://example.com')

returnResponse.json({title,image})

}

}
```

Keep your `apiKey` out of browser code: the [x-api-key](https://microlink.io/docs/api/basics/authentication) 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](https://microlink.io/link-preview).