Package: sdw-api
A Basic SDW APIThis package provides a basic API for the ECB's Statistical Data Warehouse (SDW).
In its current version, a few features are still missing. Nonetheless, the package already allows for downloading data seamlessly. An option allows saving the downloaded data directly into a.xlsxspreadsheet.1.0 Basic Functionality1.1 InstallationThe package is available via pip. To install the SDW_API simply runpip install sdw-apiin your command prompt.1.2 Downloading DataThe package consists of one main class calledSDW_API, which handles the data download and basic data treatment automatically. Once the package is downloaded, it can be imported using the following statement:fromsdw_apiimportSDW_APIThe SDW_API class takes the following input arguments:SDW_API(ticker_list,start=None,end=None,outpath=None,filename=None,target_freq=None,method=None)They can be separated into two groups:Required/Positional arguments:ticker_list: A python list containing the data series tickers or labels. These are equivalent to the ones used on the SDW website.Keyword Arguments:start: This argument can be used, if a start date is to be set. The start date has to be inYYYY-MM-DDformat. If this argument is specified, only data with a time stamp that is more recent than the start date is retrieved. If the argument isNone, the entire available history will be downloaded.end: This argument can be used, if an end date is to be set. The end date has to be inYYYY-MM-DDformat. If this argument is specified, only data with a time stamp that is older than the end date is retrieved.outpath: If the resulting date is to be saved as.xlsxan output path can be specified. This argument sets the directory where the data is to be saved.filename: This argument allows to specify a unique filename for the output file. If neitheroutpathnorfilenameare set, the output file is not saved.target_freq: This setting allows for defining a desired output frequency of the final DataFrame or spreadsheet. The class automatically detects the data frequency of the individual data series inticker_list. Ifticker_listcontains time series at monthly as well as quarterly frequency, the highest frequency is assumed as a default. In this example, the output DataFrame will thus be at monthly frequency. In this case, settingtarget_freqto "Q" overwrites the default. The final DataFrame is then at quarterly frequency.method: Iftarget_freqis set to "Q", but theticker_listalso contains time series at monthly frequency, this option allows for setting an aggregation method for the time series at higher frequency. At the moment, only the average is implemented, which is also the default option.2.0 ExampleLet's assume we want to download Euro area (EA) HICP excluding food and energy ('ICP.M.U2.Y.XEF000.3.INX'), EA GDP ('MNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.N'), the historical close of the EONIA at monthly frequency ('FM.M.U2.EUR.4F.MM.EONIA.HSTA'), and EA total employment in hours worked ('ENA.Q.Y.I8.W2.S1.S1._Z.EMP._Z._T._Z.HW._Z.N') over from January 2000 (i.e. '2000-01-01') until now.Assuming the package is imported, let's first download the data at monthly frequency:# set the tickers to be downloadedticker_list=['ICP.M.U2.Y.XEF000.3.INX','MNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.N','FM.M.U2.EUR.4F.MM.EONIA.HSTA','ENA.Q.Y.I8.W2.S1.S1._Z.EMP._Z._T._Z.HW._Z.N']# set a start datestart='2000-01-01'# initialize the APIexample=SDW_API(ticker_list,start=start)# download the data and compose DataFrameexample()# access the output dataexample.dataThe head of the resulting DataFrame looks something like this:ICP.M.U2.Y.XEF000.3.INXMNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.NFM.M.U2.EUR.4F.MM.EONIA.HSTAENA.Q.Y.I8.W2.S1.S1._Z.EMP._Z._T._Z.HW._Z.N2000-01-31 00:00:0079.8723nan3.04286nan2000-02-29 00:00:0079.8981nan3.27571nan2000-03-31 00:00:0079.94012.22607e+063.510435.83027e+072000-04-30 00:00:0079.9912nan3.685nan2000-05-31 00:00:0080.0094nan3.92nanTo generate output data at quarterly frequency instead, the following commands can be used:# set the tickers to be downloadedticker_list=['ICP.M.U2.Y.XEF000.3.INX','MNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.N','FM.M.U2.EUR.4F.MM.EONIA.HSTA','ENA.Q.Y.I8.W2.S1.S1._Z.EMP._Z._T._Z.HW._Z.N']# set a start datestart='2000-01-01'target_freq='Q'# initialize the APIexample=SDW_API(ticker_list,start=start,target_freq=target_freq)# download the data and compose DataFrameexample()# access the output dataexample.dataThe monthly series have now been aggregated to quarterly frequency automatically:ICP.M.U2.Y.XEF000.3.INXMNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.NFM.M.U2.EUR.4F.MM.EONIA.HSTAENA.Q.Y.I8.W2.S1.S1._Z.EMP._Z._T._Z.HW._Z.N2000-03-31 00:00:0079.90352.22607e+063.276345.83027e+072000-06-30 00:00:0080.05132.24645e+063.966525.85199e+072000-09-30 00:00:0080.29872.2588e+064.439395.87186e+072000-12-31 00:00:0080.59682.27377e+064.806225.89292e+072001-03-31 00:00:0080.76852.29697e+064.843265.90698e+073.0 Features coming soon:more aggregation methodssupport for more data frequencies