🇪🇸 Cities in Spain — API & JSON data

Spain has 51,513 cities in the Geomelon dataset, one of the more densely covered countries in the API. The most populous is Madrid in Community of Madrid, at 3,416,771 people. Query it by name, region, or coordinates, with translations in 39 languages.

Data updated: 2026-07-14

Live demo

Type to search Spain cities…

Top 10 cities by population

CityRegionPopulation
MadridCommunity of Madrid3,416,771
BarcelonaCatalonia1,702,547
Valencia825,948
Zaragoza CityAragon666,880
PalmaBalearic Islands431,521
Pamplona metropolitan area370,804
AlicanteValencian Community358,720
L'Hospitalet de LlobregatCatalonia279,993
Gijón CityAsturias255,070
BadalonaCatalonia227,083

Sample API response

GET /cities/search?countryCode=es&sort=population_desc&limit=3

[
  {
    "id": "b60d7d4b-3225-401f-9d78-c6b5fd5b249b",
    "name": "Madrid",
    "population": 3416771,
    "countryName": "Spain",
    "countryCode": "ES",
    "countryEmoji": "🇪🇸",
    "regionName": "Community of Madrid"
  },
  {
    "id": "964512d1-f150-4876-87ec-0ba47aef694a",
    "name": "Barcelona",
    "population": 1702547,
    "countryName": "Spain",
    "countryCode": "ES",
    "countryEmoji": "🇪🇸",
    "regionName": "Catalonia"
  },
  {
    "id": "65889394-0b8b-462c-92c7-5737ee2ed754",
    "name": "Valencia",
    "population": 825948,
    "countryName": "Spain",
    "countryCode": "ES",
    "countryEmoji": "🇪🇸",
    "regionName": null
  }
]

Try it

curl --request GET \
  --url 'https://geomelon.p.rapidapi.com/cities/search?countryCode=es&sort=population_desc&limit=10' \
  --header 'x-rapidapi-host: geomelon.p.rapidapi.com' \
  --header 'x-rapidapi-key: YOUR_API_KEY'

Multilingual city names

City names in Spain are available in 39 languages.

Free dataset

Prefer a static file? Download 5,000 Spain cities as JSON (761 KB, no API key) from the Spain cities dataset page.

FAQ

How many cities in Spain does the API return?

Geomelon currently has 51,513 cities in Spain across 25 regions. Results are paginated, up to 100 per request.

Is there a free tier?

Yes. RapidAPI's free tier covers a fixed number of requests per month with no credit card required. There is also a free, no-key city-autocomplete endpoint (the demo above) for prefix search.

Can I get Spain city names in other languages?

Yes — city names in Spain are available in 39 languages. Pass the languages you want via the preferredLanguages parameter, most-preferred first.

Do I need an API key?

The main search and lookup endpoints require a free RapidAPI key. The prefix-search autocomplete endpoint used in the demo above is public and does not require a key.

Try free on RapidAPI

Related