Part of a Data Solution
- Explore →
Postal Codes Solution
Every worldwide postal-code dataset in one bundle — the ultimate global reference for precise postal codes.
Premium
You're viewing a free sample
Get the complete dataset — all rows and files — delivered instantly after checkout, with lifetime access to the latest version.
- Secure checkout via Stripe
- Instant download after payment
- Lifetime access to the latest version
- Creative Commons Attribution 4.0 license
API Access
Access dataset files directly from scripts, code, or AI agents.
Browse dataset files
API Access
Access dataset files directly from scripts, code, or AI agents.
Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.
Start with these files — they give you everything you need to understand and access the dataset.
- 1. Fetch datapackage.yml to inspect schema and resources
- 2. Download data resources listed in datapackage.yml
- 3. Read README.md for full context
Data Files
Postal Codes Data Resource for Spain, ES
| Field | Description | Title |
|---|---|---|
| country_code | ISO 3166-1 alpha-2 code for the country. | Country Code |
| postal_code | Postal code for the location. | Postal Code |
| place_name | Name of the city, town, or place. | Place Name |
| admin_name1 | Primary administrative division (e.g., state, region). | Administrative Name 1 |
| admin_code1 | Code for the primary administrative division. | Administrative Code 1 |
| admin_name2 | Secondary administrative division (e.g., county, district). | Administrative Name 2 |
| admin_code2 | Code for the secondary administrative division. | Administrative Code 2 |
| admin_name3 | Tertiary administrative division (e.g., municipality, borough). | Administrative Name 3 |
| admin_code3 | Code for the tertiary administrative division. | Administrative Code 3 |
| latitude | Latitude coordinate of the place. | Latitude |
| longitude | Longitude coordinate of the place. | Longitude |
| accuracy | Accuracy level of the latitude and longitude coordinates. | Accuracy |
| alternative_city_name | Alternative name(s) for the city or place. | Alternative City Name |
Download
Download sample CSVAbout
- Last updated
- 7 November 2024
- Total rows
- ...
- Format
- CSV
- File size
- 8.8 kB
- Sources
- CartoCiudad, Instituto Geografico Nacional / CNIG (Obra derivada de CartoCiudad 2026 CC-BY 4.0 scne.es) - postal code to municipality relations and per-postal-code coordinates
- Relacion de municipios y sus codigos por provincias, Instituto Nacional de Estadistica (INE), updated 2026-01-01 - Elaboracion propia con datos extraidos del sitio web del INE; the INE neither participates in nor endorses this dataset
- GeoNames (CC BY 4.0) - independent cross-check and locality names; see README.md for the multi-municipality, cross-province-routing and accuracy-tier notes
About this dataset
Spain (ES) — internal licensing notes
Not mentioned in datahub-next#941 — no known licensing flag on this country. Sources: IGN/CNIG CartoCiudad INSPIRE WFS (CC BY 4.0 — postal codes, coordinates), INE municipality register (official Spanish government admin reference), GeoNames ES (CC BY 4.0, cross-check only). Deliberately NOT Correos (their paywall covers the CP polygon cartography) and NOT Wikipedia (CC BY-SA share-alike would encumber a resold derivative).
Session finding, 2026-08-19
Fixed es/scripts/ from hardcoded other-repo paths to self-contained.
Committed two static reference files that aren't re-derivable by any fetch
step: muni_corrections.csv (7 manually-verified municipality corrections,
each with an evidence string from a CartoCiudad geocoder query) and the
buyer-facing README template. resolve_po_box_codes.py bootstraps from the
currently-published es.csv on R2 (a within-repo dependency, not external)
purely as a discovery list of which PO-box-style codes exist — none of that
file's own data is trusted, every code is independently re-resolved (its
admin_name3 is literally the string "nan" and its coordinates are
demonstrably wrong for these rows).
Verified end-to-end from a fresh fetch: 8,132 municipalities / 52 provinces /
19 communities (exact match to documented counts), 288/288 PO-box codes
resolved, 14,538/14,538 final rows, 100% admin coverage, 100% coordinate
fill. Sorted diff against live R2: 296 lines, entirely the known
alternative_city_name gap on 148 PO-box rows (independent geocoder
resolution difference, not a bug).
Real ordering gotcha documented for future runs: build_dataset.py must
run twice — once before resolve_po_box_codes.py (to produce the
baseline it diffs against) and once after (to fold in the resolved codes +
coordinates). Getting this wrong silently produces an empty PO-box table —
happened once during this same session's work.
No further licensing review — this was a code-reproducibility audit.
CLOSED — 2026-08-24 (datahub-next#941 §4)
Live datapackage.json carried a sources array — forbidden by this
project's standing directive (source attribution belongs in
ATTRIBUTION.txt and the README, never in datapackage.json). Stripped
from the live object and from package_delivery.py (which had been writing
it on every rebuild). Added standalone es/ATTRIBUTION.txt (now in R2 and
inside es.zip) carrying the CartoCiudad/INE/GeoNames attribution content
that was previously only in the sources array — nothing lost, correctly
relocated. package_delivery.py now writes and zips ATTRIBUTION.txt on
every run. _meta/catalog.json's ES entry rebuilt to include it.