abstract_api.exchange_rates package#

Submodules#

Module contents#

class abstract_api.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.

class abstract_api.exchange_rates.ExchangeRatesConversionResponse(response: Response, date_included_in_request: bool | None = False)[source]#

Bases: JSONResponse

Exchange rate conversion service response.

property base: str | None#

The base currency used to get the exchange rates.

property base_amount: float | None#

The amount of the base currency from the request.

property converted_amount: float | None#

The amount after conversion.

The amount of the target currency that the base_amount has been converted into.

property date: str | None#

The date the currencies were pulled from.

This is per successful request and returned only when ‘date’ parameter is passed in request. This is mutually-exclusive with ‘last_updated’ in response.

property exchange_rate: float | None#

The exchange rate used in conversion.

property last_updated: int | None#

The Unix timestamp of when the returned data was last updated.

This is returned if ‘date’ parameter was not passed in request. This is mutually-exclusive with ‘date’ in response.

property target: str | None#

The target currency that the base_amount was converted into.

class abstract_api.exchange_rates.HistoricalExchangeRatesResponse(response: Response)[source]#

Bases: MultipleExchangeRatesResponse

Historical exchange rates service response.

property date: str | None#

The date the currencies were pulled from.

This is per successful request.

class abstract_api.exchange_rates.LiveExchangeRatesResponse(response: Response)[source]#

Bases: MultipleExchangeRatesResponse

Live exchange rates service response.

property last_updated: int | None#

The Unix timestamp of when the returned data was last updated.