API et modules

API sinonimes - Mode d'emploi

L'API sinonimes vous permet d'obtenir les synonymes d'un mot en occitan.

L'URL d'entrée

L'URL de base de l'application est http://api.locongres.org/synonyms. Vous devez y ajouter les paramètres obligatoires. Si vous ne savez pas ajouter des paramètres à un URL, nous vous renvoyons à ce tutoriel.

Les paramètres obligatoires

Il vous faut obligatoirement indiquer les paramètres suivants :

  • Votre clé API : pour utiliser les API du Congrès, il vous faut indiquer une clé API personnelle que nous pouvons vous fournir sur la page dédiée. Vous l'indiquez avec le paramètre "key".
  • Le mot : indiquez le mot dont vous voulez rechercher les synonymes avec le paramètre "term".

Par exemple, si vous voulez chercher des synonymes de "polit" dans toutes les variétés de l'occitan, vous pouvez utiliser l'URL http://api.locongres.org/synonyms?key=[votre_clé_API]&term=polit. Vous obtenez le résultat suivant :

{
    "query": [
        {
            "id": "18601",
            "orth": "alindat",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "46788",
            "orth": "aunèste",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "62313",
            "orth": "bèl",
            "PoS": "AJ0110",
            "var": "oc-lengadoc",
        },
        {
            "id": "62769",
            "orth": "belòi",
            "PoS": "AJ0110",
            "var": "oc-lengadoc",
        },
        {
            "id": "64375",
            "orth": "beroget",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "64410",
            "orth": "berogin",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "64451",
            "orth": "beròi",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "64507",
            "orth": "berojon",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "65567",
            "orth": "bèth",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "66579",
            "orth": "bien aprés",
            "PoS": "AJ0110",
            "var": "oc-auvern",
        },
        {
            "id": "66585",
            "orth": "bien graciós",
            "PoS": "AJ0110",
            "var": "oc-auvern",
        },
        {
            "id": "66594",
            "orth": "bien oneste",
            "PoS": "AJ0110",
            "var": "oc-auvern",
        },
        {
            "id": "72698",
            "orth": "bon",
            "PoS": "AJ0110",
            "var": "oc-lengadoc",
        },
        {
            "id": "73805",
            "orth": "borgau",
            "PoS": "AJ0110",
            "var": "oc-vivaraup",
        },
        {
            "id": "78666",
            "orth": "brave",
            "PoS": "AJ0110",
            "var": "oc-lemosin",
        },
        {
            "id": "78667",
            "orth": "brave",
            "PoS": "AJ0110",
            "var": "oc-vivaraup",
        },
        {
            "id": "81103",
            "orth": "bròi",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "82623",
            "orth": "brunit",
            "PoS": "AJ0110",
            "var": "oc-lengadoc",
        },
        {
            "id": "124778",
            "orth": "corós",
            "PoS": "AJ0110",
            "var": "oc-vivaraup",
        },
        {
            "id": "126008",
            "orth": "cortés",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "128150",
            "orth": "crane",
            "PoS": "AJ0110",
            "var": "oc-lemosin",
        },
        {
            "id": "242928",
            "orth": "gente",
            "PoS": "AJ0110",
            "var": "oc-lemosin",
        },
        {
            "id": "274888",
            "orth": "jòli",
            "PoS": "AJ0110",
            "var": "oc-vivaraup",
        },
        {
            "id": "286261",
            "orth": "lis",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "286511",
            "orth": "lisse",
            "PoS": "AJ0110",
            "var": "oc-auvern",
        },
        {
            "id": "329984",
            "orth": "oneste",
            "PoS": "AJ0110",
            "var": "oc-vivaraup",
        },
        {
            "id": "363741",
            "orth": "plan",
            "PoS": "AJ0110",
            "var": "oc-auvern",
        },
        {
            "id": "364713",
            "orth": "plasent",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        },
        {
            "id": "368056",
            "orth": "polidet",
            "PoS": "AJ0110",
            "var": "oc-gascon",
        }
    ]
}

Le paramètre facultatif

