The South Africa Macroeconomic Database (SAMADB) is an open relational database with ~10,000 macroeconomic time series for South Africa, obtained from the South African Reserve Bank (SARB) and Statistics South Africa (STATSSA) and updated on a weekly basis via EconData and automated scraping of the SARB and STATSSA websites. It is accessible through API packages for R, Python and Julia. While the source code for SAMADB and the APIs remains private, this public repo provides guidance on API installation and allows you to report issues with the database or APIs. Each API has its own built-in documentation. More information about SAMADB is available in the introductory presentation.
To install from CRAN, use
install.packages("samadb")
Then attach the package with
library(samadb)
help("samadb") # Open Documentation
Notes: The R API offers the broadest functionality, including the possibility to transpose data and export data to Excel. In the wide format, variable labels are attached to the series as attributes, and can be received using collapse::vlabels()
or, together with names, using collapse::namlab()
. Functions return a data.table.
To install from pypi, open a terminal and execute
pip install samadb
Then import the package with
import samadb as sm
help(sm) # Overview of Package Functions
Notes: The python package returns polars DataFrame's. These can be converted to pandas DataFrame's using the .to_pandas()
method. The Python API is a bit different than the R API, due to the greater difficulty of dealing with variable labels in Python. It also presently has no options to transpose or export to Excel, which can however be achieved by converting to pandas and using the .to_excel()
method.
To install from the Julia package registry, use
using Pkg; Pkg.add("SAMaDB")
Then import the package with
import SAMaDB as sm
?sm # Overview of Package Functions
Notes: The Julia API returns DataFrame's, and is pretty much identical to the Python API i.e. you should access functions using qualified names as in Python, e.g. sm.datasets()
. No functions are exported.