Indicator Bank API

Version 2.0

The INEGI Indicators API allows consulting the data and metadata of the available nationwide indicators, by state and municipality. You can use the API to create applications that display information directly from INEGI databases at the exact moment it is updated.

Developer's guide
Introduction

Welcome to the documentation for developers of the INEGI Indicators API. INEGI joins the open access data initiative with the aim of expanding the availability of information for users.

Audience

This documentation is intended for developers familiar with JavaScript programming and knowledge of object-oriented programming.

Indicators method
To consult the Indicators method, the parameters are sent directly in the URL, for example:
Syntax:
URL:
IdIndicator

The first step to obtain information from the API is to select the indicator and identify its key. This can be done by consulting the "Query Builder".

Language

The information is available in Spanish [es] and English [en].

Geographic area

It can be national [00], by federal entity [99] or by municipality [999], depending on each indicator.

Most recent data or historical series

Only the most recent data [true] or the complete historical series [false] can be consulted.

Data source

It corresponds to the source of dissemination [BISE] or [BIE] from which the consulted data will be obtained.

Version

The edition [2.0] of the data provision service will be identified with it.

Token

To use the API it is necessary to send a valid token, which you can obtain when registering here.

Format

The information is offered in 3 types of formats: JSON [json], JSONP [jsonp] or XML [xml].


  
Id

It is the identifier of the selected method["INDICATOR"].

AgencyID

It is the identification of the agency that provides the data ["INEGI"].

Version

It is the Version of the method used to obtain the data [2.0].

Language

It is the key of the language in which the data is provided ["es"].

CODE

It is the arrangement of the data obtained, each element consists of the following attributes.
Value: It is an identifier of the data.
Description: It is the description of the data.

Metadata Catalog method
To consult the Metadata Catalog method, the parameters are sent directly in the URL, for example:
Syntax:
URL:
Catalogue

Identifies [CL_UNIT] to the list of data that complement the indicator. This can be done by consulting the "Query Builder".

IdCatalogo

Identification key to get a record [1] or all [null] records in the catalog.

Language

The information is available in Spanish [es] and English [en].

Data source

It corresponds to the source of dissemination [BISE] or [BIE] from which the consulted data will be obtained.

Version

The edition [2.0] of the data provision service will be identified with it.

Token

To use the API it is necessary to send a valid token, which you can obtain when registering here.

Format

The information is offered in 3 types of formats: JSON [json], JSONP [jsonp] or XML [xml].


  
Id

It is the identifier of the selected method["INDICATOR"].

AgencyID

It is the identification of the agency that provides the data ["INEGI"].

Version

It is the Version of the method used to obtain the data [2.0].

Language

It is the key of the language in which the data is provided ["es"].

CODE

It is the arrangement of the data obtained, each element consists of the following attributes.
Value: It is an identifier of the data.
Description: It is the description of the data.

For users of the Web Service previously available at http://www2.inegi.org.mx/servicioindicadores/Indicadores.asmx

If you are Web Service's user, now you can obtain the information by using the following methods of the Indicators Bank API:

Indicators method - for consulting indicators.
Metadata Catalog method. - for consulting catalogs.

Developer's guide
Introduction

PC-Axis is a specialized statistical program that is a standard in terms of data dissemination.

Objective

PC-Axis is a free program developed by Statistics Sweden for querying multidimensional statistical tables. This program is used by a significant number of statistical offices and its features include the following: Table customization, which allows the user to decide which variables and values are involved and in what order. Typical calculations in a statistical table without writing formulas. Preparation of statistical graphs. Export and copy data to other applications. PC-Axis is used to query on your desktop the data tables that INEGI broadcasts in PX format through its e-Base repository. The PC-Axis program is not required to query publications on the Internet, however, PC-Axis is required to work with e-Base tables that are downloaded in this format.


Existing Pc-Axis tools have been developed by organizations actively involved in the standard and are generally distributed under open source license. To get started with the standard in a basic way, we recommend that you use the following:

PC-Axis 2008

PC-Axis 2008 is a program for Windows 95/98/NT/2000/XP and for Windows Vista. The installation procedure will leave PC-Axis files (extension *.px) associated with this program, so that your Internet browser will recognize them as such and directly launch the PC-Axis program. If this does not happen, review your browser settings for associated applications. In order to use the program, you must have administrator permission on the computer. Download PC-Axis 2008

