Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

y-currency

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

y-currency

A module that enables fast and easy currency/ies conversion using the Yahoo Finance API.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-58.82%
Maintainers
1
Weekly downloads
 
Created
Source

Y-currency

Easy currency conversion and currency information retrieval using the Yahoo Finance API where the rates are updated every few minutes.

Installation:

npm install y-currency

Usage:

To convert currencies use the convert(amount,from,to,callback) function.

Example:

var currency = require('y-currency');

currency.convert(10, 'USD', 'EUR', function(err,converted){
    
    if (err){
        console.log(err);
    }

    console.log(converted);
});

Outputs the converted currency as a float: 8.81

It is also possible to convert multiple values at once by entering an array:

var currency = require('y-currency');

currency.convert([10, 81, 99, 20, 67, 19], 'USD', 'EUR', function(err,converted){
    
    if (err){
        console.log(err);
    }

    console.log(converted);
});

Outputs an array of converted floats: [8.93, 17.87, 26.80, 35.74, 44.67]


You can also get information about currency pairs by using getCurrency(pair,callback)

Example:

var currency = require('y-currency');

currency.getCurrency('USDEUR',function(err,response){

    if (err){
        console.log(err);
    }

    console.log(response);

});

Outputs an object:

 { id: 'USDEUR',
  Name: 'USD to EUR',
  Rate: '0.891',
  Date: '2/27/2015',
  Time: '10:56am',
  Ask: '0.891',
  Bid: '0.8909' }

You can also get multiple currency pairs by entering an array of pairs as so:

var currency = require('y-currency');

currency.getCurrency(['USDEUR','NZDCAD','SEKTHB'],function(err,response){

    if (err){
        console.log(err);
    }

    console.log(response);

});

Outputs an array of objects:

[ { id: 'USDEUR',
        Name: 'USD to EUR',
        Rate: '0.8935',
        Date: '2/27/2015',
        Time: '12:07pm',
        Ask: '0.8935',
        Bid: '0.8935' },
      { id: 'NZDCAD',
        Name: 'NZD to CAD',
        Rate: '0.9452',
        Date: '2/27/2015',
        Time: '12:07pm',
        Ask: '0.9455',
        Bid: '0.9449' },
      { id: 'THBSEK',
        Name: 'THB to SEK',
        Rate: '0.2587',
        Date: '2/27/2015',
        Time: '12:07pm',
        Ask: '0.2592',
        Bid: '0.2581' } ]

Keywords

FAQs

Package last updated on 03 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc