forex-promise

1.3.0 • Public • Published

Forex

Current and historical foreign exchange rates

Installation

npm

npm install forex-promise

yarn

yarn add forex-promise

Usage

Import module

const forex = require("forex-promise");

Latest

params

base: string | optional
symbols: string, array | optional

forex.latest();
forex.latest(base: "BRL")
forex.latest(base: "BRL", symbols: "JPY,BRL,NOK" || ["JPY","BRL","NOK"] )

Response

{
  "base": "BRL",
  "date": "2019-03-20",
  "rates": [
    { "currency": "JPY", "price": 29.440621222 },
    { "currency": "BRL", "price": 1 },
    { "currency": "NOK", "price": 2.253208407 },
    { "currency": "DKK", "price": 1.7349576862 },
    { "currency": "CNY", "price": 1.767274249 } ],
   ...
}

Date

forex.date("2019-01-01");

Response

{
  "base": "BRL",
  "date": "2019-01-01",
  "rates": [
    { "currency": "JPY", "price": 29.440621222 },
    { "currency": "BRL", "price": 1 },
    { "currency": "NOK", "price": 2.253208407 },
    { "currency": "DKK", "price": 1.7349576862 },
    { "currency": "CNY", "price": 1.767274249 } ],
   ...
}

History

params

dates: object | mandatory
base: string | optional
symbols: string, array | optional

forex.history({ start: "2018-01-01", end: "2018-09-01" });
 
forex.history({ start: "2018-01-01", end: "2018-09-01" }, base: "BRL");
 
forex.history({ start: "2018-01-01", end: "2018-09-01" }, base: "BRL", symbols: "JPY,BRL,NOK" || ["JPY","BRL","NOK"] );

Response

{
  "end_at": "2018-01-03",
  "base": "USD",
  "start_at": "2018-01-01",
  "rates": [
    {
      "date": "2018-01-02",
      "data": [
        { "currency": "JPY", "price": 29.440621222 },
        { "currency": "BRL", "price": 1 }
        ...
      ],
    }
    { "date": "2018-01-03",
      "data": [
        { "currency": "JPY", "price": 29.440621222 },
        { "currency": "BRL", "price": 1 }
        ...
      ]
    }
  ]
}

License

MIT

Package Sidebar

Install

npm i forex-promise

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

40 kB

Total Files

5

Last publish

Collaborators

  • weslei