A free JSON API for Costa Rica postal codes
Static JSON with Costa Rica’s official data (DTA 2026). No API key, no sign-up, no limits, open CORS. Version 2.1.0.
https://api.postalcr.dev
See the endpointsView on GitHub
- 14
- endpoints
- 494
- districts
- MIT
- license
The API endpoints
All of them answer GET. Unknown codes return 404. Codes are always strings.
/provincias.jsonThe 7 provinces/provincias/{provincia}.jsonA province and its cantons (1–7)/cantones.jsonAll 84 cantons/cantones/{canton}.jsonA canton (103) and its districts/distritos.jsonAll 494 districts with every field/distritos/{codigoPostal}.jsonOne district by ZIP code/pueblos.json6,891 towns and beaches with their district/populares.jsonThe 200 most-searched places/distritos.geojsonSimplified boundaries (GeoJSON)/gam.jsonCodes inside and outside the GAM/todo.jsonFull tree/meta.jsonVersion, totals and sources/openapi.jsonOpenAPI 3.1 spec/llms.txtGuide for AI agents
The district 10305 as JSON
Each district includes a display label, its GAM status, an interior point, its neighbors, its towns and the link to its postalcr.dev page. Field names are in Spanish.
{
"codigo_postal": "10305",
"nombre": "San Antonio",
"canton": { "codigo": "103", "nombre": "Desamparados" },
"provincia": { "codigo": "1", "nombre": "San José" },
"etiqueta": "San Antonio, Desamparados, San José",
"area_km2": 2.1,
"gam": true,
"centro": [lat, lon],
"vecinos": ["10106", "10301", "10310", "10312", "11804", "30308"],
"pueblos": ["San Antonio"],
"url": "https://postalcr.dev/san-jose/desamparados/san-antonio/"
}Province, canton and district with the API
Province → canton → district for an address form:
const API = 'https://api.postalcr.dev';
const provincias = await fetch(`${API}/provincias.json`).then(r => r.json());
const { cantones } = await fetch(`${API}/provincias/1.json`).then(r => r.json());
const { distritos } = await fetch(`${API}/cantones/103.json`).then(r => r.json());The GAM in each district’s JSON
Every district carries gam: true when it lies inside the Greater Metropolitan Area per MIVAH’s 2013-2030 GAM Plan. 167 of the 494 districts are inside and 327 outside. Useful for delivery pricing; each courier may use its own zone list.
/gam.jsonThe codes inside and outside the GAM, in two lists/distritos/{codigoPostal}.jsonOne district’s gam field
The API code, open
MIT license. The data comes from official sources and every version is logged.