Superface

Exchange Rate

crypto/exchange-rate@1.0.1
1 provider

Get Exchange Rate

Get exchange rate between two currencies

Input
From
To
Result
Rate

1.Choose a provider

2.Use GetExchangeRate with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('crypto/exchange-rate@1.0.1');

  // Use the profile
  const result = await profile
    .getUseCase('GetExchangeRate')
    .perform({
      from: '',
      to: ''
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

from
Code of the source currency, e.g.: "ETH"
to
Code of the target currency, e.g.: "BTC"

Example

{
  "from": "",
  "to": ""
}

Result (object)

rate
Exchange rate, e.g.: "0.06249100"

Example

{
  "rate": ""
}

Implementation details

Provider
mock
Use case
GetExchangeRate
Author
@superface
Source
Verified