All Projects → me-io → Node Currency Swap

me-io / Node Currency Swap

Licence: mit
Currency Exchange Rates library for nodejs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Currency Swap

arbolito
A currency conversion api for the minimalist developer
Stars: ✭ 50 (-57.98%)
Mutual labels:  rate, currencies
Laravel Likeable
Rate Eloquent models with Likes and Dislikes in Laravel. Development moved to Laravel Love package!
Stars: ✭ 95 (-20.17%)
Mutual labels:  rate
Rpinteraction
Review page interaction - handy and pretty way to ask for review.
Stars: ✭ 26 (-78.15%)
Mutual labels:  rate
Oxr
💱 Node.js wrapper for the Open Exchange Rates API
Stars: ✭ 72 (-39.5%)
Mutual labels:  currencies
Money bot
Docker-containered bot. Added to a group chat, she replies to any message containing price and currency pattern. Live!
Stars: ✭ 8 (-93.28%)
Mutual labels:  currencies
Redisratelimiter
Redis Based API Access Rate Limiter
Stars: ✭ 80 (-32.77%)
Mutual labels:  rate
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (+473.11%)
Mutual labels:  rate
Moeda
💰 📈 A foreign exchange rates and currency conversion using CLI
Stars: ✭ 113 (-5.04%)
Mutual labels:  rate
Movie Recommender System
Basic Movie Recommendation Web Application using user-item collaborative filtering.
Stars: ✭ 85 (-28.57%)
Mutual labels:  rate
Tggstarevaluationview
星星评价视图控件
Stars: ✭ 66 (-44.54%)
Mutual labels:  rate
Laravel Reactions
Laravel reactions package for implementing reactions (eg: like, dislike, love, emotion, etc) on Eloquent models.
Stars: ✭ 58 (-51.26%)
Mutual labels:  rate
Livecoin Api
LiveCoin RESTful API wrapper for Node.js
Stars: ✭ 12 (-89.92%)
Mutual labels:  currencies
Countries
Countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external links/files/data, NO interface{}, NO specific dependencies, Databases/JSON/GOB/XML/CSV compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.
Stars: ✭ 85 (-28.57%)
Mutual labels:  currencies
Gocurrency
Simple currency converter. Insert an amount, what currency to convert from and what currency to convert to.
Stars: ✭ 26 (-78.15%)
Mutual labels:  currencies
Javamoney Lib
JavaMoney financial libraries, extending and complementing JSR 354
Stars: ✭ 104 (-12.61%)
Mutual labels:  currencies
Laravel Love
Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?
Stars: ✭ 822 (+590.76%)
Mutual labels:  rate
Cldr
Internationalize your application using Unicode's CLDR
Stars: ✭ 38 (-68.07%)
Mutual labels:  currencies
Apprater Dialog
A dialog which asks the user to rate the app
Stars: ✭ 77 (-35.29%)
Mutual labels:  rate
Androidrate
AndroidRate is a library to help you promote your Android app by prompting users to rate the app after using it for a few days.
Stars: ✭ 117 (-1.68%)
Mutual labels:  rate
Currency
Handles currency calculations, storage etc
Stars: ✭ 109 (-8.4%)
Mutual labels:  currencies

Build Status

node-currency-swap

Currency Exchange Rates library for nodejs

Installation

npm install @meio/node-currency-swap

Usage

First, you need to add a provider to swap by using addProvider() method

var swap = require('node-currency-swap');

// Add the google finance provider
swap.addProvider(new swap.providers.GoogleFinance());

You can also add multiple providers

var swap = require('node-currency-swap');

// Add the google finance provider
swap.addProvider(new swap.providers.GoogleFinance());

// Add the yahoo finance provider with request timeout option in ms
swap.addProvider(new swap.providers.YahooFinance({timeout: 2000}));

swap.providers

To get the list of all providers

// Returns the list of providers
swap.providers;

quote(options, callback)

To retrieve the latest exchange rate for a currency pair asynchronously.

Arguments

  • options - An object to specify options for quote. For complete list refer Options Section.
  • callback(err, rate) - A callback which returns error on any failure or rate array on success.

quoteSync(options)

To retrieve the latest exchange rate for a currency pair synchronously.

Arguments

  • options - An object to specify options for quote. For complete list refer Options Section.

Examples

// if there is single provider in the list it fetch the rate from that provider but if there are multiple provider in the list it fetch the rate from first available one.
swap.quote({currency: 'USD/SAR'}, function (err, rate) {
// print the exchange rate
console.log(rate[0].value);

// print the date from the provider
console.log(rate[0].date);

// print the provider name
console.log(rate[0].provider);
});

Synchronously in case of any error it throws an error which you should handle through try/catch

// if there is single provider in the list it fetch the rate from that provider but if there are multiple provider in the list it fetch the rate from first available one.
var rate = swap.quoteSync({currency: 'USD/SAR'});

// print the exchange rate
console.log(rate[0].value);

// print the date from the provider
console.log(rate[0].date);

// print the provider name
console.log(rate[0].provider);

To fetch rate from all the added providers

var rates = swap.quoteSync({currency: 'USD/SAR', fetchMultipleRate: true});

rates.forEach(function(rate){
// print the exchange rate
console.log(rate.value);

// print the date from the provider
console.log(rate.date);

// print the provider name
console.log(rate.provider);

});

To fetch rate from cache if available if not it fetch the rate from provider and store in cache

var rates = swap.quoteSync({currency: 'USD/SAR', cache: true});

rates.forEach(function(rate){
// print the exchange rate
console.log(rate.value);

// print the date from the provider
console.log(rate.date);

// print the provider name
console.log(rate.provider);

});

Currencies are expressed as their ISO 4217 code.

swap.currencyCodes

Swap provides an object of currency codes so you can use it to avoid typos.

var rates = swap.quoteSync({
    currency: {
            baseCurrency: swap.currencyCodes.ISO_USD,
            quoteCurrency: swap.currencyCodes.ISO_AED
        }
    });

Options

  • currency - currency info to get exchange rate either as string USD/AED or as object {baseCurrency:'USD', quoteCurrency:'AED'}.
  • fetchMultipleRate - if true, fetch rate from all the added providers. (default: false)
  • cache - if true, it tries to fetch rate from cache if available otherwise fetch rate from added provider and store it in cache. (default: false)
  • ttl - time in ms to retain rate in cache. (default: 360000) 1 hour

Providers

// options.timeout in ms (optional) To set request timeout default (default: 3000ms)
swap.addProvider(new swap.providers.EuropeanCentralBank(options));
  • Google Finance Supports multiple currencies as base and quote currencies.
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.GoogleFinance(options));
  • Open Exchange Rates Supports only USD as base currency for the free version and multiple ones for the enterprise version.
// options.appId (required) API key from open exchange rates
// options.enterprise (optional) true in case you have enterprise account (default: false)
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.OpenExchangeRates(options));
  • Xignite You must have access to the XigniteGlobalCurrencies API. Supports multiple currencies as base and quote currencies.
// options.token (required) API token from Xignite
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.Xignite(options));
  • Yahoo Finance Supports multiple currencies as base and quote currencies.
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.YahooFinance(options));
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.NationalBankOfRomania(options));
  • Currency Layer Supports multiple currencies as base and quote currencies.
// options.accessKey (required) API access key from Currency Layer.
// options.timeout in ms (optional) To set request timeout (default: 3000ms)
swap.addProvider(new swap.providers.CurrencyLayer(options));

Credits

node-currency-swap is designed to be a simple and universal exchange rate library with support for multiple providers. This library is heavily inspired from PHP Swap

License

The code is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].