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.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 
keyv
 for supporting most popular databases storages
See 
got#cache
 to know more.Type: <number>
Default: 2
Default: 2
Defines how many retries can be done before an API call is considered failed.
See 
got#retry
 to know more.Type: <object>
Any additional option will be passed to 
got
 or ky
 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 
Stream
 instead of a Promise.mql.buffer(<url>, [options], [httpOptions])
Returns a 
Buffer
 instead of a Promise.