CBAR Currency Rates
Python client for the official currency rates published by the Central Bank of the Republic of Azerbaijan.
CBAR publishes official AZN exchange-rate bulletins as dated XML files:
https://cbar.az/currencies/DD.MM.YYYY.xml
When a date is not provided, this package fetches the latest official bulletin for the current Baku date and falls back through recent dates if CBAR has not published a dated XML file yet.
Installation
pip install cbar-currency-rates
Quick Start
from cbar_currency_rates import CBARClient
cbar = CBARClient()
# Simple backwards-compatible shape: {"USD": 1.7, "EUR": 1.9362, ...}
rates = cbar.get_rates()
print(rates["USD"])
# Fetch selected currencies only
selected = cbar.get_rates(codes=["USD", "EUR", "TRY"])
print(selected)
Rich Rate Metadata
from cbar_currency_rates import CBARClient
cbar = CBARClient()
table = cbar.latest(codes=["USD", "JPY"])
usd = table.require("USD")
jpy = table.require("JPY")
print(table.date) # Official bulletin date
print(table.source_url) # CBAR XML URL
print(usd.value) # Decimal("1.7000")
print(jpy.nominal_text) # "100"
print(jpy.rate) # AZN value for one JPY
CBAR lists some currencies by nominal amounts, such as 100 JPY or 100 RUB.
CurrencyRate.value keeps CBAR's official value for the listed nominal, while
CurrencyRate.rate normalizes it to one unit.
Historical Dates
from datetime import date
from cbar_currency_rates import CBARClient
cbar = CBARClient()
rates = cbar.get_rates(date=date(2024, 5, 27))
same_rates = cbar.get_rates(date="27.05.2024")
Accepted date inputs:
datetime.datedatetime.datetimeYYYY-MM-DDDD.MM.YYYYDD/MM/YYYY
Convert Amounts
from cbar_currency_rates import CBARClient
cbar = CBARClient()
azn = cbar.convert(100, "USD", "AZN")
eur = cbar.convert(100, "USD", "EUR")
convert() returns a Decimal and uses CBAR's official AZN cross-rates.
Bank Metals
Currency methods exclude bank metals by default. Enable them when needed:
from cbar_currency_rates import CBARClient
cbar = CBARClient()
table = cbar.latest(include_metals=True)
gold = table.require("XAU")
print(gold.value)
Compatibility
The old import style still works:
from cbar_currency_rates.rates import CBARRates
cbar = CBARRates()
print(cbar.get_rates())
Development
pip install -r requirements.txt
pip install pytest
pytest
Metadata
Release files for cbar-currency-rates 2.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 |
|---|---|---|---|---|
| cbar_currency_rates-2.0.0.tar.gz | 7.9 kB | Without provenance | Details for cbar_currency_rates-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cbar_currency_rates-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for cbar_currency_rates-2.0.0-py3-none-any.whl |
Total release size: 16.6 kB
Release files / cbar_currency_rates-2.0.0.tar.gz
| Download URL | cbar_currency_rates-2.0.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
daa16c642ed04764c44c29897010ec085d0d5fc373c7976f53b6aed757451303
|
|
BLAKE2b-256 checksum How to use checksums |
0c115542d30eba193739ea9d531b8807ac26f35e213976fa07597fc1880077a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / cbar_currency_rates-2.0.0-py3-none-any.whl
| Download URL | cbar_currency_rates-2.0.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a50b3a1219fc7e8a1378491fa280ace228f2fbabf409835433c53e9442adba1
|
|
BLAKE2b-256 checksum How to use checksums |
702c883dfd912861b7258a68fe5b8b61737ba6ec4434a3b4537e50362e69fed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for cbar-currency-rates 2.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.