New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

currency-restapi-currencylayer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

currency-restapi-currencylayer

nodejs wrapper for currencylayer restful api

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by28.57%
Maintainers
1
Weekly downloads
 
Created
Source

This is a Nodejs wrapper of currencylayer restful api for currency-rates-store. You need to have an account in currencylayer.com

Example - instantiate the method directly

const live = require('currency-restapi-currencylayer').Live('YOUR_ACCESS_KEY');
const inspect = require('util').inspect;

live((err, rates) {
  
  if (err) return console.error(inspect(err, {colors: true}));
  console.log(inspect(rates, {colors: true}));
});

Example - instantiate the api

const currlayer = require('currency-restapi-currencylayer')('YOUR_ACCESS_KEY');
const inspect = require('util').inspect;


// check 1 month ago rates
var d = new Date(Date.now() - 1000*60*60*24*30);  
currlayer.historical(d, (err, rates)=>{

  if (err) return console.error(inspect(err, {colors: true}));
  console.log(inspect(rates, {colors: true}));
})

Options to instantiate the API

  • <String>|<Object>
    • accessKey: YOUR_ACCESS_KEY
    • currencies: <Array>|<String>, e.g. ['USD','GBP','EUR']
    • source: the exchange rates base, default to USD

If options is a string, it means YOUR_ACCESS_KEY.

More info, see Documentation

currlayer.live(cb)

This is what currency-rates-store bot need, CurrencyRatesStore will use this api to refresh exchange rates.

callback will receive exchange rates like following

{
  base: 'USD|EUR|GBP'   - tell which currency this rates is based on
  rates: {
    USD: 1,             
    GBP: ...
    EUR: ...
    ...
  },
  ts: {Milliseconds}
}

currlayer.historical(date, cb)

  • date: <DateString>|<Timestamp in milliseonds>|<Date object>

currlayer.list(cb)

Keywords

FAQs

Package last updated on 17 Apr 2016

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