Skip to main content

Central Bank of the Republic of Türkiye (TCMB) Python API.

Project description

tcmb

PyPI Latest Release License Downloads Python Version Code style: black

tcmb is a Python API wrapper around the Central Bank of the Republic of Türkiye (TCMB) Web Service. It is an unofficial open-source Python package intended for personal use (Disclaimer).


tcmb, Türkiye Cumhuriyeti Merkez Bankası (TCMB) Web Servisi'ne Python aracılığıyla erişimi sağlayan resmi olmayan API uygulamasıdır. Kişisel kullanım ve araştırma maksadıyla hazırlanmıştır (Elektronik Veri Dağıtım Sistemi (EVDS) Kullanım Koşulları).

Quickstart

pip install tcmb
import tcmb

client = tcmb.Client(api_key="...")

data = client.read(series="TP.DK.USD.S.YTL")

Overview

Data Hiearchy

  1. Categories:

Categories are at the top level of the TCMB data hiearchy.

client = tcmb.Client(api_key="...")
Client.categories

{'CATEGORY_ID': 1.0,
 'TOPIC_TITLE_ENG': 'MARKET STATISTICS',
 'TOPIC_TITLE_TR': 'PİYASA VERİLERİ'}

It is also possible to get the same information using the client.get_categories_metadata() method.

  1. Data Groups:

Each category consists of a number of data groups.

client = tcmb.Client(api_key="...")
Client.datagroups

[{'DATAGROUP_CODE': 'bie_pyrepo',
  'CATEGORY_ID': 1,
  'DATAGROUP_NAME': 'Açık Piyasa Repo ve Ters Repo İşlemleri',
  'DATAGROUP_NAME_ENG': 'Open Market Repo and Reverse Repo Transactions',
  ...}
 {'DATAGROUP_CODE': 'bie_mkbral',
  'CATEGORY_ID': 0,
  'DATAGROUP_NAME': 'Altın Borsası İşlemleri-İstanbul (TL-ABD Doları)(Arşiv)',
  'DATAGROUP_NAME_ENG': 'Istanbul Gold Exchange (TRY-USD)(Archive)',
  ...}]

It is also possible to filter the datagroups metadata using the client.get_datagroups_metadata() method.

  1. Series

Datagroups consist of time series, each having a series key such as TP.YSSK.A1 or TP.DK.USD.S.YTL. Series is read using the .read() method.

# read one time series
data = client.read("TP.YSSK.A1")

# read multiple time series
data = client.read(["TP.YSSK.A1", "TP.YSSK.A2", "TP.YSSK.A3"])

Series metadata can be fetched with .get_series_metadata() method.

# show metadata of each series within a data group
client.get_series_metadata(datagroup="bie_yssk")

[{'SERIE_CODE': 'TP.YSSK.A1',
  'DATAGROUP_CODE': 'bie_yssk',
  'SERIE_NAME': '1-2 Yıl(ABD doları)',
  'SERIE_NAME_ENG': '1-2 Years(USD)',
  ...},
  {'SERIE_CODE': 'TP.YSSK.A2',
  'DATAGROUP_CODE': 'bie_yssk',
  'SERIE_NAME': '3 Yıl(ABD doları)',
  'SERIE_NAME_ENG': '3 Years(USD)',
  ...}]

# show metadata of a specific time series
client.get_series_metadata(series="TP.YSSK.A1")

[{'SERIE_CODE': 'TP.YSSK.A1',
  'DATAGROUP_CODE': 'bie_yssk',
  'SERIE_NAME': '1-2 Yıl(ABD doları)',
  'SERIE_NAME_ENG': '1-2 Years(USD)',
  ...}]

Installation

pip install tcmb

Authentication

An API key is required to access the Web Service. Users can sign up from the login page. Once logged in, API Key is generated from the Profile page.

There are two ways of providing API key to the tcmb client.

  • Using environment variables:
$ export TCMB_API_KEY="..."
import os
os.environ["TCMB_API_KEY"] = "..."
  • Passing api_key when initializing the Client class.
client = Client(api_key="...")

Disclaimer

tcmb is an unofficial open-source package intended for personal use and research purposes. Please see TCMB's EVDS Disclaimer for the official terms of use of the EVDS Web Service.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tcmb-0.2.0.tar.gz (13.6 kB view hashes)

Uploaded Source

Built Distribution

tcmb-0.2.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page