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.

See the full endpoint reference

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());

See all the examples

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

See the GAM list