Px-map

Free software developed by the Norwegian Statistics Institute that allows you to present statistics using thematic maps. px-map is developed to work fully integrated with pc-axis. compatible with windows 95/98/me/nt/2000/xp, it is necessary to install pc-axis 2005 previously. Note: The installation process is in English. simply accept the default options. Once the process is done, it is necessary to install the map templates of the Basque country (available on this same page) if the pc-axis files with which you will work allow the use of maps. Download Px-map

Px-map help

Once px-map is installed it is possible to install the help and menus in Basque or Spanish for you to work in the language you want. Note: The installation process is in Spanish. simply accept the default options.. Download Px-map

Pc-Axis Method
To query the PcAxis method, the parameters are sent directly in the URL, for example:
Syntax:
URL:
IdIndicator

The first step to obtain information from the API is to select the indicator and identify its key. This can be done by consulting the "Query Builder".

Language

The information is available in Spanish [es] and English [en].

Geographic area

It can be national [00], by federal entity [99] or by municipality [999], depending on each indicator.

Most recent data or historical series

Only the most recent data [true] or the complete historical series [false] can be consulted.

Data source

It corresponds to the source of dissemination [BISE] or [BIE] from which the consulted data will be obtained.

Token

To use the API it is necessary to send a valid token, which you can obtain when registering here.

Format

It is required to use the Pc-Axis typer [pcAxis].


  
CHARSET

Type: text
Length: 20 characters
Multiline: No
CHARSET=”ANSI”; indicates that the texts in the file are written in Windows format. If the keyword is missing it means that the texts in the file are in DOS format. They will be translated by PC-Axis to Windows. This keyword must appear in the beginning of the file before any texts that can include characters outside A-Z, 0-9.

AXIS-VERSION

Type: text
Length: 20 characters
Multiline: No
Version number for PC-Axis (new text length 2008). Is read and saved but otherwise not used.

CODEPAGE

Type: text
Length: 20 characters
Multiline: No
Is used when creating XML format to get correct characters. Default iso-8859-1. Max 20 chars.

LANGUAGE

Type: text
Length: 2 characters per language
Multiline: No
The language used in the PC-Axis file (2 chars), sv for Swedish, en for English etc. Compare language codes for text files. If the keyword is used, the words for “and” and “by” are read from the text file of that language. Otherwise these words are read from the text file of the language in which the program is running.

CREATION-DATE

Type: text
Length: 256 characters
Multiline: Yes
Date when file was created. Written in format CCYYMMDD hh:mm, e.g. ”19960612 14:20”. Is shown together with footnotes.

DECIMALS

Type: integer [0, 15]
Length: Lines of 256 characters
Multiline: No
The number of decimals in the table cells. 0 - 15. (0-6 if SHOWDECIMALS is not included). Indicates how many decimals will be saved in the PC-Axis file. Written without quotation marks. Compare SHOWDECIMALS.

SHOWDECIMALS

Type: integer
Length: N/A
Multiline: No
The number of decimals to be shown in the table, 0-6. Must be the same or smaller than the number stored as indicated by the keyword DECIMALS. If SHOWDECIMALS is not stated in the file the number stated by DECIMALS will be used.

MATRIX

Type: text
Length: 20
Multiline: No
The name of the matrix. Is suggested as file name when the file is fetched. (new length 2008).

COPYRIGHT

Type: text
Length: 20 characters
Multiline: No
Copyright is given as YES or NO. If COPYRIGHT=YES the copyright refers to the organization given in SOURCE. Is shown together with footnotes.

SUBJECT-CODE

Type: text
Length: 20 characters
Multiline: No
Subject area code. It is used to create files with tables available in PC-Axis. The text must not exceed 20 characters (new length 2008).

SUBJECT-AREA

Type: text
Length: 256 characters
Multiline: No
The name of the subject area in plain text, as shown in the menu "Select subject area". The text must not exceed 256 characters (new length in 2008).

TITLE

Type: text
Length: Lines of 256 characters
Multiline: Yes
The title of the table, reflecting its contents and variables. Is not needed if the file contains DESCRIPTION, in that case the text belonging to description is used. How the heading of a table will look depends on which variables the user chooses; the heading thus created will then be saved as TITLE. (Compare also DESCRIPTIONDEFAULT) If the file contains DESCRIPTION the text for this key word will be used.

