Introduction
The Currencies API is used to convert from one currency to another and get exchange rates.
Currency rates are provided by XE and are updated on a daily basis. Rates are provided together with the timestamp when they were set. By using the Currencies API you agree to XE's Terms of Use.
The Currencies API provides these functions:
- Use
listCurrencies()
to get a list of all the convertible currencies. - Use
convertCurrency()
to convert amounts between two currencies. - Use
getConversionRate()
to get today’s conversion rate for a pair of currencies.
Before you begin
-
To use the Currencies API you must upgrade your site to a Premium Plan.
-
The currency converter changes the displayed prices on your site for different currencies but does not change the payment currency. The payment is always made in the currency set in your site's Dashboard.
-
The currency codes used must exist in the array of supported currencies returned by the
listCurrencies()
function.
Terminology
- XE. A currency converter provider that the Currencies API uses.
- Currency code: A 3-letter ISO-4217 code representing each currency.
Setup
To use the Currencies API, install the @wix/ecom
package using npm or Yarn:
1npm install @wix/ecom
or
1yarn add @wix/ecom
Then import { currencies }
from @wix/ecom
:
1import { currencies } from '@wix/ecom'
Returns an array of amounts converted from the original (from
) currency to the target (to
) currency and the timestamp for the conversion rate used.
Use the convertCurrency()
function to convert an array of one or more amounts between two currencies. The convertCurrency()
function returns an array of converted amounts and the timestamp for the conversion rate used.
Note: The currency codes used must exist in the array of supported currencies returned by the listCurrencies()
function.
Permission Scopes
For app development, you must have one of the following permission scopes:function convertCurrency(identifiers: ConvertCurrencyIdentifiers, amounts: Array<DecimalValue>): Promise<ConvertCurrencyResponse>
Identifying details needed to determine which currency rate to convert. The combination of the from and to properties together comprise the unique ID.
Amounts to convert.
Returns the conversion rate between 2 currencies.
Permission Scopes
For app development, you must have one of the following permission scopes:function getConversionRate(identifiers: GetConversionRateIdentifiers): Promise<ConversionRateResponse>
Identifying details needed to get the conversion rate. The combination of the from and to properties together comprise the unique ID.
Returns an array of currencies. The array lists all currencies for which Wix supports conversion and their symbols.
Permission Scopes
For app development, you must have one of the following permission scopes:function listCurrencies(): Promise<ListCurrenciesResponse>