L'API letras pick letters at random, according to their frequency in the language.
The application basic URL is http://api.locongres.org/letras.php. You have to add mandatory parameters and you can add facultative parameters. If you don't know how to add parameters in an URL, you can read this tutorial.
You have to add the following parameters :
For instance, if you want to pick letters with a frequency consistent with Provence occitan, you have to use the URL http://api.locongres.org/letras.php?key=[la_vòsta_clau_API]&var=provenc. You get the following result :
{
"query": [
{
"f",
}
]
}
Specify the number of letters you want with the "nb" parameter. Its value is a number between 1 and 50. If you don't specify this parameter, by default you will have only one letter.
For instance, if you want to draw 15 letters according to their frequency in Languedoc occitan, you have to use the URL http://api.locongres.org/letras.php?key=[la_vòsta_clau_API]&var=lengadoc&nb=15. You get the following result :
{
"query": [
{
"f",
"a",
"í",
"b",
"s",
"t",
"è",
"m",
"l",
"u",
"ç",
"g",
"s",
"e",
"a",
}
]
}
Specify if you want the draw to include accented letters with the "acc" parameter. It allows the values "y" (yes) and "n" (no). If you don't specify this parameter, by default you will get accented characters.
For instance, if you want to draw 5 non-accented letters according to their frequency in Gascony occitan, you have to use the URL http://api.locongres.org/letras.php?key=[la_vòsta_clau_API]&var=gascon&nb=5&acc=n. You get the following result :
{
"query": [
{
"j",
"u",
"e",
"b",
"a",
}
]
}
Specify if you want the draw to include foreign letters (k, w, y) with the "foreign" parameter. It allows the values "y" (yes) and "n" (no). If you don't specify this parameter, by default you will not get foreign letters.
For instance, if you want to draw 10 letters according to their frequency in Languedoc occitan, including k, w and y, you have to use the URL http://api.locongres.org/letras.php?key=[la_vòsta_clau_API]&var=lengadoc&nb=10&foreign=o. You get the following result :
{
"query": [
{
"j",
"u",
"e",
"b",
"g",
"w",
"a",
"s",
"s",
"a",
}
]
}
The default output format is JSON. But you can get an XML output in adding "format=xml" to the l'URL.
For instance, if you want to get 12 letters accordingly to their frequency in Provence occitan in XML format, you can use the URL http://api.locongres.org/letras.php?key=[la_vòsta_clau_API]&var=provenc&nb=32&format=xml. You get the following result :
<query>
<letter id="1">s</letter>
<letter id="2">i</letter>
<letter id="3">u</letter>
<letter id="4">p</letter>
<letter id="5">s</letter>
<letter id="6">a</letter>
<letter id="7">l</letter>
<letter id="8">o</letter>
<letter id="9">o</letter>
<letter id="10">u</letter>
<letter id="11">l</letter>
<letter id="12">g</letter>
</query>
If there are errors in the input URL or if the query returns no form, the API returns an error with a code and an error text in english. You can see below the error codes with their text :
The output you get is a list of letters.
{
"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": "string"
},
"minItems": 1,,
"maxItems": 50
}
}
}
<! ELEMENT query (letter) >
<! ELEMENT error (#PCDATA) >
<! ATTLIST error code ID #REQUIRED >
<! ELEMENT letter (#PCDATA) >
<! ATTLIST letter id ID #REQUIRED >
© Lo Congrès Permanent de la Lenga Occitana, 2017, all rights reserved - Contact Lo Congrès