Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ecb-euro-exchange-rates

qqilihq33kMIT4.0.0TypeScript support: included

Retrieve Euro foreign exchange reference rates from the European Central Bank

euro, currency, rates, ecb, typescript

readme

Euro Exchange Rates by ECB

Actions Status codecov npm version

Retrieve Euro foreign exchange reference rates from an API provided by the European Central Bank. This module is intended to run on the server via Node.js, not in the browser.

The API provides exchange rates updated daily for the following currencies:

  • USD: US dollar
  • JPY: Japanese yen
  • BGN: Bulgarian lev
  • CZK: Czech koruna
  • DKK: Danish krone
  • GBP: Pound sterling
  • HUF: Hungarian forint
  • PLN: Polish zloty
  • RON: Romanian leu
  • SEK: Swedish krona
  • CHF: Swiss franc
  • ISK: Icelandic krona
  • NOK: Norwegian krone
  • HRK: Croatian kuna
  • RUB: Russian rouble
  • TRY: Turkish lira
  • AUD: Australian dollar
  • BRL: Brazilian real
  • CAD: Canadian dollar
  • CNY: Chinese yuan renminbi
  • HKD: Hong Kong dollar
  • IDR: Indonesian rupiah
  • ILS: Israeli shekel
  • INR: Indian rupee
  • KRW: South Korean won
  • MXN: Mexican peso
  • MYR: Malaysian ringgit
  • NZD: New Zealand dollar
  • PHP: Philippine piso
  • SGD: Singapore dollar
  • THB: Thai baht
  • ZAR: South African rand

Installation

$ yarn add ecb-euro-exchange-rates

Usage

TS typings are available and you’ll get auto-completion for the supported currencies.

import * as exchangeRates from 'ecb-euro-exchange-rates';

const result = await exchangeRates.fetch();
console.log('Last update: ' + result.time);
console.log('USD: ' + result.rates.USD);

Historic rates are available via fetchHistoric90d (fetches previous 90 days) and fetchHistoric (fetches all rates back to 1999).

Development

Use Volta.

Install NPM dependencies with yarn.

To execute the tests, run yarn test.

For the best development experience, make sure that your editor supports ESLint and EditorConfig.

Linting of code and commit message happens on commit via Husky.

Releasing to NPM

Commit all changes and run the following:

$ npm login
$ yarn version --<update_type>
$ npm publish

… where <update_type> is one of patch, minor, or major. This will update the package.json, and create a tagged Git commit with the version number.

Contributing

Pull requests are very welcome. Feel free to discuss bugs or new features by opening a new issue.


Copyright Philipp Katz, LineUpr GmbH, 2018 – 2024

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[4.0.0] - 2024-02-01

Changed

  • Require NodeJS 18
  • Use native fetch instead of axios library

Fixed

  • Update dependencies

3.0.0 – 2023-04-08

Changed

  • Require NodeJS 14
  • Replace xml2js with fast-xml-parser
  • Update dependencies and devDependencies

2.0.2 – 2022-07-14

Fixed

  • Update dependencies

2.0.1 – 2021-09-18

Fixed

  • Update dependencies

2.0.0 – 2020-03-31

Changed

  • Require NodeJS 10

1.1.1 - 2018-10-26

Fixed

  • Fixes previous release, which didn’t contain the built files

1.1.0 - 2018-10-26

Added

  • This CHANGELOG file
  • Allow querying for historical data using fetchHistoric and fetchHistoric90d