Exchange Rates Service

Reference page for the Exchange Rates Service Interface

Interface

interface IExchangeRatesService {
  getExchangeRate(params: ExchangeRatesServiceRequest): Promise<ExchangeRatesServiceResponse>;
}

Structures used

ExchangeRatesServiceRequest

Field NameType
baseCurrencyCurrency
targetCurrencyCurrency

ExchangeRatesServiceResponse

Field NameType
exchangeRatenumber

Service Methods

getExchangeRate

Overview

This method allows you to get a conversion rate by giving a base currency and a target currency.

Usage
Typescript
import getunblockSDK, { Currency } from "@getunblock/sdk";

(async () => {
  // setup SDK
  const sdk = getunblockSDK({
    apiKey:
      "API-Key [Some merchant Key]", // Key generated at the moment the merchant was created in getunblock system
    prod: false, // If true Production environment will be used otherwise Sandbox will be used instead
  });
  
  // SDK API call example
  const result = await sdk.exchangeRates.getExchangeRate({
    baseCurrency: Currency.USD,
    targetCurrency: Currency.EURO,
  });
})();
Javascript
const getunblockSDK = require("@getunblock/sdk").default;
const { Currency } = require("@getunblock/sdk");

(async () => {
  // setup SDK
  const sdk = getunblockSDK({
    apiKey:
      "API-Key [Some merchant Key]", // Key generated at the moment the merchant was created in getunblock system
    prod: false, // If true Production environment will be used otherwise Sandbox will be used instead
  });
  
  // SDK API call example
  const result = await sdk.exchangeRates.getExchangeRate({
    baseCurrency: Currency.USD,
    targetCurrency: Currency.EURO,
  });
})();