API

mql(<url>, [options], [httpOptions])

required
Type: <string>
The target URL for getting content.
Type: <object>
You can pass any API Parameters from Microlink API as an option.
const mql = require('@microlink/mql')

const { status, data, response } = await mql('https://kikobeats.com', {
  screenshot: true,
  device: 'iPad',
  palette: true
})

console.log(`My screenshot at ${data.screenshot.url}`)

Additionally, you can configure:
Type: <string>
The API Key used for authenticating your requests as x-api-key header.
When the apiKey is provided, the as endpoint will be used.
Type: <object>
Note: this feature is only available for Node.js.
When you pass an object that follows Map API, you can enable serve response from your storage cache in order to save API if they have been previously done.
const mql = require('@microlink/mql')
const cache = new Map()

let data

data = await mql('https://example.com', { cache })
console.log(data.response.fromCache)
// => false

data = await mql('https://example.com', { cache })
console.log(data.response.fromCache)
// => true
Caching feature is only available in the Node.js bundle.
Consider to pass for supporting
See to know more.
Type: <number>
Default: 2
Defines how many retries can be done before an API call is considered failed.
See to know more.
Type: <object>
Any additional option will be passed to or that are the internal HTTP clients used for Node.js and browser respectively.
That's necessary for some user workflow, e.g., passing authentication headers without exposing credentials.

mql.stream(<url>, [options], [httpOptions])

Returns a instead of a Promise.

mql.buffer(<url>, [options], [httpOptions])

Returns a instead of a Promise.