How to capture a website screenshot with Microlink from Node.js
Use Microlink’s Node.js SDK to capture a website screenshot, customize the output, and handle the returned image asset.
To capture a website screenshot with Microlink from Node.js, install its official microlink.io package, call microlink.screenshot(url, options), and use the returned screenshot asset’s url. The SDK returns an asset object with metadata; it does not automatically save a local image file.
1. Install the Microlink SDK
Install the package in your Node.js project:
npm install microlink.io
The documented SDK example uses ES module imports. Use an environment configured for ES modules, such as a project whose package.json contains "type": "module", or adapt the import to your project’s module format. The cited documentation does not specify a Node.js compatibility range.
2. Take your first screenshot
Create screenshot.mjs with the following runnable example:
import createClient from 'microlink.io'
const microlink = createClient()
try {
const screenshot = await microlink.screenshot('https://example.com')
console.log('Asset URL:', screenshot.url)
console.log('Image type:', screenshot.type)
console.log('Dimensions:', `${screenshot.width} × ${screenshot.height}`)
console.log('Bytes:', screenshot.size)
} catch (error) {
console.error('Screenshot request failed:', error)
process.exitCode = 1
}
Run it with node screenshot.mjs. The result is the SDK asset object: fields include the hosted asset URL, type, width, height, and byte size. Save or pass along screenshot.url when your application needs the image reference.
3. Choose screenshot options
Pass options as the second argument to screenshot(). These settings customize what is captured and the returned image.
| Need | Option | Behavior |
|---|---|---|
| Capture the complete scrollable page | fullPage: true |
Captures the full page instead of just the visible viewport. |
| Choose an image format | type: 'png' or type: 'jpeg' |
The SDK reference documents PNG as the default and PNG or JPEG as supported types. |
| Set JPEG compression quality | quality: 80 |
JPEG quality ranges from 0 to 100; the documented default is 80. This option is relevant to JPEG output. |
| Capture one visible region | element: 'main' |
Uses a CSS selector to target a visible DOM element. |
| Skip page metadata extraction | meta: false |
Microlink’s guide recommends this when you need only a screenshot. |
Full-page JPEG example
const screenshot = await microlink.screenshot('https://example.com', {
fullPage: true,
type: 'jpeg',
quality: 80
})
console.log(screenshot.url)
Capture a specific element
Use a selector for a visible element when the whole page is unnecessary:
const screenshot = await microlink.screenshot('https://example.com', {
element: 'main'
})
console.log(screenshot.url)
Choose a selector that identifies the intended content on the target page. A selector for a missing or non-visible element cannot identify the region you want to capture.
Screenshot-only request
If your task needs the screenshot but not extracted page metadata, pass the documented meta: false option:
const screenshot = await microlink.screenshot('https://example.com', {
meta: false
})
This is Microlink’s documented behavior; the research does not include a measurement of its effect on latency or cost.
4. Use the screenshot asset
The SDK gives your program a hosted asset URL rather than writing the image to disk. For example, you can return that URL from an application endpoint or store it alongside your own capture record. If you need a local file, fetch the asset URL and write the response body yourself:
import { writeFile } from 'node:fs/promises'
const screenshot = await microlink.screenshot('https://example.com')
const response = await fetch(screenshot.url)
if (!response.ok) {
throw new Error(`Could not download screenshot: HTTP ${response.status}`)
}
const image = new Uint8Array(await response.arrayBuffer())
await writeFile('screenshot.png', image)
console.log('Saved screenshot.png')
Use an extension that matches the requested image type. If you request JPEG, for example, save with a .jpg extension. The download is a separate HTTP request to the returned asset URL.
5. Understand SDK and HTTP API responses
The SDK is a convenience layer around Microlink’s API. Its documented call is microlink.screenshot(url, options), and the returned value is the screenshot asset object. The raw API uses a target url and screenshot=true; its normal JSON response places asset information under data.screenshot. Do not use the SDK’s screenshot.url shape when parsing raw API JSON.
Raw HTTP API with Node.js
This example makes the equivalent request directly and reads the screenshot metadata from the API JSON envelope:
const endpoint = new URL('https://api.microlink.io/')
endpoint.searchParams.set('url', 'https://example.com')
endpoint.searchParams.set('screenshot', 'true')
endpoint.searchParams.set('meta', 'false')
const response = await fetch(endpoint)
if (!response.ok) {
throw new Error(`Microlink API returned HTTP ${response.status}`)
}
const result = await response.json()
const asset = result.data.screenshot
console.log(asset.url, asset.type, asset.width, asset.height, asset.size)
For a response intended to be used directly as an image, Microlink documents embed: 'screenshot.url'. The standard JSON response is more useful when your code needs the asset URL and metadata; use the embedded form where a direct image response fits your consumer.
Raw HTTP API with cURL
curl -G 'https://api.microlink.io/' \
--data-urlencode 'url=https://example.com' \
--data-urlencode 'screenshot=true' \
--data-urlencode 'meta=false'
The default response is JSON. Inspect data.screenshot.url to obtain the hosted image asset. Add embed=screenshot.url when you need Microlink’s documented direct image response.
Raw HTTP API with Python
import requests
response = requests.get(
'https://api.microlink.io/',
params={
'url': 'https://example.com',
'screenshot': 'true',
'meta': 'false',
},
timeout=90,
)
response.raise_for_status()
result = response.json()
asset = result['data']['screenshot']
print(asset['url'], asset['type'], asset['width'], asset['height'], asset['size'])
These raw API examples clarify the HTTP request shape; the article’s primary walkthrough uses the Node.js SDK. Microlink documents that the API can be used without an API key, while advising that production users usually use a plan. Quotas and plan terms can change, so check Microlink’s current official information before relying on a limit.
6. Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
Cannot use import statement outside a module |
The script is running as CommonJS while using the documented ES module import. | Use an .mjs file or configure the project for ES modules, then rerun with Node. |
| The program prints a URL but no local file appears | The SDK returns a hosted screenshot asset URL; it does not automatically save a file. | Fetch screenshot.url and write the response bytes, as shown above. |
| The screenshot is only the visible screen | Viewport capture is the default behavior. | Set fullPage: true if the complete scrollable page is needed. |
| The screenshot is not the intended region | The selector may not match the desired visible element. | Use a CSS selector for the actual visible content and try a broader or more specific selector as appropriate. |
| Code cannot find screenshot metadata in the response | SDK asset fields and raw API JSON have different shapes. | Read screenshot.url for the SDK result; for raw API JSON read result.data.screenshot.url. |
| Request fails or returns an HTTP error | The API request did not complete successfully; the documentation reviewed here does not establish one universal cause. | Log the HTTP status and response details, confirm the target URL is valid and reachable, and retry transient failures with a bounded retry policy. |
7. Performance, reliability, and cost
- Keep the response small when appropriate: select JPEG and a suitable quality when JPEG is acceptable; use PNG when its format is preferred. The cited docs describe the quality setting but do not provide comparative size or speed benchmarks.
- Request only what you use: use
meta: falsefor screenshot-only work, following Microlink’s guide. This research does not quantify a performance improvement. - Handle remote dependencies: a hosted browser must load the target site before producing an asset. Your code should handle request failures, check download HTTP status, and avoid assuming every capture succeeds.
- Make retries bounded: if your application retries transient failures, limit attempts and use backoff so a broken target does not create an unbounded request loop.
- Check current access terms: Microlink’s guide states a free daily request allowance, but the reviewed page does not date that figure. Treat quotas and plans as changeable and verify current terms directly before budgeting production usage.
The research did not execute these examples or independently measure performance, reliability, or security. Microlink’s product page makes performance and isolation claims; those claims are omitted here because they were not independently validated.
Or skip the browser setup
ScreenshotNeo returns a screenshot with one GET request, and its API supports PNG, JPEG, WebP, and PDF. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also provides an MCP server with screenshot, page-info, and PDF tools for AI agents.
Install no browser automation stack for this call; supply an API key and target URL. See the ScreenshotNeo API documentation for configuration and the other supported options.
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' })
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`)
if (!res.ok) {
throw new Error(`ScreenshotNeo returned HTTP ${res.status}`)
}
const image = new Uint8Array(await res.arrayBuffer())
await writeFile('shot.webp', image)
The call returns the image response, so this example saves its bytes locally. ScreenshotNeo includes every feature on every plan: 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month, with no card.
FAQ
Does Microlink return a data URL or an asset URL?
The documented SDK response includes a hosted screenshot asset URL and metadata. The raw API’s regular JSON response nests the asset under data.screenshot.
Can I capture just part of a page?
Yes. Pass a CSS selector in the element option to target a visible DOM element.
Do I need a Microlink API key for the example?
The screenshot guide says the API works without a key. Verify current access quotas and plan terms before using it in production.
Which image format should I choose?
Use PNG by default or JPEG when its compression settings fit your use case. Set quality for JPEG output.


