abstract_api.exchange_rates.exchange_rates module#

class abstract_api.exchange_rates.exchange_rates.ExchangeRates(api_key: str | None = None)[source]#

Bases: BaseService

AbstractAPI exchange rates service.

Used to looking up the latest exchange rates for 80+ currencies, getting historical exchange rates, and converting an arbitrary amount from one currency to another.

Attributes:

_subdomain: Exchange rates service subdomain.

convert(base: str, target: str, date: str | None = None, base_amount: float | None = None) ExchangeRatesConversionResponse[source]#

Converts amount of money from base currency to target currency/ies.

Args:
base: Base currency used to get the latest exchange rate(s) for.

Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).

target: The target currency to convert the base_amount to.

Like the base parameters, any currency passed here follows the ISO 4217 standard. Note that unlike the other endpoints, convert only accepts one target currency at a time.

date: The historical date you’d like to get rates from, in the

format of YYYY-MM-DD. If you leave this blank, it will use the latest available rate.

base_amount: The amount of the base currency you would like to

convert to the target currency.

Returns:

ExchangeRatesConversionResponse representing API call response.

historical(base: str, date: str, target: Iterable[str] | None = None) HistoricalExchangeRatesResponse[source]#

Finds historical exchange rates from base to target currencies.

Args:
base: Base currency used to get the latest exchange rate(s) for.

Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).

date: The historical date you’d like to get rates from, in the

format of YYYY-MM-DD.

target: The target currency or currencies to get the exchange rate

of versus the base currency. Like the base parameters, any currency passed here follows the ISO 4217 standard.

Returns:

HistoricalExchangeRatesResponse representing API call response.

live(base: str, target: Iterable[str] | None = None) LiveExchangeRatesResponse[source]#

Finds exchange rates from base currency to target currency/ies.

Args:
base: Base currency used to get the latest exchange rate(s) for.

Uses the ISO 4217 currency standard (e.g., USD for United States Dollars).

target: The target currency or currencies to get the exchange rate

of versus the base currency. Like the base parameters, any currency passed here follows the ISO 4217 standard.

Returns:

VATValidationResponse representing API call response.