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

@abskmj/exchangeratesapi

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abskmj/exchangeratesapi

Node client for exchangeratesapi.io

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-14.29%
Maintainers
1
Weekly downloads
 
Created
Source

npm (scoped) NPM npm

Node client for exchangeratesapi.io

Unofficial node.js client for exchangeratesapi.io

Exchange rates API is a free service for current and historical foreign exchange rates published by the European Central Bank

Installation

NPM Registry

npm install --save @abskmj/exchangeratesapi

Github Package

This module is also available at Github Package

Examples

Get all the rates on current date

let exchange = require('@abskmj/exchangeratesapi')

const getLatestRates = async () => {
    const response = await exchange.rates()

    console.log(response.data)

    /*
      {
        rates: {
          CAD: 1.5243,
          HKD: 8.4286,
          ISK: 158.3,
          ...
        },
        base: 'EUR',
        date: '2020-05-13'
      }
    */
}

Get the rates on a date

let exchange = require('@abskmj/exchangeratesapi')

const getRatesByDate = async (date) => {
  const response = await exchange.rates({ date })

  console.log(response.data)

  /*
    {
      rates: {
        CAD: 1.4959,
        HKD: 11.2301,
        LVL: 0.7093,
        ...
      },
      base: 'EUR',
      date: '2010-01-12'
    }
  */
}

Get the rates of a base currency

let exchange = require('@abskmj/exchangeratesapi')

const getLatestRatesForBaseCurrency = async(base) => {
  const response = await exchange.rates({ base })

  console.log(response.data)

  /*
    {
      rates: {
        CAD: 1.4016551724,
        HKD: 7.7504367816,
        ISK: 145.5632183908,
        ...
      },
      base: 'USD',
      date: '2020-05-13'
    }
  */
}

Get specific rates of a base currency

let exchange = require('@abskmj/exchangeratesapi')

const getLatestRatesForCurrencies = async (symbols) => {
  const response = await exchange.rates({ symbols })

  console.log(response.data)

  /*
    {
      rates: { USD: 1.0875, GBP: 0.88245 },
      base: 'EUR',
      date: '2020-05-13'
    }
  */
}

Get historical rates

let exchange = require('@abskmj/exchangeratesapi')

const getHistoricalRates = async(start_at, end_at) => {
  const response = await exchange.history({ start_at, end_at})

  console.log(response.data)
}

Works with Promises and Callbacks

// promise
exchange().then(response =>{
    console.log(response.data);
});

// callback
exchange({}, (err, response) => {
    if(err) return console.error(err)

    console.log(response.data)
})

API Documentation

Documentation is available at API.md

Changelog

Change log is available at CHANGELOG.md

Keywords

FAQs

Package last updated on 16 May 2020

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