OpenExchangeRates Data Connector

The OpenExchangeRates Data Connector provides acccess to the OpenExchangeRates API. The Data Connector provides functionality for retrieving current and historic exchange rates between currency pairs.

Constructor

OpenExchangeRates(appid) → {object}

We recommend that you create a Data Connector Configuration called "OpenExchangeRates" via the Verj.io Runtime Environment's Administration Application.

An OpenExchangeRates Data Connector is then available at connectors.verjio.openexchangerates using that configuration.

If you are unable to do that, you may use this constructor to create a new OpenExchangeRates Data Connector.

This method accepts an application ID for authentication.

Parameters:
Name Type Description
appid string

OpenExchangeRates application ID.

Returns:
object

The OpenExchangeRates Data Connector.

Functions

convert(value, from, to) → {float}

Convert between two currencies at latest exchange rates.

Parameters:
Name Type Description
value float

The value of the from currency to convert.

from string

The currency to convert from.

to string

The currency to convert to.

Returns:
float

The converted value in the to currency.

Example:
// A floating value such as 16.976533
var response = connectors.verjio.openexchangerates.convert(14.95, 'GBP', 'EUR');

historical(date, baseopt) → {OpenExchangeRates.ExchangeRates}

Retrieve historic exchange rates.

Parameters:
Name Type Attributes Default Description
date Date | string    

The date to retrieve exchanges rates for. This can be supplied as a string in the form YYYY-MM-dd or a JavaScript Date object.

base string <optional> USD

The base currency for exchange rates. All exchange rates retrieved will be relative to this currency.

Returns:
OpenExchangeRates.ExchangeRates

An object containing the historical exchange rates for the specified date.

Example:
var date = '2010-12-25';
var rates = connectors.verjio.openexchangerates.historical(date, 'GBP');
event.owner.addInfoMessage(`The GBP-USD conversion rate on ${date} was ${rates.USD}`);

latest(baseopt) → {OpenExchangeRates.ExchangeRates}

Retrieve the latest exchange rates.

Parameters:
Name Type Attributes Default Description
base string <optional> USD

The base currency for exchange rates. All exchange rates retrieved will be relative to this currency.

Returns:
OpenExchangeRates.ExchangeRates

An object containing the latest exchange rates.

Example:
var price = 1.99;
var rates = connectors.verjio.openexchangerates.latest('GBP');
var priceInUSD = rates.USD * price;

Type definitions

ExchangeRates

An object containing one or more exchange rates. The property key is a 3-character country code, e.g. {"USD": 1}

Properties:
Name Type Description
ABC float

Exchange rate for country with the code ABC.

Copyright Ebase Technology 2024