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:

base
string
required

The base currency to get the latest exchange rates for, e.g GBP. It must be a currency code supported by AbstractAPI.

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

Usage

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

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

base
String

The base currency used to make the request

last_updated
Integer

A Unix timestamp of when the returned data was last updated

exchange_rates
Object

A JSON object of currencies supported by AbstractAPI and their rates. Response is limited if target currencies are specified in the request.

status
Integer

The status code of the response.

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:

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
}