Data users

Do you want to use the data from Mapineq in your own application or website? Here you find instructions on how to use the API to get data from the Mapineq database.

Introduction

In general the API works as follows: you call a function with one or more parameters, the result is json formatted data.

https://mapineqfeatures.web.rug.nl/functions/postgisftw.functionname/item.json?parameters&limit=1000

functionname depends on the function you want to use, possible values:

parameters depends on the function you choose.

Always use the parameter limit otherwise you only get 10 values, choose the value higher than the number of expected values

Functions

get_levels

Gives the available nutslevels

parameters:

  • none

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_levels/items.json

returns a list of nutslevels

[
  {
    "f_level": "3"
  },
  {
    "f_level": "2"
  },
  {
    "f_level": "1"
  },
  {
    "f_level": "0"
  }
]

get_source_by_nuts_level

Gives the available sources depending on nutslevel

parameters:

  • _level (number, 0,1,2,3)

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_source_by_nuts_level/items.json?_level=2&limit=500

returns a list of sources:

[
  {
    "f_description": "Area by NUTS 3 region (ESTAT)",
    "f_resource": "DEMO_R_D3AREA",
    "f_short_description": "Area by NUTS 3 regio"
  },
  {
    "f_description": "Business demography and high growth enterprise by NACE Rev. 2 and NUTS 3 regions (ESTAT)",
    "f_resource": "BD_HGNACE2_R3",
    "f_short_description": "Business demography "
  },
  {
    "f_description": "Business demography by size class and NUTS 3 regions (ESTAT)",
    "f_resource": "BD_SIZE_R3",
    "f_short_description": "Business demography "
  },
  {
    "f_description": "Conventional dwellings by occupancy status, type of building and NUTS 3 region (ESTAT)",
    "f_resource": "CENS_11DWOB_R3",
    "f_short_description": "Conventional dwellin"
  },
  {
    "f_description": "Crimes recorded by the police by NUTS 3 regions (ESTAT)",
    "f_resource": "CRIM_GEN_REG",
    "f_short_description": "Crimes recorded by t"
  }, 
  ......
]

get_source_by_year_nuts_level

Gives the available sources depending on year and nutslevel

parameters:

  • _year
  • _level

examplecall:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_source_by_year_nuts_level/items.json?_year=2017&_level=2&limit=500

returns a list of sources

get_year_nuts_level_from_source

parameters:

  • _resource (name of a source)

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_year_nuts_level_from_source/items.json?_resource=BD_HGNACE2_R3&limit=500

returns a list of levels and years where there is data:


  {
    "f_level": "0",
    "f_year": "2008"
  },
  {
    "f_level": "0",
    "f_year": "2009"
  },
  {
    "f_level": "0",
    "f_year": "2010"
  },
  .....
]

get_column_values_source_json

Gives the possible values for filtering the source

parameters:

  • _resource (one of the f_resource you got from a call to get_source_by_nuts_level)
  • source_selections

sourceselections is a json formatted piece which contains always "year" ans "level" and a field "selected" which is an array, initially empty.

{
  "year":"2020",
  "level":"2",
  "selected":[]
}

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_column_values_source_json/items.json?_resource=TGS00010&source_selections={"year":"2020","level":"2","selected":[]}&limit=40

result:

