The Exchange Rates API can be used to get real time exchange rates, past/historical rates, and perform quick currency conversion betwwen multiple currencies. It supports over 80+ currencies. In abstract-python, the ExchangeRatesAPI class is used to communicate with this API.

API Endpoints

Supported currency codes

AbstractAPI supports ISO 4217 currency codes which can be found here

Get currency codes programmatically

With abstract-python you can get the supported currency codes as a Python List. See usage below:

from abstract_python import EXCHANGE_SUPPORTED_CURRENCIES

print(EXCHANGE_SUPPORTED_CURRENCIES)

Here is the result below:

>>> [
    "ARS", "AUD", "BCH", "BGN", "BNB", "BRL", "BTC", "CAD", "CHF", "CNY", 
    "CYP", "CZK", "DKK", "DOGE", "DZD", "EEK", "ETH", "EUR", "GBP", "GRD", 
    "HKD", "HRK", "HUF", "IDR", "ILS", "INR", "ISK", "JPY", "KRW", "LTC", 
    "LTL", "LVL", "MAD", "MTL", "MXN", "MYR", "NOK", "NZD", "PHP", "PLN", 
    "RON", "RUB", "SEK", "SGD", "SIT", "SKK", "THB", "TRY", "TWD", "USD", 
    "XRP", "ZAR"
    ]

Use case

If your app receives currency codes from users, you may need to validate these inputs before querying the ExchangeRatesAPI class.

See usage below:

from abstract_python import EXCHANGE_SUPPORTED_CURRENCIES

base_currency = input("Enter a currency code")

if base_currency in EXCHANGE_SUPPORTED_CURRENCIES:
    # continue with the app logic 
else:
    print(f"{base_currency} is not a supported currency code")

The code above is a simple console-based program. This technique can also be extended to other programs such as a web app or desktop app.

Error messages

Refer to this page for all possible error messages you may encounter while using the ExchangeRatesAPI class.