-
Notifications
You must be signed in to change notification settings - Fork 47
SDMX Data Queries: HowTo
A data query is a sequence of tokens that uniquely identifies the resource in the SDMX provider. We'll refer to this sequence as the SDMX identifier of the resource. The identifier depends on the structure (DSD) of the dataflow that contains the resource.
Let's use the EXR dataflow from ECB as an example. The DSD for this dataflow declares 5 dimensions:
- FREQ
- CURRENCY
- CURRENCY_DENOM
- EXR_TYPE
- EXR_SUFFIX
This means that, in order to uniquely identify a resource in this dataflow, the identifier will have to contain the name of the dataflow plus 5 tokens representing the dimensions (you can think of the dataflow as a DB table whos primary key is made of 5 columns).
The tokens that have to be used to identify dimension values are the codes declared in the codelist associated to every single dimension. Take the FREQ dimension as an example: the codelist for it is the CL_FREQ.
So, if we want to retrieve a time series from the EXR dataflow, we'll have to build a resource identifier that is made of 6 tokens: one representing the flow (always the first) and the others representing legal values for each dimension, in the very same order as they are declared in the DSD of the flow
An example is EXR/A.USD.EUR.SP00.A, that means:
- EXR: the flow
- A: code for FREQ dimension
- USD: code for CURRENCY dimension
- EUR: code for CURRENCY_DENOM dimension
- SP00: code for EXR_TYPE dimension
- A: code for EXR_SUFFIX dimension
NOTE: not every combination of legal dimension codes is actually associated to a resource. Some combinations, though valid, produce no results (or, in 2.1 providers, they return an HTTP 404 error code).
Two special keys are supported in data queries:
- The wildcard (an empty character) means all the available codes
- The '+' means a logic OR and can be used to query multiple codes.
Examples of usage for this characters:
EXR/.USD.EUR.SP00.A
queries all available frequencies
EXR/A+M.USD.EUR.SP00.A
queries Annual and Monthly frequencies
You can query multiple time series (also from different data flows) in a single request by means of the ';' separator. As an example the query
EXR/A.USD.EUR.SP00.A;EXR/A.GBP.EUR.SP00.A;EXR/M.USD.EUR.SP00.A
will return 3 time series.
This method is less efficient, as it performs multiple separate requests, but it has the advantage to respect the request order in the output.
The time constraints can be added in various formats. Following you can check some of them.
# select years
getTimeSeries('ECB', 'EXR/D.USD.EUR.SP00.A', '2000', '2001')
# select months
getTimeSeries('ECB', 'EXR/D.USD.EUR.SP00.A', '2000-01', '2000-12')
# select quarters
getTimeSeries('ECB', 'EXR/D.USD.EUR.SP00.A', '2000-Q1', '2000-Q2')
# select days
getTimeSeries('ECB', 'EXR/D.USD.EUR.SP00.A', '2000-01-01', '2000-01-31')
-
sdmx-twg on github
https://github.com/sdmx-twg/sdmx-rest/wiki
https://github.com/sdmx-twg/sdmx-rest/wiki/Data-queries
https://github.com/sdmx-twg/sdmx-rest/wiki/Where-is-it-used
-
EUROSTAT
http://ec.europa.eu/eurostat/web/sdmx-web-services/about-eurostat-data -
ECB
http://sdw-wsrest.ecb.europa.eu/documentation/index.jsp -
ISTAT
http://sdmx.istat.it/SDMXWS/rest/help
Note that this endpoint needs registration for being accessed:
http://sdmx.istat.it/registr_ut_sep/ -
INEGI
http://www.inegi.org.mx/inegi/contenidos/servicios/sdmx/ -
OECD
http://stats.oecd.org/Sdmxws/sdmx.asmx -
IMF
http://sdmxws.imf.org/Gateway/Help.aspx -
ABS
http://stat.abs.gov.au/sdmxws/sdmx.asmx -
ILO
http://www.ilo.org/ilostat/content/conn/ILOSTATContentServer/path/Contribution%20Folders/statistics/web_pages/static_pages/technical_page/ilostat_appl/SDMX_User_Guide.pdf -
INSEE
http://www.bdm.insee.fr/bdm2/statique?page=sdmx -
UIS
https://apiportal.uis.unesco.org -
WITS
http://wits.worldbank.org/witsapiintro.aspx?lang=en