# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.night-api.com/images/utils/qr-code/reader.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
