Pythonic access to the exchange rate API hosted by Magyar Nemzeti Bank (MNB, Central Bank of Hungary)
Project description
MNB
This package provides Pythonic access to the exchange rate API hosted by Magyar Nemzeti Bank (MNB, Central Bank of Hungary).
Background
MNB exposes a publicly available exchange rate API as a SOAP service where they publish their official daily rate between Hungarian Forint (HUF) and most other currencies.
The official documentation of their API is available here (only in Hungarian).
Installation
Since this package is published to PyPI, you can install it with any PyPI-compatible package manager, such as pip:
pip install mnb
Usage
Create a Client
(mnb-py3.11) vscode ➜ /workspaces/mnb/src (develop) $ python
Python 3.11.1 (main, Jan 11 2023, 14:15:54) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mnb import Mnb
>>> client = Mnb()
GetInfo()
Returns the first and the last day when rates were published, including all available currencies.
>>> client.get_info()
Info(first_date=datetime.date(1949, 1, 3), last_date=datetime.date(2023, 1, 16), currencies=['HUF', 'EUR', 'AUD', 'BGN', 'BRL', 'CAD', 'CHF', 'CNY', 'CZK', 'DKK', 'GBP', 'HKD', 'HRK', 'IDR', 'ILS', 'INR', 'ISK', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RON', 'RSD', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'UAH', 'USD', 'ZAR', 'ATS', 'AUP', 'BEF', 'BGL', 'CSD', 'CSK', 'DDM', 'DEM', 'EEK', 'EGP', 'ESP', 'FIM', 'FRF', 'GHP', 'GRD', 'IEP', 'ITL', 'KPW', 'KWD', 'LBP', 'LTL', 'LUF', 'LVL', 'MNT', 'NLG', 'OAL', 'OBL', 'OFR', 'ORB', 'PKR', 'PTE', 'ROL', 'SDP', 'SIT', 'SKK', 'SUR', 'VND', 'XEU', 'XTR', 'YUD'])
GetCurrencies()
Returns all available currencies.
>>> client.get_currencies()
['HUF', 'EUR', 'AUD', 'BGN', 'BRL', 'CAD', 'CHF', 'CNY', 'CZK', 'DKK', 'GBP', 'HKD', 'HRK', 'IDR', 'ILS', 'INR', 'ISK', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PLN', 'RON', 'RSD', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'UAH', 'USD', 'ZAR', 'ATS', 'AUP', 'BEF', 'BGL', 'CSD', 'CSK', 'DDM', 'DEM', 'EEK', 'EGP', 'ESP', 'FIM', 'FRF', 'GHP', 'GRD', 'IEP', 'ITL', 'KPW', 'KWD', 'LBP', 'LTL', 'LUF', 'LVL', 'MNT', 'NLG', 'OAL', 'OBL', 'OFR', 'ORB', 'PKR', 'PTE', 'ROL', 'SDP', 'SIT', 'SKK', 'SUR', 'VND', 'XEU', 'XTR', 'YUD']
GetCurrencyUnits()
Returns the unit for each currency passed in the parameter.
>>> client.get_currency_units(["EUR", "JPY"])
[CurrencyUnit(currency='EUR', unit=1), CurrencyUnit(currency='JPY', unit=100)]
GetCurrentExchangeRates()
Returns the latest available exchange rates for all currencies.
Note: Rates are not published over the weekends and public holidays.
>>> client.get_current_exchange_rates()
<Element Day at 0x7f9ef8b09300>
Day(date=datetime.date(2023, 1, 16), rates=[Rate(currency='AUD', rate=256.81), Rate(currency='BGN', rate=203.99), Rate(currency='BRL', rate=72.36), Rate(currency='CAD', rate=275.26), Rate(currency='CHF', rate=398.61), Rate(currency='CNY', rate=54.8), Rate(currency='CZK', rate=16.62), Rate(currency='DKK', rate=53.63), Rate(currency='EUR', rate=398.98), Rate(currency='GBP', rate=449.86), Rate(currency='HKD', rate=47.2), Rate(currency='IDR', rate=0.0245), Rate(currency='ILS', rate=107.78), Rate(currency='INR', rate=4.52), Rate(currency='ISK', rate=2.59), Rate(currency='JPY', rate=2.872), Rate(currency='KRW', rate=0.2981), Rate(currency='MXN', rate=19.56), Rate(currency='MYR', rate=85.43), Rate(currency='NOK', rate=37.25), Rate(currency='NZD', rate=235.75), Rate(currency='PHP', rate=6.76), Rate(currency='PLN', rate=84.92), Rate(currency='RON', rate=80.69), Rate(currency='RSD', rate=3.4), Rate(currency='RUB', rate=5.39), Rate(currency='SEK', rate=35.4), Rate(currency='SGD', rate=279.24), Rate(currency='THB', rate=11.18), Rate(currency='TRY', rate=19.62), Rate(currency='UAH', rate=10.03), Rate(currency='USD', rate=368.71), Rate(currency='ZAR', rate=21.6)])
GetDateInterval()
Returns the first and the last day when rates were published.
>>> client.get_date_interval()
(datetime.date(1949, 1, 3), datetime.date(2023, 1, 16))
GetExchangeRates()
Returns the list of rates published between the provided range for the currencies provided.
>>> import datetime
>>> client.get_exchange_rates(datetime.date(2023, 1, 13), datetime.date(2023, 1, 14), ["EUR", "USD"])
<Element Day at 0x7f9ef7fcb980>
[Day(date=datetime.date(2023, 1, 13), rates=[Rate(currency='EUR', rate=396.19), Rate(currency='USD', rate=365.39)])]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mnb-1.0.1.tar.gz.
File metadata
- Download URL: mnb-1.0.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.79.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b0c52d6ffa40881289de6aeca8036e98f8b4e2c0d5af8c3b86c8793a3b498a
|
|
| MD5 |
ed34f024c7cae037d0f69bee5880d8c3
|
|
| BLAKE2b-256 |
d5775efb75fcc565d38a487a89316fbb726a19faaca0061c51d66167fe7e94e0
|
File details
Details for the file mnb-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mnb-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.79.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f3badafa63dd959f10399d1f74d8738f5ee2f6d9b29e686098b434927b01365
|
|
| MD5 |
680904addb9fa1db0c53d3ca40282fb6
|
|
| BLAKE2b-256 |
192d7d40eae4c7f1bec84bc4c763174303c843582dd6b159f11cf188e50b268c
|