Open Government, Mexico API

Free to Use Varies (check documentation)

Overview

The Open Government Mexico (INEGI) API provides free access to official Mexican statistical data published by the National Institute of Statistics and Geography, including population, economy, geography, and census information. No API key is required for most public endpoints, making it straightforward to start querying demographic and geographic data about Mexico. It is particularly useful for researchers and developers working on Latin American data projects.

💡

Beginner Tip

INEGI offers a dedicated indicator API — use a numeric indicator ID (like 1002000001 for total population) with the base URL https://www.inegi.org.mx/app/api/indicadores/desarrolladores/jsonxml/INDICADOR/ to fetch time-series data directly in JSON format.

Available Data

Open Government, Mexico data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Open Government, Mexico",
    "description": "Mexican Statistical Government Open Data",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

Series List of data series returned for the requested indicator
Series[].INDICADOR Numeric code identifying the statistical indicator
Series[].DATOS Time-series data points for the indicator
Series[].DATOS[].PERIODO Time period for the data point (e.g., year or quarter)
Series[].DATOS[].VALOR The numeric value of the indicator for that period, returned as a string

Implementation Example

const url = "https://www.inegi.org.mx/datos/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Response is XML instead of JSON The URL path specifies XML output format by default on some endpoints
Append json to the URL path or add Accept: application/json to your request headers depending on the endpoint
404 Not Found for an indicator ID The indicator code does not exist or has been deprecated in the current catalog
Browse the indicator catalog at https://www.inegi.org.mx/servicios/api_indicadores.html to find valid current indicator IDs
Data series stops at an old year INEGI updates data on varying schedules depending on the survey cycle
Check the lastUpdate field in the response to confirm when the series was last refreshed before building time-sensitive analyses

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 15/20
✓ Reliability 7/15
Response Time 214ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Government
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →