# Authentication

You need to authenticate every request to the NOTO API using your API Key ([find out how to create an API key](/noto-api-docs/get-started/create-your-project/api-keys.md)).

The API key should be passed in the Header of the request, using the key:`api-key`\
\
Here you can see a example in Bash:

```bash
# CHANGE ME
url="https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld"
# CHANGE ME
api_key="your_api_key"

curl -X GET -H "api-key: $api_key" $url
```

### Here you can see additional examples in the following languages:

<details>

<summary>Node.js</summary>

```javascript
const fetch = require('node-fetch');

// CHANGE ME
const url = 'https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld'; 
// CHANGE ME
const api_key = 'your_api_key';

async function fetchData(url, api_key) {
    try {
        const response = await fetch(url, {
            method: 'GET',
            headers: { 'api-key': api_key }
        });
        if (!response.ok) throw new Error('Error: network response');
        const data = await response.json();
        console.log('Server response:', data);
    } catch (error) {
        console.error('Fetch error:', error);
    }
}

// CALL FUNCTION
fetchData();
```

</details>

<details>

<summary>Python</summary>

```python
import requests

# CHANGE ME
url = "https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld"
# CHANGE ME
api_key = "your_api_key"

headers = {"api-key": api_key}

try:
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    print(response.json())
except requests.exceptions.HTTPError as errh:
    print("An HTTP error occurred:", errh)
except requests.exceptions.RequestException as err:
    print("A Request error occurred:", err)
```

</details>

<details>

<summary>Go</summary>

```go
package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    // CHANGE ME
    url := "https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld"
    // CHANGE ME
    api_key := "your_api_key"

    client := &http.Client{}
    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }

    req.Header.Add("api-key", api_key)

    res, err := client.Do(req)
    if err != nil {
        fmt.Println("Error making request:", err)
        return
    }
    defer res.Body.Close()

    body, err := ioutil.ReadAll(res.Body)
    if err != nil {
        fmt.Println("Error reading response body:", err)
        return
    }

    fmt.Println("Server response:", string(body))
}
```

</details>

<details>

<summary>C#</summary>

```csharp
using System;
using System.IO;
using System.Net;

class Program
{
    static void Main()
    {
        // CHANGE ME
        string url = "https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld";
        // CHANGE ME
        string api_key = "your_api_key";

        try
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            request.Headers.Add("api-key", api_key);

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            using (Stream stream = response.GetResponseStream())
            using (StreamReader reader = new StreamReader(stream))
            {
                Console.WriteLine(reader.ReadToEnd());
            }
        }
        catch (WebException e)
        {
            Console.WriteLine("An error occurred while connecting to the API.");
            Console.WriteLine(e.Message);
            if (e.Response != null)
            {
                using (Stream stream = e.Response.GetResponseStream())
                using (StreamReader reader = new StreamReader(stream))
                {
                    Console.WriteLine("Response from server:");
                    Console.WriteLine(reader.ReadToEnd());
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("A general error occurred.");
            Console.WriteLine(e.Message);
        }
    }
}

```

</details>

<details>

<summary>Java</summary>

```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) {
        // CHANGE ME
        String url = "https://engine.noto.network/noto/api/v1/resolve?fullQualifiedDomain=example.tld";
        // CHANGE ME 
        String api_key = "your_api_key"; 

        try {
            URL obj = new URL(url);
            HttpURLConnection connection = (HttpURLConnection) obj.openConnection();

            connection.setRequestMethod("GET");
            connection.setRequestProperty("api-key", api_key);

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuilder response = new StringBuilder();

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            System.out.println(response.toString());
        } catch (Exception e) {
            System.out.println("An error occurred: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
```

</details>


---

# 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.noto.network/noto-api-docs/api-reference/authentication.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.
