# Reader

{% hint style="info" %}
With the QRcode reader you can verify if the link is not dangerous for you or users
{% endhint %}

## Read a QR Code

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

#### Headers

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

#### Request Body

| Name                                    | Type          | Description                 |
| --------------------------------------- | ------------- | --------------------------- |
| image<mark style="color:red;">\*</mark> | Buffer or URL | The image in Buffer or URL. |

{% tabs %}
{% tab title="200: OK If the QRcode is a link" %}

```javascript
{
    "status": 200,
    "content": {
        "type": "link",
        "target": "https://night-api.com",
        "status": "Safe" // Status of danger on website by google AI
    }
}
```

{% endtab %}

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

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

{% endtab %}

{% tab title="200: OK If the QRcode is other of a link (geo, event, vcard, ...)" %}

```javascript
{
    "status": 200,
    "content": {
        "type": "geo", // Type of the QRcode
        "data": { // The QRcode but with tried data by the API (change beetween different QRcode data)
            "latitude": "48.85837",
            "longitude": "2.29448"
        },
        "target": "geo:48.85837,2.29448" // The data of the QRcode
    }
}
```

{% endtab %}
{% endtabs %}

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

axios.get('https://api.night-api.com/images/qrcode/reader', {
    headers: {
        authorization: "Your API token"
    },
    data: {
        image: readFileSync(`${__dirname}/qrcode.png`)
    }
})
.then(function (response) {
    console.log(response.data);
})
```

Or with the module

```javascript
const { readFileSync } = require('fs');
const { NightAPI } = require('night-api');
const api = new NightAPI("API_key");
const qrcode = readFileSync('./qrcode.png');


const QRcode_infos = api.qrcode.read(qrcode);

// OR with QRcode URL

const QRcode_infos = api.qrcode.read("https://mydomain.com/qrcode.png");

console.log(QRcode_infos);
```

***PS:** read function take Buffer or URL* parameter