CONTENTS

Type: text
Length: 256 characters
Multiline: No
Information about the contents, which makes up the first part of a title created when retrieving tables from PC-Axis. The text must not exceed 256 characters (before 2002 only 100 chars).

STUB

Type: text
Length: 256 characters per valuer
Multiline: Yes
At least one of the keywords STUB or HEADING must be included. Usually both are included, as you choose one or several variables for the stub and the heading, respectively. The keywords are followed by a list with the chosen variables. The variables are within quotation marks and separated by commas. If the list with the variables has to be divided up into several lines, this should be done after a comma and not within the variable name.

HEADING

Type: text
Length: 256 character per value
Multiline: Yes
At least one of the keywords STUB or HEADING must be included. Usually both are included, as you choose one or several variables for the stub and the heading, respectively. The keywords are followed by a list with the chosen variables. The variables are within quotation marks and separated by commas. If the list with the variables has to be divided up into several lines, this should be done after a comma and not within the variable name.

VALUES

Type: text
Length: 256 characters per value
Multiline: Yes
The keyword VALUES occurs once for each variable in the table, and is followed by the variable name in parentheses, within quotation marks. The values will be in the same order as in the stub and heading, respectively. They are within quotation marks and separated by commas. Each value name must not exceed 256 characters. If the values have to be divided up into several lines, this should be done after a comma and not within the value name. See also the keyword TIMEVAL below.

UNITS

Type: text
Length: 256 characters
Multiline: No
Unit text, e.g. ton, index. The text must not exceed 256 characters (new length 2008). Compare UNITS for CONTVARIABLE. When there is a CONTVARIABLE the keyword UNITS takes an index and is repeated for every value for the contents variable. UNITS("value")="tons".

VALUENOTE

Type: text
Length: 256 characters
Multiline: Yes
A footnote for separate variable values. Should be written with the variable name and the value names in parentheses.

SOURSE

Type: text
Length: 256 characters
Multiline: Yes
States the organization which is responsible for the statistics. Is shown with the footnote.

DATASYMBOL1, DATASYMBOL2, DATASYMBOL3, DATASYMBOL4, DATASYMBOL5, DATASYMBOL6

Type: text
Length: 20 characters
Multiline: No
This if used to indicate how a stored “.” is to be presented in a table.

DATA

Type: integer/text
Length: N/A
Multiline: Yes
The keyword DATA must be placed at the end of the file, followed by all the data cells or if KEYS are used the variable values and all data cells that differ from 0.

See more...
Developer's guide
Introduction

The main statistical standards for data and metadata exchange are XML-based: they are generally complicated and detailed, so JSON-Stat comes to change this paradigm.

Objective

JSON-stat is a lightweight and simple JSON broadcast format, more suitable for viewing data, mobile applications or open data initiatives, which has been designed for all types of broadcasters.
JSON-stat also proposes an HTML microdata scheme to enrich HTML tables and put the JSON-stat vocabulary in the browser.


JSON-stat comes with libraries and sample code for various programming languages: JavaScript, R, Java, Julia, PHP or even the command line. See more...

As part of the tools you can use the visualizer to deploy the datso and metadata online. See more...

In addition there is an online application that allows you to verify the correct construction of the Json-Stat file. See more...

Json-stat method
To query the Json-stat method, the parameters are sent directly to the URL, for example:
Syntax:
URL:
IdIndicator

The first step to obtain information from the API is to select the indicator and identify its key. This can be done by consulting the "Query Builder".

Language

The information is available in Spanish [es] and English [en].

Geographic area

It can be national [00], by federal entity [99] or by municipality [999], depending on each indicator.

Most recent data or historical series

Only the most recent data [true] or the complete historical series [false] can be consulted.

Data source

It corresponds to the source of dissemination [BISE] or [BIE] from which the consulted data will be obtained.

Token

To use the API it is necessary to send a valid token, which you can obtain when registering here.

Format

Using the json-stat [jsonStat] typeifier is required..


  
Version

Declares the JSON-stat version of the response. The goal of this property is to help clients analyze that particular response. Because future releases might add optional properties, the same response can be valid in multiple versions: any of those versions are accepted as a version value.
Before version 2.0 The version was introduced in version 2.0. That's why this property cannot accept values less than 2.0.

