This API provides access to Mexican geographic data, including estados (states), municipios (municipalities), and colonias (neighborhoods).
This API deliberately excludes population data. Population statistics become outdated very quickly after publication, and maintaining current population data would require constant updates. For the most up-to-date population information, please refer to INEGI's official population statistics.
GET /api/v1/estados
Returns a list of all Mexican states.
GET /api/v1/estados/:clave
Returns details for a specific state by its clave (ID).
GET /api/v1/municipios?clave_estado=XX
Returns a list of all municipalities across Mexico. The clave_estado parameter is required.
GET /api/v1/estados/:estado_clave/municipios
Returns all municipalities within a specific state.
GET /api/v1/municipios/:clave?clave_estado=XX
Returns details for a specific municipality. The clave_estado parameter is required.
GET /api/v1/municipios/search
Search for municipalities. Supports the following query parameters:
q: Search term for municipality name (case-insensitive)clave_estado: Filter by state clave
GET /api/v1/colonias
Returns a list of all neighborhoods across Mexico.
GET /api/v1/estados/:estado_clave/municipios/:municipio_clave/colonias
Returns all neighborhoods within a specific municipality.
GET /api/v1/colonias/:clave?clave_estado=XX
Returns details for a specific neighborhood. Requires clave_estado parameter.
GET /api/v1/colonias/search
Search for neighborhoods. Supports the following query parameters:
q: Search term for neighborhood name (case-insensitive)clave_estado: Filter by state clavemunicipio_id: Filter by municipality ID
All responses are in JSON format. Nested resources are included where relevant:
- Estados include their abbreviation and name
- Municipios include their estado
- Colonias include their municipio and estado
Example response for a colonia:
{
"id": 1,
"clave": "0001",
"nombre": "Centro",
"latitud": "19.4326",
"longitud": "-99.1332",
"altitud_msm": "2250",
"municipio": {
"id": 1,
"clave": "015",
"nombre": "Cuauhtémoc",
"estado": {
"id": 1,
"clave": "09",
"nombre": "Ciudad de México",
"abbreviation": "CDMX"
}
}
}The API includes a rake task for importing INEGI data:
rake "inegi:import[path/to/file.csv]"The CSV should include the following columns:
- NOM_ENT: Estado name
- NOM_ABR: Estado abbreviated name
- CVE_ENT: Estado clave
- NOM_MUN: Municipio name
- CVE_MUN: Municipio clave
- NOM_LOC: Colonia name
- CVE_LOC: Colonia clave
- LAT_DECIMAL: Latitude
- LON_DECIMAL: Longitude
- ALTITUD: Altitude in meters
Note: The CSV should be UTF-8 encoded to ensure proper handling of Spanish characters.
The geographic data provided by this API is sourced from the Instituto Nacional de Estadística y Geografía (INEGI), Mexico's National Institute of Statistics and Geography. Use of this data is subject to INEGI's terms and conditions, which can be found at: https://www.inegi.org.mx/contenidos/inegi/doc/terminos_info.pdf
When using this API, please ensure compliance with INEGI's terms of use and provide appropriate attribution to INEGI as the data source.