1.0.3 • Published 4 years ago

api24-currencyrate v1.0.3

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

Currency-Rate

If you need any information about our webservice Please visit Currency Rate Official Documentation

Currency Rate API Documentation (Farsi)

If you need latest rate of currencies in Iran in your application, you can easily use our webservice.

For more information and check other products check our WebSite

Installation

npm i api24-currencyrate

If you don't have npm you can easily install it from npm website

Usage

Well, There is three examples to get Data from the service:

Get List of All Rates

const { CurrencyRate } = require("api24-currencyrate");
const cr = new CurrencyRate("YOUR_API_KEY");

// Get List of Rates
const prices = await cr.rates(); // Result in Array
console.log("Prices in Array", prices);

/*
Output:
[
  Rate {
    title: 'USD',
    price: 10000,
    measure: 'TOMAN',
    date: undefined
  },
  Rate {
    title: 'EUR',
    price: 10000,
    measure: 'TOMAN',
    date: undefined
  },
  ....
]
*/

Get a Single Rate

const { CurrencyRate } = require("api24-currencyrate");
const cr = new CurrencyRate("YOUR_API_KEY");

// Get a Single Rate
const rateUSD = await cr.rates({ currency: "USD" });
const rateUSD_price = rateUSD.price;
console.log("Single USD Rate", rateUSD, rateUSD_price);

/*
Output:
  Rate {
    title: 'USD',
    price: 10000,
    measure: 'TOMAN',
    date: undefined
  }
*/

Convert Rates

const { CurrencyRate } = require("api24-currencyrate");
const cr = new CurrencyRate("YOUR_API_KEY");

// Convert Rates
const amount = 100;
const convertResult = await cr.convert(amount, "USD", "Toman");
console.log("Convert Result", convertResult);

/*
Output should be float
*/

وب سرویس نرخ ارز