This package offers Spain's municipalities names and codes as shown in INE (Spain's National Statistics Institute).
According to Wikipedia:
A municipality is usually a single administrative division having corporate status and powers of self-government or jurisdiction as granted by national and regional laws to which it is subordinate.
Also Wikipedia has an specific page for municipalities of Spain.
XLSX Files provided by INE are updated the first day of every year and can be found at https://www.ine.es/dyngs/INEbase/es/operacion.htm?c=Estadistica_C&cid=1254736177031&menu=ultiDatos&idp=1254734710990.
Every change after the first day of the year is logged in the same page and this package will update its data accordingly. Information about new changes will be shown in this README file.
This package contains the data extracted from the information contained in an XLSX file provided by INE.
This package offers two files:
- An index.js file that contains an array with municipalities,
- A JSON file that you can read and parse to be offered using a REST API or to insert records into a database.
yarn add @doncicuto/es-municipalities
npm install @doncicuto/es-municipalities --save
The default export is an array of objects with the following structure:
||INE's Autonomous community code||
||INE's province code||
||INE's municipality code||
WARNING Be warned that this array contains 8131 municipalities so it may be heavy for your usage case. You may prefer to use the JSON file called 'municipalitiesWithProvinces.json' contained in the lib folder.
import municipalities from "@doncicuto/es-municipalities"; const names = municipalities.map((p) => p.name); console.log(names); const filtered = municipalities.filter((p) => p.commCode === "07"); console.log(filtered);
const municipalities = require("@doncicuto/es-municipalities").default; const names = municipalities.map((p) => p.name); console.log(names); const filtered = municipalities.filter((p) => p.commCode === "07"); console.log(filtered);