[
  {
    "field": "isced11",
    "field_label": "International Standard Classification of Education (ISCED 2011)",
    "field_values": "[{\"label\": \"Less than primary, primary and lower secondary education (levels 0-2)\", \"value\": \"ED0-2\"}, {\"label\": \"Upper secondary and post-secondary non-tertiary education (levels 3 and 4)\", \"value\": \"ED3_4\"}, {\"label\": \"Tertiary education (levels 5-8)\", \"value\": \"ED5-8\"}, {\"label\": \"No response\", \"value\": \"NRP\"}, {\"label\": \"All ISCED 2011 levels\", \"value\": \"TOTAL\"}, {\"label\": \"Unknown\", \"value\": \"UNK\"}]"
  },
  {
    "field": "unit",
    "field_label": "Unit of measure",
    "field_values": "[{\"label\": \"Percentage\", \"value\": \"PC\"}]"
  },
  {
    "field": "age",
    "field_label": "Age class",
    "field_values": "[{\"label\": \"15 years or over\", \"value\": \"Y_GE15\"}]"
  },
  {
    "field": "sex",
    "field_label": "Sex",
    "field_values": "[{\"label\": \"Females\", \"value\": \"F\"}, {\"label\": \"Males\", \"value\": \"M\"}, {\"label\": \"Total\", \"value\": \"T\"}]"
  },
  {
    "field": "freq",
    "field_label": "Time frequency",
    "field_values": "[{\"label\": \"Annual\", \"value\": \"A\"}]"
  }
]

Advanced:

Sometimes the filter values you can choose are dependent of previous chosen values. For example if you choose the source Fertility indicators (DEMO_R_FIND2)

sourceselections is first

{   
     "year":"2019",
     "level":"2",
     "selected":[]
}



Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_column_values_source_json/items.json?_resource=DEMO_R_FIND2&source_selections={"year":"2020","level":"2","selected":[]}&limit=40

Result:

[
  {
    "field": "unit",
    "field_label": "Unit of measure",
    "field_values": "[{\"label\": \"Number\", \"value\": \"NR\"}, {\"label\": \"Year\", \"value\": \"YR\"}]"
  },
  {
    "field": "freq",
    "field_label": "Time frequency",
    "field_values": "[{\"label\": \"Annual\", \"value\": \"A\"}]"
  },
  {
    "field": "indic_de",
    "field_label": "Demographic indicator",
    "field_values": "[{\"label\": \"Mean age of women at childbirth\", \"value\": \"AGEMOTH\"}, {\"label\": \"Median age of women at childbirth\", \"value\": \"MEDAGEMOTH\"}, {\"label\": \"Total fertility rate\", \"value\": \"TOTFERRT\"}]"
  }
]

You can then choose for Unit of measure : YR the parameter sourceselections becomes:

{   
     "year":"2019",
     "level":"2",
     "selected":[{"field":"unit","value":"YR"}]
}

The Demographic indicators gets reduced to :

  • Mean age of women at childbirth
  • Median age of women at childbirth

Univariate\Bivariate DATA

If you want data there you have to take some steps:

  1. Choose NUTS level
  2. Choose source
  3. Choose year
  4. Choose filters

After choosing a NUTS level, source and a year you call the function get_column_values_source_json to get the filter values

API call

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_column_values_source_json/items.json?_resource=TGS00010&source_selections={"year":"2020","level":"2","selected":[]}&limit=40

Result


[
  {
    "field": "isced11",
    "field_label": "International Standard Classification of Education (ISCED 2011)",
    "field_values": "[{\"label\": \"Less than primary, primary and lower secondary education (levels 0-2)\", \"value\": \"ED0-2\"}, {\"label\": \"Upper secondary and post-secondary non-tertiary education (levels 3 and 4)\", \"value\": \"ED3_4\"}, {\"label\": \"Tertiary education (levels 5-8)\", \"value\": \"ED5-8\"}, {\"label\": \"No response\", \"value\": \"NRP\"}, {\"label\": \"All ISCED 2011 levels\", \"value\": \"TOTAL\"}, {\"label\": \"Unknown\", \"value\": \"UNK\"}]"
  },
  {
    "field": "unit",
    "field_label": "Unit of measure",
    "field_values": "[{\"label\": \"Percentage\", \"value\": \"PC\"}]"
  },
  {
    "field": "age",
    "field_label": "Age class",
    "field_values": "[{\"label\": \"15 years or over\", \"value\": \"Y_GE15\"}]"
  },
  {
    "field": "sex",
    "field_label": "Sex",
    "field_values": "[{\"label\": \"Females\", \"value\": \"F\"}, {\"label\": \"Males\", \"value\": \"M\"}, {\"label\": \"Total\", \"value\": \"T\"}]"
  },
  {
    "field": "freq",
    "field_label": "Time frequency",
    "field_values": "[{\"label\": \"Annual\", \"value\": \"A\"}]"
  }
]