Class

JSON-stat supports several kinds of responses. The possible values of the class are: dataset, dimension, and collection. Dataset responses include a single dataset. They are declared using the value of the dataset class.

Href

Specifies a URL.
Vendors can use this property to prevent the sending of information that is shared between different requests (for example, dimensions)..

Label

Used to assign very short descriptive text (a line) to IDs at different levels of the response tree. It's language-dependent.
When it is a root property or a child of dimension ID or a unit category ID, it is a string.

Value

Contains data sorted by dataset dimensions. It usually takes the form of an array where missing values are expressed as null.

Status

Contains observation-level metadata. When you take an array shape of the same value size, it assigns a state to each data per position.

Id

It is used to describe a particular dimension. The name of this object must be one of the strings in the id array. There must be a single dimension ID object for each dimension in the id array.

Size

Contains the number (integer) of categories (possible values) of each dimension in the dataset. It has the same number of elements and in the same order as in id.

Dimension

JSON-stat follows a cube model: values are organized into cells, and a cell is the intersection of multiple dimensions. The dimension property contains information about the dimensions of the dataset.

Category

Used to describe the possible values of a dimension.

Unit

Used to describe the possible values of a dimension.

See more...

Questions



Obtain data from the historical series of the Total Population indicator, in the United Mexican States, in Spanish language, in JSON format.

