# Generator

## Generate a QR Code

<mark style="color:blue;">`GET`</mark> `https://api.night-api.com/images/qrcode`

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| authorization<mark style="color:red;">\*</mark> | String | Your API key |

#### Request Body

| Name                                   | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| backgroundDimming                      | String  | Color of the dimming mask above the background image.                                                                                                                                                                                                                                                                                                                                                          |
| logoImage                              | String  | <p>Logo image to be displayed at the center of the QR code.</p><p></p><p><em>Accepts a <code>data:</code> string in web browsers or a Buffer in Node.js.</em></p><p></p><p><em><strong>When set to</strong><strong> </strong><strong><code>undefined</code></strong><strong> </strong><strong>or</strong><strong> </strong><strong><code>null</code></strong><strong>, the logo is disabled.</strong></em></p> |
| logoCornerRadius                       | Number  | Corner radius of the logo image in pixels.                                                                                                                                                                                                                                                                                                                                                                     |
| backgroundImage                        | String  | <p>Background image to be used in the QR code.</p><p><em>Accepts a <code>data:</code> string in web browsers or a Buffer in Node.js.</em></p>                                                                                                                                                                                                                                                                  |
| autoColor                              | Boolean | Automatically calculate the *colorDark* value from the QR code's background.                                                                                                                                                                                                                                                                                                                                   |
| colorLight                             | String  | Color of the empty areas on the QR code.                                                                                                                                                                                                                                                                                                                                                                       |
| colorDark                              | String  | Color of the blocks on the QR code.                                                                                                                                                                                                                                                                                                                                                                            |
| size                                   | Number  | Size of the QR code in pixel.                                                                                                                                                                                                                                                                                                                                                                                  |
| text<mark style="color:red;">\*</mark> | String  | Text to be encoded in the QR code.                                                                                                                                                                                                                                                                                                                                                                             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  status: 200,
  content: {
    type: 'Buffer',
    data: [
      137,  80,  78,  71,  13,  10,  26,  10,   0,   0,   0,  13,
       73,  72,  68,  82,   0,   0,   1, 244,   0,   0,   1, 244,
        8,   6,   0,   0,   0, 203, 214, 223, 138,   0,   0,   0,
        6,  98,  75,  71,  68,   0, 255,   0, 255,   0, 255, 160,
      189, 167, 147,   0,   0,  32,   0,  73,  68,  65,  84, 120,
      156, 236, 221, 121, 120,  85, 245, 157,  63, 240, 247,  57,
      231, 174, 185, 185, 217,  73,  66,  54,  18, 194, 190, 133,
       69, 109,   1, 177, 173,  27,  34,  83,  28, 117, 164, 237,
       60,  51, 173, 117,
      ... 17703 more items
    ]
  }
}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{
    "status": 400,
    "content": "Invalid Key"
}
```

{% endtab %}
{% endtabs %}

**List of available parameters to put in the body or in the module function**

* text <mark style="color:red;">**Required**</mark>
* size
* colorDark
* colorLight
* autoColor
* backgroundImage
* backgroundDimming
* logoImage
* logoCornerRadius

```javascript
const axios = require("axios");
const { writeFileSync } = require("fs");

axios.get('https://api.night-api.com/images/qrcode', {
    headers: {
        authorization: "Your API token"
    },
    data: {
        text: "https://night-api.com/"
    }
})
.then(function (res) {
    writeFileSync(`${__dirname}/qrcode.png`, Buffer.from(res.data.content, 'base64'));
    console.log(res.data);
})
```

Or with the module

```javascript
// Return: Promise

const { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');

const qrcode = await api.qrcode.generate({
    text: "https://night-api.com"
})
```
