The Macrobond Data API for Python (Python wrapper)

Introduction

The Macrobond Data API for Python uses either the Macrobond Web REST API or the Macrobond Client data API to obtain time series with values and metadata. The API consists of a set of functions in common between the underlying APIs as well as specialized functions unique to each implementation.

You get time series directly as Pandas series.

Requirements

This API can be used only with Data+ license.

Macrobond Data API for Python officially supports Python 3.6+.

Installation

Macrobond Data API for Python is available on PyPI:

python -m pip install macrobond-data-api

Keyring

When using WebClient it is recommended to use the system keyring. This can be done easily by running the include script using this command:

python -c "from macrobond_data_api.util import *; save_credential_to_keyring()"

Supported keyrings:

Working with Python wrapper

Learn more about the Commonly used metadata in Macrobond.

Download one series (Basic usage)

import macrobond_data_api as mb_api

usgdp = mb_api.get_one_series("usgdp")

print(usgdp)

Download one series (Advanced usage)

#web
from macrobond_data_api.web import WebClient

with WebClient('client id', 'client secret') as api:
    series = api.get_one_series('usgdp')

print(series)
#com
from macrobond_data_api.com import ComClient

with ComClient() as api:
    series = api.get_one_series('usgdp')

print(series)

Extensive guide - more examples

We have prepared examples in Jupyter Notebooks to help you start using Python wrapper. See them on our Github.