Input parameters:
  • Indicator: 1002000001
  • Geographic area: 01
  • Language: es
  • Latest data: False (for this case the complete historical series is requested)
  • Format: json
  • Token: [Here's your Token]

Inquiry:


Result:

  

Presentation of information using HTML and Javascript
Presentation of information using HTML and Javascript

Download the full example Here .

Obtain data from the historical series of the Total Population indicator, in the United Mexican States, in Spanish language, in JSON format.

library(httr)
library(jsonlite)
library(rjson)

#API call
url <-"https://www.inegi.org.mx/app/api/indicadores/desarrolladores/jsonxml/INDICATOR/1002000001/en/00000/false/BISE/2.0/[Here's your Token]?type=json"
respuesta<-GET(url)
datosGenerales<-content(respuesta,"text")
flujoDatos<-paste(datosGenerales,collapse = " ")

#Getting the list of observations 
flujoDatos<-fromJSON(flujoDatos)
flujoDatos<-flujoDatos $Series
flujoDatos<-flujoDatos[[1]] $OBSERVATIONS

#Generating the average of the list of observations 
datos<-0;
for (i in 1:length(flujoDatos)){

 datos[i]<-flujoDatos[[i]] $OBS_VALUE
}

datos<-as.numeric(datos)
print(mean(datos))
                                                    


Obtain data from the historical series of the Total Population indicator, in the United Mexican States, in Spanish language, in PC-Axis format.

Input parameters:
  • Indicator: 1002000001
  • Geographic area: 01
  • Language: es
  • Latest fact: False (for this case the complete historical series is requested)
  • Format: pcAxis
  • Token: [Here's your Token]

URL Query


Result:

  

Presentation of information using HTML and Javascript
Presentation of information using HTML and Javascript

Code
<!DOCTYPE html >    
<html>
<head>
    <link href="c3/c3.css" rel="stylesheet" type="text/css">
</head>
<body>
    <div id="chart"></div>
    <div id="chartPcAxis"></div>

    <script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
    <script src="c3/c3.js"></script>
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

    <script src="JSPc-Axis/px.js"></script>
    <script src="JSPc-Axis/underscore.js"></script>;       
        
    </body >
</html >
window.onload = function() {
            getPcAxis();
        }

        function buildPcAxis() {
            return new Promise(function(resolve, reject) {
                var urlApiPcAxis = "http://www.inegi.org.mx/app/api/indicadores/desarrolladores/jsonxml/PCAXIS/1002000001/en/00/false/BISE/[Here's your Token]?type=pcAxis";
                $.ajax({
                    type: "GET",
                    url: urlApiPcAxis,
                    //async: false,
                    headers: {
                        Accept: "text/px"
                    },
                    success: function(data, status, jqXHR) {
                        resolve(data);
                    },
                    error: function(jqXHR, status) {
                        reject(jqXHR);
                    }
                });
            })
        }

        function buildChart(px) {

            const _column = [px.metadata["VALUES "].Indicadores];
            for (var i = 0; i < px.data.length; i++) {
                _column.push(parseFloat(px.data[i]))
            }

            const _X = ["x"];
            for (var i = 0; i < px.metadata["VALUES "].Tiempo.length; i++) {
                _X.push(px.metadata["VALUES "].Tiempo[i]);
            }
            
            
            var chartPcAxis = c3.generate({
                bindto: '#chartPcAxis',
                data: {
                    x: 'x',
                    colors: {
                         '(1002000001) Población total': '#FF9124'
                        
                    },
                    columns: [
                        _X,
                        _column                        
                    ],
                    type: 'bar',
                    onclick: function(d, element) {
                        //console.log("onclick", d, element);
                    },
                    onmouseover: function(d) {
                        //console.log("onmouseover", d);
                    },
                    onmouseout: function(d) {
                        //console.log("onmouseout", d);
                    }
                },
                axis: {
                    x: {
                        type: 'categorized',
                        label: 'X Label'
                    },
                    y: {
                        label: {
                            text: px.metadata.UNITS.TABLE,
                            position: 'outer-middle'
                        }
                    }
                },
                bar: {
                    width: {
                        ratio: 0.3,
                        //max: 30
                    },
                }
            });
        }

        function getPcAxis() {
            buildPcAxis().then(r => {
                buildChart(new Px(r));
            }).catch(() => {
                console.log('Algo salió mal');
            });
        }
 
Download the full example Here .


Obtain data from the historical series of the Total Population indicator, in the United Mexican States, in Spanish language, in Json-Stat format.

Input parameters:
  • Indicator: 1002000001
  • Geographic area: 01
  • Language: es
  • Latest data: False (for this case the complete historical series is requested)
  • Format: jsonStat
  • Token: [Here's your Token]

Inquiry:


Result:

  

Presentation of information using HTML and Javascript
Presentation of information using HTML and Javascript
Cargando información...


Code
<html lang="es">

<head>
    <title>Ejemplo de json-stat </title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
    <script src="https://unpkg.com/[email protected]"> </script>
    <script src="https://unpkg.com/[email protected]"> </script>
    <script src="/JsonStat/ejemplo-json-stat.js"> </script>

    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"> </script>
</head>

<body onload="inicioJsonStat()">
    <div id="TablaJsonStat"> </div>
    <br>
    <div id="top_x_div" style="width: 1900px; height: 700px;"> </div>

</body>

</html>
const url =
"https://www.inegi.org.mx/app/api/indicadores/desarrolladores/jsonxml/JSONSTAT/1002000001/en/0700/false/BISE/[Aquí va tu Token]?type=jsonStat";


//Se obtiene el JsonStat en forma de objeto por medio de la librería jsonstat-toolkit
async function getJsonStatDS(url_) {
return new Promise(function (resolve, reject) {
    JSONstat(url_).then((result) => {
    resolve(result);
    });
});
}

//Creation of the table using the jsonstat-suite library
async function getJsonStatTabla(url_) {
return new Promise(function (resolve, reject) {
    JSONstat(url_).then((result) => {
    var html = JSONstatUtils.datalist(result, {
        counter: true,
        status: true,
        tblclass: "table table-striped",
    });
    document.getElementById("TablaJsonStat").innerHTML = html;
    resolve(result);
    });
});
}

var jsonStat;
async function inicioJsonStat() {
var jsonStat = await getJsonStatDS(url);
await getJsonStatTabla(url);

//Creación de la matriz de datos para alimentar al graficador
var jsonStatChart = jsonStat.Dataset(0).toTable({}, function (d, i) {
    return [d[0] + " " + d[4], d[5]];
});

google.charts.load("current", { packages: ["bar"] });
google.charts.setOnLoadCallback(drawStuff);

function drawStuff() {
    var data = new google.visualization.arrayToDataTable(jsonStatChart);

    var options = {
    legend: { position: "none" },
    chart: {
        title: jsonStat.Dataset(0).label,
    },
    bar: { groupWidth: "90%" },
    colors: ["#d95f02"],
    };

    var chart = new google.charts.Bar(document.getElementById("top_x_div"));
    chart.draw(data, google.charts.Bar.convertOptions(options));
}
} 
 
Download the full example Here .