import mql from '@microlink/mql' const { data } = await mql('https://news.ycombinator.com/item?id=13713480', { screenshot: true, embed: "screenshot.url" })
embed
Type: <string>
It returns the specified data field as response over the target url, mimicking the same headers and body of the original resource.
You can use dot notation to reference a nested data field of the response payload.
Why use embed
The embed parameter transforms Microlink API from a JSON endpoint into a direct asset server. Instead of receiving JSON and parsing it with JavaScript, you get the actual resource (image, PDF, etc.) that can be used directly in:
- HTML
<img>tags - CSS
background-imageproperties - Markdown image syntax
- Open Graph meta tags
HTML integration
Embed screenshots directly in your HTML markup:
And it will be rendered as an external image:
CSS integration
Use embedded URLs directly in stylesheets:
Markdown integration
Embed in any Markdown document:
Common embed fields
| Field | Description | Use case |
|---|---|---|
screenshot.url | Screenshot image URL | Social cards, previews |
pdf.url | Generated PDF URL | Document downloads |
image.url | Primary image URL | Link previews |
logo.url | Website logo URL | Brand displays |
video.url | Video source URL | Media embeds |
Combining with other parameters
Embed works well with other parameters for customized output:
import mql from '@microlink/mql' const { data } = await mql('https://microlink.io', { screenshot: true, device: "iPhone X", embed: "screenshot.url" })
Generate and embed a mobile screenshot directly.
Open Graph images
A common use case is generating dynamic Open Graph images:
Security considerations
To authenticate requests securely when using embed in client-side code, use
proxy
and edge-proxy
to protect your API credentials.Read more about that at the authentication section.