# API

### [Mql(\<url\>, \[options\], \[httpoptions\])](https://microlink.io/docs/mql/getting-started/api#mqlurl-options-httpoptions)

#### [url](https://microlink.io/docs/mql/getting-started/api#url)

**required**\

Type: \<string\>

The target URL for getting content.

#### [options](https://microlink.io/docs/mql/getting-started/api#options)

Type: \<object\>

You can pass any API Parameters from [Microlink API](https://microlink.io/docs/api/getting-started/overview) 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:

##### [apiKey](https://microlink.io/docs/mql/getting-started/api#apikey)

Type: \<string\>

The API Key used for [authenticating](https://microlink.io/docs/api/basics/authentication) your requests as `x-api-key` header.

When the `apiKey` is provided, the [](https://pro.microlink.io/)

pro.microlink.io

as [endpoint](https://microlink.io/docs/api/basics/endpoint) will be used.

##### [cache](https://microlink.io/docs/mql/getting-started/api#cache)

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 [](https://www.npmjs.com/package/keyv)

keyv

for supporting [](https://github.com/lukechilds/keyv#official-storage-adapters)

most popular databases storages

See [](https://www.npmjs.com/package/got#cache)

got#cache

to know more.

##### [retry](https://microlink.io/docs/mql/getting-started/api#retry)

Type: \<number\>\
Default: 2

Defines how many retries can be done before an API call is considered failed.

See [](https://www.npmjs.com/package/got#retry)

got#retry

to know more.

#### [httpOptions](https://microlink.io/docs/mql/getting-started/api#httpoptions)

Type: \<object\>

Any additional option will be passed to [](https://ghub.io/got)

got

or [](https://github.com/sindresorhus/ky)

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](https://microlink.io/docs/api/parameters/headers) headers without exposing credentials.

### [mql.stream(\<url\>, \[options\], \[httpoptions\])](https://microlink.io/docs/mql/getting-started/api#mqlstreamurl-options-httpoptions)

Returns a [](https://nodejs.org/api/stream.html)

Stream

instead of a Promise.

### [mql.buffer(\<url\>, \[options\], \[httpoptions\])](https://microlink.io/docs/mql/getting-started/api#mqlbufferurl-options-httpoptions)

Returns a [](https://nodejs.org/api/buffer.html)

Buffer

instead of a Promise.