|
<< Click to Display Table of Contents >> Download API |
![]() ![]()
|
Gekko has an interface to the online API of Statistics Denmark (statbank.dk). This is perhaps not very interesting for non-Danish users, but other online databanks could be supported in Gekko, too. You can use the DOWNLOAD statement to download timeseries originating from data tables on statbank.dk, without having to go through a manual process. The syntax for accessing the API is:
download 'http://api.statbank.dk/v1/data' statbank.json; |
With the above statement line, Gekko accesses the online API via the provided link and a .json file describing which data to download. The file indicates which table and which variables from that table are to be retrieved. The json file is based on the .json format, which can be thought of as a kind of simplified and more readable xml. For example:
{ |
With the above specification, Gekko will use the API to fetch the data table PRIS6 ("table": "PRIS6"), in PC-Axis format ("format": "px", which is currently the only format Gekko can use regarding statbank.dk), and the price index ("code": "UNIT", "values": ["100"]) retrieve the product groups with the codes 011200 and 011100 ("code": "PRODUCT", "values": ["011200", "011100"]) for the entire period ("code": "TIME", "values": ["*"]).
The variables are placed in Gekko's work bank and the variables are named according to the following convention:
<table name>_<dimension1>_<code1>_<dimension2>_<code2>_<dimension3>_<code3> ...
When the above DOWNLOAD statement is run, the following output is shown:
-> Download start ...
PRIS6_VAREGR_011200_ENHED_100, with freq M, 2000m1-2015m12
PRIS6_VAREGR_011100_ENHED_100, with freq M, 2000m1-2015m12
-> Downloaded 2 timeseries in total
And the two time series PRIS6_VAREGR_011200_ENHED_100 and PRIS6_VAREGR_011100_ENHED_100 are located in Gekko's first-position databanke, where the name composition corresponds to this:
PRICE6 <table name>
_VAREGR_011200 _<dimension1>_<code1>
_ENHED_100 _<dimension2>_<code2>
In addition, Gekko shows info about frequency and time period, respectively. For instance, with freq M, 2000m1-2015m12 means that the frequency is monthly (M), and the dates mean that the data runs from January 2000 to December 2015. If it had instead been 2000m2-2015m11, the data would have run from February 2000 to November 2015.
If you want to retrieve all item groups and unit types from a table, you may use "*" inside the square bracket that follows the table group code (PRODUCT, UNIT and TIME in the above). This is e.g. done for the time period in the json file above.
If you wanted to e.g. to retrieve the entire table, PRICE6, with price indices for all product groups, the json file should look like this:
{ |
The API is a handy tool for downloading multiple statbank data at once. As mentioned, the DOWNLOAD interface could be adapted for other online databanks, too.