> ## Documentation Index
> Fetch the complete documentation index at: https://rilwanorganization.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange API Overview

> Fast and lightweight currency exchange API

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

<CardGroup cols={2}>
  <Card title="Real-time exchange rates" icon="palette" href="essentials/exchange/live">
    Get real time exchange rates between multiple currencies
  </Card>

  <Card title="Convert currencies" icon="code" href="essentials/exchange/conversion">
    Covert one currency to another using a base amount. e.g 5 USD to GBP
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="Historical exchange rates" icon="code" href="essentials/exchange/historical">
    Get a detailed `JSON` object of past exchange rates within a specified peiod.
  </Card>
</CardGroup>

## Supported currency codes

AbstractAPI supports ISO 4217 currency codes which can be found [here](https://docs.abstractapi.com/exchange-rates#currency-codes-of-supported-currencies)

## Get currency codes programmatically

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

```python theme={null}
from abstract_python import EXCHANGE_SUPPORTED_CURRENCIES

print(EXCHANGE_SUPPORTED_CURRENCIES)
```

Here is the result below:

```python theme={null}
>>> [
    "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:

```python theme={null}
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](https://docs.abstractapi.com/exchange-rates#response-and-error-codes) for all possible error messages you may encounter while using the `ExchangeRatesAPI` class.
