List Costa Rica provincia/cantón/distrito location codes
const url = 'https://api.emite.cr/v1/catalogs/locations';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.emite.cr/v1/catalogs/locationsHacienda's official provincia → cantón → distrito hierarchy (location codification v4.4), the catalog behind cascading address pickers. Codes come in the exact shape a location expects (a company's or a contact's address): provincia 1 digit, cantón and distrito 2 digits. Barrios are not included: barrio is free text in v4.4. Public (no credentials) and cacheable for a day; it changes only when Hacienda republishes the codification.
Responses
Section titled “Responses”object
Costa Rica's seven provincias, each with its cantones and their distritos, as Hacienda's location codification (v4.4) defines them. The codes only make sense together: a cantón code is unique within its provincia, and a distrito code within its cantón. Barrios are not listed: barrio is free text in v4.4.
object
Provincia code, 1 digit (1 San José to 7 Limón): the value for location.provincia (<Ubicacion><Provincia> in the XML).
Official name of the provincia.
The cantones of this provincia.
object
Cantón code, 2 digits, unique within its provincia: the value for location.canton (<Ubicacion><Canton> in the XML).
Official name of the cantón.
The distritos of this cantón.
object
Distrito code, 2 digits, unique within its cantón: the value for location.distrito (<Ubicacion><Distrito> in the XML).
Official name of the distrito.
Example
{ "provincias": [ { "code": "1", "name": "San José", "cantones": [ { "code": "01", "name": "San José", "distritos": [ { "code": "01", "name": "Carmen" } ] } ] } ]}