Xate can help you access different exchange rate APIs.
npm i xate
const Xate = require('xate')
// import Xate from 'xate'
const provider = 'ExchangeRateAPI'
const apiKey = '0a1b2c3d4e5f6g7h8i9j'
const xate = new Xate(provider, apiKey)
Xate(provider, api_key, base) constructor returns a new Xate instance.
| Parameter | Type | Necessity | Description | Default |
|---|---|---|---|---|
| provider | String | Required | API provider | ⸻ |
| api_key | String | Required | API key | ⸻ |
| base | String | Optional | Default base currency | USD |
Currencies object represents a list of currencies.
| Key | Value |
|---|---|
| Currency code | Currency name |
Rates object represents a list of exchange rates.
| Key | Value |
|---|---|
| Currency code | Currency exchange rate |
xate.requests() returns usage statistics.
| Property | Type | Description |
|---|---|---|
| made | Number | Number of requests made |
| left | Number | Number of requests left |
| days_until_renew | Number | Number of days until quota gets renewed |
xate.currencies() returns a list of supported currencies.
| Parameter | Type | Necessity | Description | Default |
|---|---|---|---|---|
| show_inactive | Boolean | Optional | Pass True to include historical/inactive currencies (OpenExchangeRates only) | False |
| show_alternative | Boolean | Optional | Pass True to extend returned values with alternative, black market, and digital currency rates (OpenExchangeRates only) | False |
xate.latest([ parameters ]) returns latest rates.
| Parameter | Type | Necessity | Description | Default |
|---|---|---|---|---|
| base | String | Optional | Base currency | USD |
| show_alternative | Boolean | Optional | Pass True to extend returned values with alternative, black market, and digital currency rates (OpenExchangeRates only) | False |
| Property | Type | Description |
|---|---|---|
| terms | String | Link to the terms of use |
| date | Number | Unix timestamp |
| base | String | Base currency |
| rates | Rates | Exchange rates |
xate.historical(date, [ parameters ]) returns historical rates for the requested date in YYYY-MM-DD format.
| Parameter | Type | Necessity | Description | Default |
|---|---|---|---|---|
| base | String | Optional | Base currency | USD |
| show_alternative | Boolean | Optional | Pass True to extend returned values with alternative, black market, and digital currency rates (OpenExchangeRates only) | False |
| Property | Type | Description |
|---|---|---|
| terms | String | Link to the terms of use |
| date | Number | Unix timestamp |
| base | String | Base currency |
| rates | Rates | Exchange rates |
Contributions are only allowed in TON:
UQCYqT9-ycmXE3o57Cac1sM5ntIKdjqIwP3kzWmiZik0VU_b