A simple Python CLI application for converting any of multiple currencies to a specified target with generated results, including conversion total sum and individual amounts and exchange rates, being up-to-date approximate estimates.
Includes all ISO-supported and unsupported digital, crypto, and optional custom currencies.
ISO-supported currency information is available at ExchangeRate-API: Supported Currencies.
The following unsupported currencies are included using fixed exchange rates* to a supported currency:
Code | Currency Name | Country/State | Fixed Exchange Rate |
---|---|---|---|
ABK |
Abkhazian Apsar | Abkhazia | 1 ABX = 10 RUB |
EHP |
Sahrawi Peseta | Western Sahara | 1 EHP = 0.00601 EUR |
EUZ |
EuroUžas | Republic of Užupis | 1 EUZ = 5 EUR |
KPW |
North Korean Won | North Korea | 1 KPW = 0.000125 USD |
MLS ** |
Maltese Scudo | Sovereign Military Order of Malta | 1 Maltese Scudo = 0.24 EUR |
ORA ** |
Ora | Orania | 1 ORA = 1 ZAR |
PND |
Pitkern Ailen Dollar | Pitcairn Islands | 1 PND = 1 NZD |
PRB |
Transnistrian Ruble | Transnistria | 1 PRB = 0.06135 USD |
SLE |
Somaliland Shilling | Somaliland | 1 SLE = 0.000125 USD |
*The accuracy of fixed exchange rates cannot be confirmed and can be subject to change.
**Fabricated currency codes when none otherwise exist for application-specific indexing purposes.
There are 14,911
cryptocurrencies supported by CoinGecko API,
with the following included in this app by default:
Code | Currency Name |
---|---|
BTC |
Bitcoin |
ETH |
Ethereum |
BNB |
Binancecoin |
XRP |
Ripple |
ADA |
Cardano |
SOL |
Solana |
DOT |
Polkadot |
DOGE |
Dogecoin |
LTC |
Litecoin |
LINK |
Chainlink |
To optionally include more cryptocurrencies, following these Add Custom Currency Instructions.
- Python (developed with
v3.12.4
) - Python-Pip (developed with
v24.0
) - API key (available at Free ExchangeRate API Key)
Pip libraries required to run the app listed in the requirements.txt
file can be installed executing the command:
pip install -r requirements.txt
An API key is required to fetch digital currency data from the ExchangeRate-API.
A key can be set for application use by either creating an environment variable named EXCHANGE_RATE_API_KEY
with
the key entered as the value, or replace the empty string with it hardcoded to the source code, as in the example:
CURRENCY_EXCHANGE_RATE_API_KEY: str = getenv(
"EXCHANGE_RATE_API_KEY", ""
) # add API key as environment variable or replace the empty string.
CURRENCY_EXCHANGE_RATE_API_KEY: str = getenv(
"EXCHANGE_RATE_API_KEY", "85b6a40bda2db784e803da02"
) # add API key as environment variable or replace the empty string.
To convert from any currency, an amount
value above the default 0
is first required to be entered before running the application.
There is no CLI command for this, it must be completed manually as follows by editing either of the currencies.json
or
cryptos.json
files for entering amount values to given digital currencies and cryptocurrencies, respectively.
For any given currency JSON object, enter a digital value representative of the amount in the currency wanting to be
converted to the amount
variable, such as in the following example when editing a value of 0.01 GBP
:
{
"currencies": [
...
{
"currency-code": "GBP",
"currency-name": "Pound Sterling",
"nation-name": "United Kingdom",
"amount": 0,
"alt-currency": {}
},
...
]
}
{
"currencies": [
...
{
"currency-code": "GBP",
"currency-name": "Pound Sterling",
"nation-name": "United Kingdom",
"amount": 0.01,
"alt-currency": {}
},
...
]
}
It seems more efficient to manually edit the amount
values rather than multiple CLI commands per currency.
Use the keyboard shortcut CTRL-F
to quick-search for a currency in a JSON file when entering an amount
.
Any currency not included by default can be added following these instructions:
An ISO-supported currency is simpler to add than an unsupported currency as the alt-currency
variable can be excluded
from editing and left empty. Scroll to the bottom of the currencies.json
file and enter a custom digital currency,
such as in the following example for New Zealand Dollar
, although already entered, where the amount is 0
by default, but any value can be entered:
{
"currencies": [
...
{
"currency-code": "NZL",
"currency-name": "New Zealand Dollar",
"nation-name": "New Zealand",
"amount": 0,
"alt-currency": {}
}
]
}
For an ISO-unsupported currency to effectively be included for conversion, it must have a fixed exchange rate with
either an ISO-supported currency or cryptocurrency listed in the currencies.json
or cryptos.json
files, respectively, to be valid.
A fixed-exchange-rate
value can be entered to the alt-currency
variable JSON body, such as in the following example
for Fictional Unsupported Currency
with a fixed-conversion-rate
of 100000000000000 ZWL
and
where the amount
is 0
by default, but any value can be entered:
{
"currencies": [
...
{
"currency-code": "FUC",
"currency-name": "Fictional Unsupported Currency",
"nation-name": "Fictional Unsupported Currency Imaginary Party Nation",
"amount": 0,
"alt-currency": {
"currency-code": "ZWL",
"currency-name": "Fictional Unsupported Currency (fixed at 1 FUC = 100000000000000 ZWL)",
"fixed-conversion-rate": 100000000000000
}
}
]
}
Entering a custom cryptocurrency is simpler than a digital currency as only the currency-code
and currency-name
are
required in addition to the amount
variable. Scroll to the bottom of the cryptos.json
file and enter a custom
cryptocurrency, such as in the following example for 01coin
where the amount
is 0
by default, but any value can be entered:
{
"currencies": [
...
{
"currency-code": "ZOC",
"currency-name": "01coin",
"amount": 0
}
]
}
A custom cryptocurrency code must be supported by the CoinGecko API to be valid
To run the app for converting currency amount(s) to a given base currency, execute the following command:
python currency_converter.py
Follow CLI user prompt instructions to enter a valid base currency for generating converted amount(s).
A base currency must be listed in either of the
currencies.json
orcryptos.json
files to be valid