> ## Documentation Index
> Fetch the complete documentation index at: https://dev.kloo.li/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentification

> Authentifiez chaque requête de l’API Kloo avec une clé API Bearer.

Toutes les requêtes API nécessitent une authentification via une clé API envoyée dans l’en-tête `Authorization` :

```http theme={null}
Authorization: Bearer {api_key}
```

Récupérez votre clé API sur [https://kloo.li/account-api](https://kloo.li/account-api).

<Warning>
  La régénération invalide immédiatement l’ancienne clé. Mettez à jour toutes vos intégrations avant de régénérer.
</Warning>

## Playground

Dans le playground API, collez votre clé dans le champ **Authorization** sous la forme `Bearer {api_key}`. Ne partagez jamais votre clé publiquement.

## Exemple

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.kloo.li/v1/user' \
    --header 'Authorization: Bearer {api_key}'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.kloo.li/v1/user', {
    method: 'GET',
    headers: {
      Authorization: 'Bearer {api_key}',
      Accept: 'application/json'
    }
  });
  const data = await response.json();
  console.log(data);
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.kloo.li/v1/user', {
    method: 'GET',
    headers: {
      Authorization: 'Bearer {api_key}',
      Accept: 'application/json'
    }
  });
  console.log(await response.json());
  ```

  ```python Python theme={null}
  import requests

  url = 'https://api.kloo.li/v1/user'
  headers = {
      'Authorization': 'Bearer {api_key}',
      'Accept': 'application/json'
  }
  response = requests.get(url, headers=headers)
  print(response.json())
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.kloo.li/v1/user');
  curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
      'Authorization: Bearer {api_key}',
      'Accept: application/json',
    ],
  ]);
  echo curl_exec($ch);
  curl_close($ch);
  ```

  ```go Go theme={null}
  package main

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

  func main() {
    req, _ := http.NewRequest(http.MethodGet, "https://api.kloo.li/v1/user", nil)
    req.Header.Set("Authorization", "Bearer {api_key}")
    req.Header.Set("Accept", "application/json")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.kloo.li/v1/user"))
    .header("Authorization", "Bearer {api_key}")
    .header("Accept", "application/json")
    .GET()
    .build();
  HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer {api_key}");
  client.DefaultRequestHeaders.Add("Accept", "application/json");
  var response = await client.GetStringAsync("https://api.kloo.li/v1/user");
  Console.WriteLine(response);
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'

  uri = URI('https://api.kloo.li/v1/user')
  req = Net::HTTP::Get.new(uri)
  req['Authorization'] = 'Bearer {api_key}'
  req['Accept'] = 'application/json'
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
  puts res.body
  ```
</CodeGroup>
