The top'Òc API allows you to translate a toponym from french to occitan and vice-versa and to get a city french and occitan names from its code or its coordinates.
The application basic URL is http://api.locongres.org/topoc.php. You have to add mandatory 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 the moment, you can find in the top'Òc cities of the following french departments : 09, 12, 31, 32, 33, 40, 46, 47, 64, 65, 81 and 82.
** Searching by city code or by coordinates is only possible for french territory cities.
For instance, you can search the occitan name of the Gers city whose french name is "Auch" with the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&name=Auch&lang=fr&dep=32. You get the following result :
{
"query": [
{
"id": 1248,
"oc": "Aush",
"fr": "Auch",
"dep": "32",
"lat": "43.65",
"long": "0.583333",
"cityCode": "32013"
}
]
}
You can search the french translation of the occitan country name "Bolívia" with the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&name=bolívia&lang=oc&type=country. You get the following result :
{
"query": [
{
"id": 4357,
"oc": "Bol\u00edvia",
"fr": "Bolivie",
"type": "country"
}
]
}
You can search the french and occitan names of the city whose code is "64001" with the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&code=64001. You get the following result :
{
"query": [
{
"id": 3056,
"oc": "Aast",
"fr": "Aast",
"dep": "64",
"lat": "43.2833",
"long": "-0.083333",
"cityCode": "64001"
}
]
}
You can search the french and occitan names of the city closest to the coordinates 43.4662 latitude and 1.35 longitude with the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&lat=43.4662&long=1.35. You get the following result :
{
"query": [
{
"id": 1038,
"oc": "Mur\u00e8th",
"fr": "Muret",
"dep": "31",
"lat": "43.4667",
"long": "1.35",
"cityCode": "31395"
"picture": "https://pedagogia.locongres.com/fichas/passejada/images/muret.jpg"
"pictureCredit": "Paternel 1"
"anecdoteOc": "qu'i morí lo rei Pèire II d'Aragon pendent la crotzada"
"anecdoteFr": "le roi Pierre II d'Aragon y est mort pendant la croisade"
"wikipedia": "http://oc.wikipedia.org/wiki/Mur%C3%A8th"
"cityCode": "31395"
}
]
}
You can choose to display only toponyms that are illustrated by a picture and a fun fact using the "ill" parameter with the value "true".
For instance, to display all the illustrated cities of Tarn, you can use the URL https://api.locongres.org/topoc.php?key=[la_vòsta_clau_API]&name=random&dep=81&ill=true. You get the following result :
{
"query": [
{
"id": 2591,
"oc": "Caramauç",
"fr": "Carmaux",
"dep": "81",
"lat": "44.05",
"long": "2.15",
"cityCode": "81060",
"picture": "https://pedagogia.locongres.com/fichas/passejada/images/caramauc.jpg",
"anecdoteOc": "s'i trabalha lo veire",
"anecdoteFr": "on y travaille le verre"
"wikipedia": "http://oc.wikipedia.org/wiki/Carmau%C3%A7"
"variety": "lengadoc"
}
]
}
The little fun facts are redacted in many occitan varieties. You can choose to display only the toponyms whose fun fact is in a specific variety with the "var" parameter. For the moment, it allows the values "gascon" (for Gascony occitan) e "lengadoc" (for Languedoc occitan).
For uinstance, to display randomly an illustrated city whose fun fact is in Gascony occitan, you can use the URL http://api.locongres.org/topoc.php?key=[la_vòsta_clau_API]&name=random&ill=true&var=gascon. You get the following result :
{
"query": [
{
"id": 2356,
"oc": "Mauvesin",
"fr": "Mauvezin",
"dep": "65",
"lat": "43.116",
"long": "0.283333",
"cityCode": "65306",
"picture": "https://pedagogia.locongres.com/fichas/passejada/images/mauvesin.jpg",
"picturecredit": "CharlesRené",
"anecdoteOc": "La comuna qu'ei coneguda en rason deu son castèth, lo de Gaston Fèbus",
"anecdoteFr": "La commune est connue à cause de son château, celui de Gaston Fébus",
"wikipedia": "https://oc.wikipedia.org/wiki/Mauvesin_(Hauts_Piren%C3%A8us",
"variety": "gascon",
}
]
}
You can display randomly a toponym in specifying the value "random" for the parameter "name". In that case, you don't have to specify a language and a type or a department. So the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&name=random allows you to display randomly a toponym. You get the something like this :
{
"query": [
{
"id": 3566,
"oc": "Sibrac dau Med\u00f2c",
"fr": "Civrac-en-M\u00e9doc",
"dep": "33",
"lat": "45.3333",
"long": "-0.9",
"cityCode": "33128"
}
]
}
If you want to display randomly a toponym from a precise department or particular type, add the parameter "dep" or the parameter "type". For instance, to display randomly a Lot city, use the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&name=random&dep=46. You get the something like this :
{
"query": [
{
"id": 1993,
"oc": "Sant Miard",
"fr": "Saint-Medard-Nicourby",
"dep": "46",
"lat": "44.7667",
"long": "2.05",
"cityCode": "46282"
}
]
}
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 display the toponym "Bratislava" in XML format, you can use the URL http://api.locongres.org/topoc.php?key=[your_APIkey]&name=Bratislava&lang=fr&type=city&format=xml. You get the following result :
<query>
<top id="4585">
<oc>Bratislava</oc>
<fr>Bratislava</fr>
<type>city</type>
</top>
</query>
If there are errors in the input URL or if the query returns no toponyme, 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 toponyms with an unique ID. For each one, you get :
The fields with an * don't appear for each toponym.
Latitude, longitude and city code only appear for french territory cities.
Picture, author, fun fact and its translation, Wikipédia page and variety only appear for cities with an illustration.
{
"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"
},
"oc": {
"type": "string"
},
"fr": {
"type": "string"
},
"type": {
"type": "string"
},
"dep": {
"type": "string"
},
"lat": {
"type": "string"
},
"long": {
"type": "string"
},
"cityCode": {
"type": "string"
},
"picture": {
"type": "string"
},
"pictureCredit": {
"type": "string"
},
"anecdoteOc": {
"type": "string"
},
"anecdotefr": {
"type": "string"
},
"wikipedia": {
"type": "string"
},
"variety": {
"type": "string"
},
},
"required": ["id", "oc", "fr"]
},
"minItems": 1
}
}
}
<! ELEMENT query (top) >
<! ELEMENT error (#PCDATA) >
<! ATTLIST error code ID #REQUIRED >
<! ELEMENT top (anecdoteOc?, anecdoteFr?, cityCode?, dep?, fr, lat, long, oc, picture?, pictureCredit?, type?, url?) >
<! ATTLIST top id ID #REQUIRED >
<! ELEMENT anecdoteOc (#PCDATA) >
<! ELEMENT anecdoteFr (#PCDATA) >
<! ELEMENT cityCode (#PCDATA) >
<! ELEMENT dep (#PCDATA) >
<! ELEMENT fr (#PCDATA) >
<! ELEMENT lat (#PCDATA) >
<! ELEMENT long (#PCDATA) >
<! ELEMENT oc (#PCDATA) >
<! ELEMENT picture (#PCDATA) >
<! ELEMENT pictureCredit (#PCDATA) >
<! ELEMENT type (#PCDATA) >
<! ELEMENT variety (#PCDATA) >
<! ELEMENT wikipedia (#PCDATA) >
© Lo Congrès Permanent de la Lenga Occitana, 2017, all rights reserved - Contact Lo Congrès