## Table of Contents

- [API](#api)
  - [Mql(\, \[options\], \[httpoptions\])](#mql-options-httpoptions)
    - [url](#url)
    - [options](#options)
      - [apiKey](#apikey)
      - [cache](#cache)
      - [retry](#retry)
    - [httpOptions](#httpoptions)
  - [mql.stream(\, \[options\], \[httpoptions\])](#mqlstream-options-httpoptions)
  - [mql.buffer(\, \[options\], \[httpoptions\])](#mqlbuffer-options-httpoptions)

---

[](https://microlink.io/docs/api/getting-started/overview)

[API](https://microlink.io/docs/api/getting-started/overview)

[](https://microlink.io/docs/guides)

GUIDES

[](https://microlink.io/docs/mql/getting-started/overview)

MQL

[](https://microlink.io/docs/sdk/getting-started/overview)

SDK

[](https://microlink.io/docs/cards/getting-started/overview)

CARDS

## API

### Mql(\<url\>, \[options\], \[httpoptions\])

#### url

The target URL for getting content.

#### options

You can pass any API Parameters from [Microlink API](https://microlink.io/docs/api/getting-started/overview) as an option.

``` js
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}`)
```

\

##### apiKey

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

> **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.

``` js
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.

##### retry

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

#### httpOptions

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

[got](https://ghub.io/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\])

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

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

instead of a Promise.

### mql.buffer(\<url\>, \[options\], \[httpoptions\])

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

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

instead of a Promise.