API Reference
pybrsa - A Python package for fetching data from BDDK.
fetch_bddk1(year, month, table_no, grup_kod=10001, currency='TL', lang='en', verbose=False)
Fetch monthly data from BDDK API.
Parameters
year : int 4-digit year (YYYY) month : int Month (1-12) table_no : int Table number (1-17) grup_kod : int or list of int, default 10001 Group code(s) (10001-10010) currency : str, default "TL" Currency code ("TL" or "USD") lang : str, default "en" Language ("en" or "tr")
Returns
pd.DataFrame DataFrame with fetched data and fetch_info in attrs
Examples
Single group code
df = fetch_bddk1(2020, 3, 1, grup_kod=10001) df.shape (82, 12)
Multiple group codes
df = fetch_bddk1(2020, 3, 1, grup_kod=[10001, 10002]) len(df['grup_kod'].unique()) 2
Turkish language output
df = fetch_bddk1(2020, 3, 1, grup_kod=10001, lang="tr") 'Yıl' in df.columns # Turkish column names True
See Also
fetch_finturk1 : For quarterly province-level data.
Source code in pybrsa/fetch_bddk.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
fetch_finturk1(year, month, table_no, grup_kod=10001, il=0, verbose=False)
Fetch quarterly data from BDDK Finturk API.
Parameters
year : int 4-digit year (YYYY) month : int Month (3, 6, 9, 12 for quarterly data) table_no : int Table number (1-7) grup_kod : int or list of int, default 10001 Group code(s) (10001-10007) il : int or list of int, default 0 Plate number(s) (0-81; 999 = Yurt Dışı)
Returns
pd.DataFrame DataFrame with fetched data and fetch_info in attrs
Examples
Single group, all provinces
df = fetch_finturk1(2020, 3, 1, grup_kod=10001) 'il_adi' in df.columns True
Multiple groups and specific provinces
df = fetch_finturk1(2020, 3, 1, grup_kod=[10006, 10007], il=[6, 34]) set(df['grup_kod'].astype(int).unique()) == {10006, 10007} True
Single group, single province
df = fetch_finturk1(2020, 3, 1, grup_kod=10001, il=34) df['il_adi'].iloc[0] 'İSTANBUL'
See Also
fetch_bddk1 : For monthly data without province granularity.
Source code in pybrsa/fetch_finturk.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
list_cities()
List available cities for Finturk quarterly data with plaka numbers.
Returns
pd.DataFrame DataFrame with columns 'plaka' and 'il'
Examples
import pybrsa df = pybrsa.list_cities() print(df.head())
Source code in pybrsa/info.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
list_groups(source='bddk', lang='en')
List available banking groups for a data source.
Parameters
source : str, default "bddk" Either "bddk" or "finturk" lang : str, default "en" Either "tr" or "en" for names
Returns
pd.DataFrame DataFrame with columns 'Group_Code' and 'Name'
Examples
import pybrsa df = pybrsa.list_groups("bddk") df = pybrsa.list_groups("finturk", "tr")
Source code in pybrsa/info.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
list_tables(source='bddk', lang='en')
List available tables for a data source.
Parameters
source : str, default "bddk" Either "bddk" or "finturk" lang : str, default "en" Either "tr" or "en" for table titles
Returns
pd.DataFrame DataFrame with columns 'Table_No' and 'Title'
Examples
import pybrsa df = pybrsa.list_tables("bddk") df = pybrsa.list_tables("finturk", "tr")
Source code in pybrsa/info.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
save_data(df, filename=None, format='pkl')
Save fetched data to multiple formats.
Parameters
df : pd.DataFrame DataFrame to save filename : str Required. A non-empty string (without extension) must be provided. format : str, default "pkl" Output format: "pkl", "csv", or "xlsx"
Returns
str Full file path with extension
Examples
import pybrsa import tempfile
df = pybrsa.fetch_bddk1(2024, 1, table_no=1) temp_path = tempfile_base() saved_path = pybrsa.save_data(df, temp_path, format="csv")
Source code in pybrsa/io.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
tempfile_base()
Create a temporary file base name without extension.
Equivalent to R's tempfile() function.
Returns
str Temporary file path without extension
Examples
temp_path = tempfile_base()
Use with save_data
pybrsa.save_data(df, temp_path, format="csv")
Source code in pybrsa/io.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
:::