Manual
The Statistical Office of the Slovak Republic offers an application programming interface (API) providing an access to data of selected tables available in the DATAcube. database. It is a tool designed mainly for developers and data analytists who need data in machine-readable form. These are available in JSON-stat, CSV, XML, XLSX and ODS formats. The Bulk download column of the table on the home page lists REST API links that allow bulk downloads. For tables with a large data range, only links to generated CSV and JSON files are available.
Access to data is free and does not require registration. All information is subject to the license terms of the Creative Commons Attribution License (cc-by) 4.0. More detailed information can be found on the page Conditions for use and further dissemination of the SO SR statistical information.
The data is updated every working day at 10:00 and 22:00.
What is JSON-stat?
JSON-stat is a simple JSON (JavaScript Object Notation) format that has been specially created for statistical tables that can have many dimensions. This initiative is based on the fact that tables are the most common form of data dissemination. JSON-stat is a hierarchical structure that contains table metadata, dimensions, and their descriptions and data. More information about this format can be found at https://json-stat.org/.
How do I get the data?
For easier access to the data, we have created a web interface in which you will find a list of all available tables. In the list, you can search for tables by their name or unique code, or filter by statistical domain and subdomain. The Complete Data column contains URL links to files that contain all the data in the table. These links are only available for smaller tables. For larger tables, it is necessary to create a partial selection from the available data.
A partial selection can be created in the table detail, which will be displayed after clicking on the table name. In the detail of the table, you can use the form to compile your own selection of dimension elements, set the required language and output data format. After the name of each dimension, there is a code designation of the dimension, which is a link to the list of its elements in the JSON-stat format. You can access the data of your choice by pressing the Generate button and then displaying the generated link.
The API allows you to get 3 types of data:
- Overview of all tables available in the API via the URL https://data.statistics.sk/api/v2/collection?lang=en in JSON-stat format.
- List of table dimension elements in JSON-stat format via URL, which we will create according to the pattern
https://data.statistics.sk/api/v2/dimension/cube_code/dim_code?lang=lang_code
, where cube_code is the eight-digit table code, dim_code is the table dimension code, and lang_code is the language code (sk or en), it is an optional parameter by default set to sk. For example, elements of dimension np3106rr_dim1 are obtained via URL https://data.statistics.sk/api/v2/dimension/np3106rr/np3106rr_dim1. - The data request shall take the form of an URL, which we will create according to the pattern
https://data.statistics.sk/api/v2/dataset/cube_code/PARAM1/PARAM2/PARAM3...?lang=lang_code&type=file_type
, where cube_code is the eight-digit table code, PARAM1, PARAM2 .... are the element codes of the selected table dimensions, lang_code is the language code (sk or en), it is an optional parameter defaultly set to sk, file_type is the file type (json, csv, xml, xlsx, ods), it is an optional parameter by default set to json. You can use the form available after clicking on the table detail to compile the URL.
Example: From the table Gross earnings by occupation with the code np3106rr we want to obtain data on the average gross nominal monthly earnings of craft and related trades workers in the Region of Trnava for the years 2016, 2017 and 2018. Using the form we get an URL: https://data.statistics.sk/api/v2/dataset/np3106rr/SK021/2016,2017,2018/E_PRIEM_HR_MZDA/7?lang=en and data in the JSON-stat format:
{ "version": "2.0", "class": "dataset", "label": "Gross earnings by occupation", "update": "2020-06-22", "note": "Structure of Earnings Survey.\n", "href": "http://datacube.statistics.sk/#!/view/en/VBD_SK_WIN/np3106rr/v_np3106rr_00_00_00_en", "id": ["nuts13","np3106rr_rok","np3106rr_ukaz","np3106rr_dim1","np3106rr_data"], "size": [1,3,1,1,1], "role":{ "time": ["np3106rr_rok"], "geo": ["nuts13"], "metric": ["np3106rr_data"] }, "dimension":{ "nuts13":{ "label": "nuts13", "note": "0 SR + Areas + Regions", "category":{ "index":{ "SK021": 0 }, "label":{ "SK021": "Region of Trnava" } } }, "np3106rr_rok":{ "label": "np3106rr_rok", "note": "Year", "category":{ "index":{ "2016": 0, "2017": 1, "2018": 2 } } }, "np3106rr_ukaz":{ "label":"np3106rr_ukaz", "note":"Indicator", "category":{ "index":{ "E_PRIEM_HR_MZDA":0 }, "label":{ "E_PRIEM_HR_MZDA":"Average gross nominal monthly earnings (EUR)" } } }, "np3106rr_dim1":{ "label":"np3106rr_dim1", "note":"Classification of Occupation (SK ISCO-08)", "category":{ "index":{ "7":0 }, "label":{ "7":"Craft and related trades workers" } } }, "np3106rr_data":{ "label":"np3106rr_data", "note":"Data", "category":{ "index":{ "NUM_VALUE":0 }, "label":{ "NUM_VALUE":"value" } } } }, "value":[992,1077,1154] }
The following keywords and special symbols can be used when writing multiple elements:
all
- all element codes of the given dimension will be included in the data selection.lastx
- where x is an integer (this is assumed to be used for the year dimension, e.g. last5 will supply values for the last 5 years). Not recommended for use with other dimensions.elem1,elem2,elem3 ....
- naming of individual element codes of the given dimension (eg 2010,2012,2015 for the dimension np3106rr_rok will limit the selection of data to the years specified). This can be used for all dimensions.elem1:elem2
- element interval (eg 2010:2015 for the dimension np3106rr_rok will limit data selection for years 2010 to 2015 inclusive). It can also be used for other dimensions if the element codes start or end with a number.elem1:
- element interval (eg 2010: for the dimension np3106rr_rok will limit data selection to 2010 inclusive and more). It can also be used for other dimensions if the element codes start or end with a number.:elem1
- element interval (eg :2015 for the dimension np3106rr_rok will limit data selection to 2015 inclusive and less). It can also be used for other dimensions if the element codes start or end with a number.*
replaces a group of characters, for example SK04* for the dimension nuts13 includes Eastern Slovakia (SK04), Region of Prešov (SK041) and Region of Košice (SK042). It can also be used for other dimensions.
Limitations
You may encounter the following restrictions when using the API:
- The URL can be up to 2000 characters long.
- The amount of data transmitted by one URL link is a maximum of 10000 items.
No data
For some combinations of dimension elements, the data may not exist. In this case, the value will be null
.