To get univariate data you can call the function get_x_data

parameters:

  • _level
  • _year
  • X_JSON source and filters for data in JSON format

Url:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_x_data/items.json?_level=2&_year=2018&X_JSON=xjson&&limit=1500


xjson = {
    "source": "TGS00010",
    "conditions": [{
            "field": "isced11",
            "value": "TOTAL"
        }, {
            "field": "unit",
            "value": "PC"
        }, {
            "field": "age",
            "value": "Y_GE15"
        }, {
            "field": "sex",
            "value": "T"
        }, {
            "field": "freq",
            "value": "A"
        }
    ]
}

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_x_data/items.json?_level=2&_year=2018&X_JSON={"source":"TGS00010","conditions":[{"field":"isced11","value":"TOTAL"},{"field":"unit","value":"PC"},{"field":"age","value":"Y_GE15"},{"field":"sex","value":"T"},{"field":"freq","value":"A"}]}&limit=1500

Result:


  {
    "geo": "AL01",
    "x": null
  },
  {
    "geo": "AL02",
    "x": null
  },
  {
    "geo": "AL03",
    "x": null
  },
  {
    "geo": "AT11",
    "x": 4.2
  },
  {
    "geo": "AT12",
    "x": 3.8
  },
  {
    "geo": "AT13",
    "x": 10
  },
  {
    "geo": "AT21",
    "x": 4.1
  },
  {
    "geo": "AT22",
    "x": 4
  },
  {
    "geo": "AT31",
    "x": 3.2
  },
..........
]

To get bivariate data you can call the function get_xy_data

parameters:

  • _level
  • _year
  • X_JSON source and filters for x data in JSON format
  • Y_JSON source and filters for y data in JSON format

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_xy_data/items.json?_level=2&_year=2018&X_JSON=xjson&Y_JSON=yjson&limit=1500



xjson = {
    "source": "TGS00010",
    "conditions": [{
            "field": "isced11",
            "value": "TOTAL"
        }, {
            "field": "unit",
            "value": "PC"
        }, {
            "field": "age",
            "value": "Y_GE15"
        }, {
            "field": "sex",
            "value": "T"
        }, {
            "field": "freq",
            "value": "A"
        }
    ]
}

yjson = {
    "source": "DEMO_R_MLIFEXP",
    "conditions": [{
            "field": "unit",
            "value": "YR"
        }, {
            "field": "age",
            "value": "Y_LT1"
        }, {
            "field": "sex",
            "value": "T"
        }, {
            "field": "freq",
            "value": "A"
        }
    ]
}  

Example call:

https://mapineqfeatures.web.rug.nl/functions/postgisftw.get_xy_data/items.json?_level=2&_year=2018&X_JSON={"source":"TGS00010","conditions":[{"field":"isced11","value":"TOTAL"},{"field":"unit","value":"PC"},{"field":"age","value":"Y_GE15"},{"field":"sex","value":"T"},{"field":"freq","value":"A"}]}&Y_JSON={"source":"DEMO_R_MLIFEXP","conditions":[{"field":"unit","value":"YR"},{"field":"age","value":"Y_LT1"},{"field":"sex","value":"T"},{"field":"freq","value":"A"}]}&limit=1500

Result:

[.......,
  {
    "geo": "AT11",
    "x": 4.2,
    "y": 81.5
  },
  {
    "geo": "AT12",
    "x": 3.8,
    "y": 81.5
  },
  {
    "geo": "AT13",
    "x": 10,
    "y": 80.6
  },
  {
    "geo": "AT21",
    "x": 4.1,
    "y": 81.6
  },
  {
    "geo": "AT22",
    "x": 4,
    "y": 82.2
  }......
]
arrow_upward