> ## 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.

# Live Exchange Rates.

> This endpoint is used to get the current rate for which a base currency exchanges with other currencies. For example, The rate for which **USD** exchanges for **CAD** or **BRL**

## Description

The `ExchangeRatesAPI.live()` method is used to communicate with this endpoint as seen below:

`ExchangeRatesAPI.live(base, Optional[target])`

## Query Parameters

Below are the query parameters for this method:

<ParamField path="base" type="string" required>
  The **base currency** to get the latest exchange rates for, e.g GBP.
  It must be a currency code supported by AbstractAPI.
</ParamField>

<ParamField path="target" type="string">
  The target currency or currencies that the **base currency** is converted into.
  A list of comma separated currency codes is also permitted, e.g "target=USD,CAD,BRL".
  This will limit the response data to the specified currency codes.
</ParamField>

## Usage

Below is a code snippet to query the `ExchangeRatesAPI.live()` method:

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

api_key = "your-exchange-rates-api-key"

api = ExchangeRatesAPI(api_key)
base = "GBP"
response = api.live(base)

print(response)

```

Below is the response object:

```
{
    'base': 'GBP', 
    'last_updated': 1726665300, 
    'exchange_rates': {
        'EUR': 1.191143, 
        'USD': 1.328839, 
        'JPY': 190.022989, 
        'BGN': 2.329637, 
        'CZK': 29.875049, 
        'DKK': 8.884971, 
        'HUF': 469.965338, 
        'PLN': 5.081176,
        'RON': 5.92522,
        'SEK': 13.480757, 
        'CHF': 1.126821, 
        'ISK': 181.649256, 
        'NOK': 13.898014, 
        'HRK': 8.497288, 
        'RUB': 140.714371, 
        'TRY': 45.21387, 
        'AUD': 1.947756, 
        'BRL': 7.175443, 
        'CAD': 1.799817, 
        'CNY': 9.38942, 
        'HKD': 10.357224, 
        'IDR': 20159.482091, 
        'ILS': 4.990769, 
        'INR': 111.163389, 
        'KRW': 1764.761235, 
        'MXN': 25.479733, 
        'MYR': 5.59444, 
        'NZD': 2.125594, 
        'PHP': 73.790097
    }, 
    'status': 200
}
```

## Response Fields

<ResponseField name="base" type="String">
  The base currency used to make the request
</ResponseField>

<ResponseField name="last_updated" type="Integer">
  A Unix timestamp of when the returned data was last updated
</ResponseField>

<ResponseField name="exchange_rates" type="Object">
  A JSON object of currencies supported by AbstractAPI and their rates. Response is limited if target currencies are specified in the request.
</ResponseField>

<ResponseField name="status" type="Integer">
  The status code of the response.
</ResponseField>

### Limit response data

You can limit the response data by specifying a comma-separated list of target currency codes in your query.\
Below is a code snippet to limit response data:

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

api_key = "your-exchange-rates-api-key"

api = ExchangeRatesAPI(api_key)
base = "GBP"
target = "USD,BRL,LTC"

# add "target" as a keyword argument
response = api.live(base, target)

print(response)

```

Below is the response object:

```
{
    'base': 'GBP', 
    'last_updated': 1726665300, 
    'exchange_rates': {
        'USD': 1.328839, 
        'BRL': 7.175443, 
        'LTC': 0.01834
    }, 
    'status': 200
}
```
