# getLexicon

## Requête

Permet de récupérer les mots. La réponse retourne un array d'objets [word](https://connector-api.orelc.ac/objets/word).

#### Endpoint

```
[Domain]/academy/api/v1/Dictionary/getLexicon
```

#### Body

```json
{
    "letter" : "a",
    "fromLanguage" : "km",
    "toLanguage" : "fr"
}
```

{% tabs %}
{% tab title="Javascript" %}

```javascript
const endpoint = "[endpoint]";
const apiKey = "[myAPIKey]";

// Use the username and password to obtain data based on user rights
const username = "[username]"; // optionnel
const password = "[password]"; // optionnel

fetch(endpoint, {
    method: "POST",
    headers: {
        "Authorization": apiKey,
        "Content-Type": "application/json",
        "username ": username,
        "password ": password 
    },
    body: JSON.stringify({
        letter: "a",
        fromLanguage: "km",
        toLanguage: "fr"
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Erreur :", error));

```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}

Description des champs de la requête

| Champ        | Type    | Description                                                                 | Valeur      |
| ------------ | ------- | --------------------------------------------------------------------------- | ----------- |
| letter       | string  | La lettre initiale des mots du lexique                                      | requise     |
| fromLanguage | string  | La langue d'entrée (ISO 639-1)                                              | requise     |
| toLanguage   | string  | La langue de traduction (ISO 639-1)                                         | requise     |
| varieties    | boolean | false, pour masquer les informations des dialectes (valeur par defaut true) | optionnelle |
|              |         |                                                                             |             |

## Réponse

<pre class="language-json"><code class="lang-json">{
    "Dictionary": {
        "version": 7,
        "authorization": "all",
        "endValidity": "",
        "variety": "shiKomori ●",
        "entries": "213/213",
        "words": [
            {
<strong>                "id": 1065,
</strong>                "hasDefinition": false,
                "km": "-a",
                "fr": [
                    "à",
                    "de"
                ],
                "isShimaore": true,
                "isShimwali": true,
                "isShindzuani": true,
                "isShingazidja": true,
                "dialectSymbols": "●"
            },
            {
<strong>                "id": 1066,
</strong>                "hasDefinition": true,
                "km": "-a âiɓu",
                "fr": [
                    "immoral (d'-)",
                    "obscène (d'-)"
                ],
                "isShimaore": false,
                "isShimwali": false,
                "isShindzuani": true,
                "isShingazidja": true,
                "dialectSymbols": "▲  ◼"
            },
            {
                "id": 1101,
                "hasDefinition": false,
                "km": "aɓaɗan",
                "fr": [
                    "jamais"
                ],
                "isShimaore": true,
                "isShimwali": true,
                "isShindzuani": true,
                "isShingazidja": true,
                "dialectSymbols": "●"
            },
            {
                "id": 1103,
                "hasDefinition": true,
                "km": "aɓuɗu (u-)",
                "fr": [
                    "vénérer"
                ],
                "isShimaore": true,
                "isShimwali": true,
                "isShindzuani": true,
                "isShingazidja": true,
                "dialectSymbols": "●"
            }
        ]
    },
    ...
}
</code></pre>

{% hint style="warning" %}
Avec une **authorization** de démo, cette requête ne renvoie qu'un nombre limité de mots. Le nombre de mots du dictionnaire est inscrits dans le champ **entries.** Vous pouvez vous servir des champs **authorization** et **entries** pour en informer l'utilisateur.
{% endhint %}

Description des champs de la réponse

| Champ | Type  | Description                                                                                  |
| ----- | ----- | -------------------------------------------------------------------------------------------- |
| words | array | La liste d'objet [word ](https://connector-api.orelc.ac/objets/word)au format entrée/valeurs |
|       |       |                                                                                              |
