nbrb
Python-библиотека для работы с api Национального банка Республики Беларусь (НБ РБ).
Возможности
- Получение полного перечня валют, по отношению к которым устанавливается официальный курс белорусского рубля.
- Получение курса конкретной валюты по внутреннему коду НБ РБ, цифровому или буквенном ISO-коду.
- Выборка курсов на произвольную дату и с учётом периодичности (ежедневно/ежемесячно).
- Получение динамики курсов (до 365 дней).
- Поучение ставки рефинсирования.
- Готовый
NBRBClientс поддержкой переиспользованияrequests.Session, таймаутов и контекстного менеджера.
Установка
pip install nbrb
Быстрый старт
from nbrb import fetch_rate
rate = fetch_rate("USD", param_mode=2)
print(f"{rate.cur_scale} {rate.cur_abbreviation}: {rate.cur_official_rate} BYN")
Использование клиента
from datetime import date
from nbrb import NBRBClient
with NBRBClient(timeout=5.0) as client:
currencies = client.list_currencies()
usd_today = client.get_rate("USD", param_mode=2)
usd_history = client.get_rate_dynamics(
431,
start_date=date(2024, 1, 1),
end_date=date(2024, 3, 31),
)
Больше примеров в файле examples.py
Обработка ошибок
Все исключения библиотеки наследуются от nbrb.NBRBError.
from nbrb import fetch_rate, HTTPError, NBRBError
try:
rate = fetch_rate(431)
except HTTPError as exc:
print(f"API вернуло ошибку: {exc.status_code} - {exc}")
except NBRBError as exc:
print(f"Произошла ошибка библиотеки: {exc}")
Лицензия
Проект распространяется по лицензии MIT. См. файл LICENSE
Metadata
Release files for nbrb 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nbrb-1.0.0.tar.gz | 9.7 kB | Without provenance | Details for nbrb-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nbrb-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for nbrb-1.0.0-py3-none-any.whl |
Total release size: 19.5 kB
Release files / nbrb-1.0.0.tar.gz
| Download URL | nbrb-1.0.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ebee57d05c59658b7f470d8897e7a286d09982cb0b9521febc38880aef0ac100
|
|
BLAKE2b-256 checksum How to use checksums |
1a45175cb978b0b06496d40af2dbf335513a38c1b67e6476e194822a565f407f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / nbrb-1.0.0-py3-none-any.whl
| Download URL | nbrb-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8bd70a9c12fa9f8373d696cd49e1cec3412b131c044f81fd065daf876a9bf81
|
|
BLAKE2b-256 checksum How to use checksums |
ca93f6a3fc5269d50f445bd7579fdb1327a9cf47755c5c9f46a0a85ab961b84c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for nbrb 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.