Indiquez dans quelle variété de l'occitan vous recherchez des synonymes avec le paramètre "var". Pour le moment, il accepte les valeurs "auvern" (pour l'occitan auvergnat), "gascon" (pour l'occitan gascon), "lemosin" (pour l'occitan limousin), "lengadoc" (pour l'occitan languedocien), "provenc" (pour l'occitan provençal) et "vivaraup" (pour l'occitan vivaro-alpin).

Par exemple, si vous voulez chercher des synonymes de "parlar" en occitan vivaro-alpin, vous pouvez utiliser l'URL http://api.locongres.org/synonyms?var=vivaraup&term=parlar. Vous obtenez le résultat suivant :

{
    "query": [
        {
            "id": 261194,
            "orth": "charrar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 263297,
            "orth": "devisar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 269011,
            "orth": "calcular",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 270720,
            "orth": "causar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 270732,
            "orth": "provocar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 276412,
            "orth": "contestar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 276427,
            "orth": "discutir",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 276903,
            "orth": "conversar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 276913,
            "orth": "dialogar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 283986,
            "orth": "dialecte",
            "PoS": "N1110"
            "var": "oc-vivaraup"
        },
        {
            "id": 284562,
            "orth": "barjar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 284570,
            "orth": "discutar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 284579,
            "orth": "chicotear",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 284587,
            "orth": "chapitrolhar",
            "PoS": "V000050000000"
            "var": "oc-vivaraup"
        },
        {
            "id": 309207,
            "orth": "lengatge",
            "PoS": "N1110"
        }
    ]
}

Le format de sortie

Par défaut, le format de sortie est JSON. Mais vous pouvez obtenir une sortie au format XML en ajoutant "format=xml" à l'URL.

Par exemple, si vous voulez afficher les synonymes en occitan provençal de "estatjant" au format XML, vous pouvez utiliser l'URL http://api.locongres.org/synonyms.php?key=[your_APIkey]&var=provenc&term=estatjant&format=xml. Vous obtenez le résultat suivant :

<query>
    <syn id="245462">
        <orth>abitant</orth>
        <PoS>N1110</PoS>
        <var>oc-provenc</var>
    </syn>
</query>

Les erreurs

S'il y a des erreurs dans l'URL ou si la requête ne retourne aucune forme, l'API retourne une erreur avec un code et un texte d'erreur en anglais. Vous trouverez ci-dessous, pour chaque code d'erreur, la traduction de son texte en français :

  • 1 : Vous devez indiquer une clé API
  • 2 : Clé API invalide
  • 3 : Format incorrect ("json" et "xml" acceptés)
  • 4 : Vous devez indiquer un mot
  • 5 : Vous devez indiquer une variété
  • 6 : Variété incorrecte ("auvern", "gascon", "lengadoc", "lemo", "provenc" et "vivaraup" acceptés)
  • 7 : Nous n'avons trouvé aucun synonyme avec vos spécifications

Les informations en sortie

En sortie, vous obtenez une liste de synonymes avec un identifiant unique. Pour chacun est donné :

  • Son orthographe
  • Sa catégorie grammaticale
  • Sa variété : "oc-auvern" (occitan auvergnat), "oc-gascon" (occitan gascon), "oc-lemosin" (occitan limousin), "oc-lengadoc" (occitan languedocien), "oc-provenc" (occitan provençal), "oc-vivaraup" (occitan vivaro-alpin)

Les catégories grammaticales sont indiquées avec la norme Eagles. Vous trouverez une explication sur comment Lo Congrès utilise la norme Eagles au chapitre 5 de ce document.

JSON schema

{
    "type": "object",
    "properties": {
        "error": {
            "type": "object",
            "properties": {
                "code": {
                    "description": "The unique identifier for an error",
                    "type": "integer"
                },
                "text": {
                    "description": "A description of the error",
                    "type": "string"
                }
            },
            "required": ["code", "text"]
        },
        "query": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "orth": {
                        "type": "string"
                    },
                    "PoS": {
                        "type": "string"
                    },
                    "var": {
                        "type": "string"
                    },
                },
                "required": ["id", "orth", "PoS", "var"]
            },
            "minItems": 1
        }
    }
}

DTD XML

<! ELEMENT query (syn) >

<! ELEMENT error (#PCDATA) >
<! ATTLIST error code ID #REQUIRED >

<! ELEMENT orth (#PCDATA) >

<! ELEMENT PoS (#PCDATA) >

<! ELEMENT syn (orth, PoS, var) >
<! ATTLIST syn id ID #REQUIRED >

<! ELEMENT var (#PCDATA) >

© Lo Congrès Permanent de la Lenga Occitana, 2017, tous droits réservés - Contacter Lo Congrès