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
| City | Region | Population |
|---|---|---|
| Madrid | Community of Madrid | 3,416,771 |
| Barcelona | Catalonia | 1,702,547 |
| Valencia | — | 825,948 |
| Zaragoza City | Aragon | 666,880 |
| Palma | Balearic Islands | 431,521 |
| Pamplona metropolitan area | — | 370,804 |
| Alicante | Valencian Community | 358,720 |
| L'Hospitalet de Llobregat | Catalonia | 279,993 |
| Gijón City | Asturias | 255,070 |
| Badalona | Catalonia | 227,083 |
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
}
]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'City names in Spain are available in 39 languages.
Prefer a static file? Download 5,000 Spain cities as JSON (761 KB, no API key) from the Spain cities dataset page.
Geomelon currently has 51,513 cities in Spain across 25 regions. Results are paginated, up to 100 per request.
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.
Yes — city names in Spain are available in 39 languages. Pass the languages you want via the preferredLanguages parameter, most-preferred first.
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.