Skip to content

A library that provides data on Spain's autonomies, provinces, and cities, including their codes, names, flags, and coats of arms for seamless integration into your applications.

License

Notifications You must be signed in to change notification settings

ByMykel/spanish-cities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

all-spanish-cities

Downloads jsdelivr

A library that provides data on Spain's autonomies, provinces, and cities, including their codes, names, flags, and coats of arms for seamless integration into your applications.

Install

npm install all-spanish-cities

Usage

Autonomies

import { autonomies } from "all-spanish-cities";

console.log(autonomies());
// [
//   {
//     "code": "01",
//     "name": "Andalucía",
//     "flag": "...",
//     "coat_of_arms": "...",
//   },
//   // …and many more
// ]

// You can filter by any of the following attributes.
console.log(autonomies({
  code: '...', 
  name: '...', 
}));
// [
//   { ... },
//   { ... },
//   // autonomies that match your filters
// ]

// You can also include the provinces and cities of that autonomy.
console.log(autonomies({
  with_provinces = true, 
  with_cities = true
}));
// [
//   {
//     "code": "01",
//     "name": "Andalucía",
//     "flag": "...",
//     "coat_of_arms": "...",
//     "provinces": [{ ... }, { ... }]
//     "cities": [{ ... }, { ... }]
//   },
//   // …and many more
// ]

Provinces

import { provinces } from "all-spanish-cities";

console.log(provinces());
// [
//   {
//     "code": "04",
//     "name": "Almería",
//     "code_autonomy": "01"
//   },
//   // …and many more
// ]

// You can filter by any of the following attributes.
console.log(provinces({
  code: '...', 
  code_autonomy: '...',
  name: '...', 
}));
// [
//   { ... },
//   { ... },
//   // provinces that match your filters
// ]

// You can also include the autonomy and cities of that province.
console.log(provinces({
  with_autonomy = true, 
  with_cities = true
}));
// [
//   {
//     "code": "04",
//     "name": "Almería",
//     "code_autonomy": "01",
//     "flag": "...",
//     "coat_of_arms": "...",
//     "autonomy": { ... }
//     "cities": [{ ... }, { ... }]
//   },
//   // …and many more
// ]

Cities

import { cities } from "all-spanish-cities";

console.log(cities());
// [
//   {
//     "code": "010014",
//     "name": "Alegría-Dulantzi",
//     "code_autonomy": "16",
//     "code_province": "01",
//     "flag": null,
//     "coat_of_arms": null
//   },
//   // …and many more
// ]

// You can filter by any of the following attributes.
console.log(cities({
  code: '...', 
  code_autonomy: '...',
  code_province: '...',
  name: '...', 
}));
// [
//   { ... },
//   { ... },
//   // cities that match your filters
// ]

// You can also include the autonomy and cities of that province.
console.log(cities({
  with_autonomy = true, 
  with_province = true
}));
// [
//   {
//     "code": "010014",
//     "name": "Alegría-Dulantzi",
//     "code_autonomy": "16",
//     "code_province": "01",
//     "flag": null,
//     "coat_of_arms": null
//     "autonomy": { ... }
//     "province": { ... }
//   },
//   // …and many more
// ]

Source

  • The names and code are extracted from the INE website.
  • The flags and coat of arms are extracted from Wikipedia articles.

License

MIT

About

A library that provides data on Spain's autonomies, provinces, and cities, including their codes, names, flags, and coats of arms for seamless integration into your applications.

Topics

Resources

License

Stars

Watchers

Forks