All currency codes in one package
Project description
Description
Comprehensive Python package for managing currency codes across different types of assets. Having all the currency codes in one package can simplify the development process for applications that involve multiple currencies and assets. This package could also help to ensure consistency and accuracy in managing currency codes across different parts of an application
The package provides currency codes for different types of assets. Such as
- fiat (US dollar, UAE Dirham, ...)
- crypto (Bitcoin, Solana, ...)
- commodity (Palladium, Gold, ...)
- others (WIR Franc, CFP Franc, ...)
Sources
- Coinmarketcap website for crypto
- ISO's website for rest
Installation
Install the package with the following command:
pip install currency_codes
How to use the package?
Get a currency info by a currency code
You can get any currency info using the snippet below
from currency_codes import get_currency_by_code, Currency
currency_code: str = "EUR"
currency: Currency = get_currency_by_code(currency_code)
if the package doesn't know a currency code you can raise a PR to extend the knowledge base but for now the CurrencyNotFoundError
will be raised.
from currency_codes import get_currency_by_code, CurrencyNotFoundError
# non-existent currency code
currency_code: str = "EUR000"
try:
get_currency_by_code(currency_code)
except CurrencyNotFoundError:
print("Non-existent code have been used")
Get a currency info by a currency numeric code
To get a currency info you can also use the numeric code like in the example below
from currency_codes import get_currency_by_numeric_code, Currency
# Euro has 978 numeric code
currency_numeric_code: str = "978"
currency: Currency = get_currency_by_numeric_code(currency_numeric_code)
if the package doesn't know a currency numeric code you can raise a PR to extend the knowledge base but for now the CurrencyNotFoundError
will be raised.
from currency_codes import get_currency_by_numeric_code, CurrencyNotFoundError
# non-existent currency numeric code
currency_numeric_code: str = "00000000"
try:
get_currency_by_numeric_code(currency_numeric_code)
except CurrencyNotFoundError:
print("Non-existent numeric code have been used")
Get the list of all currencies
If you want to get information about all currencies, you can use get_all_currencies
function
from currency_codes import get_all_currencies, Currency
currencies: list[Currency] = get_all_currencies()
Get the list of fiat currencies
If you want to get information only about fiat currencies, you can use get_fiat_currencies
function
from currency_codes import get_fiat_currencies, Currency
fiat_currencies: list[Currency] = get_fiat_currencies()
Get the list of crypto currencies
If you want to get information only about crypto currencies, you can use get_crypto_currencies
function
from currency_codes import get_crypto_currencies, Currency
crypto_currencies: list[Currency] = get_crypto_currencies()
Get the list of commodity currencies
If you want to get information only about commodity currencies, you can use get_commodity_currencies
function
from currency_codes import get_commodity_currencies, Currency
commodity_currencies: list[Currency] = get_commodity_currencies()
Get the list of other currencies
If you want to get information only about other currencies, you can use get_other_currencies
function
from currency_codes import get_other_currencies, Currency
other_currencies: list[Currency] = get_other_currencies()
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
Hashes for currency_codes-23.4.23-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a6a1b8727965c70c0db0f34abb163c7f59b7b7714bdc6f3e1a43ec1ce8de682 |
|
MD5 | 0bea82c7b5a9ee26a3617e497440fdad |
|
BLAKE2b-256 | 8838919124ee0465d25bcec283f71b7fe34bb40043dc06f3d89e2e3617b73f64 |