npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

exchange-rates-rba

v1.2.0

Published

Retrieve daily foreign exchange rates for USD, EUR, and more from the Reserve Bank of Australia.

Downloads

18

Readme

exchange-rates-rba

Get currency exchange rates from the Reserve Bank of Australia

Retrieves exchange rates from the Reserve Bank of Australia's exchange rate datasets. Base currency is always AUD.

All datasets are cached after being downloaded for quick retrieval, and each dataset covers multiple years. Exchange rate data goes back to December 1983. A maximum of 11 datasets will be downloaded, totalling about 6MB. Datasets are only downloaded as needed, so you will likely only ever download one dataset (each dataset covers 3 - 4 years).

Some currencies are not available through the entire 1983 – current datasets, double check RBA datasets for if the specified currency is available throughout the required period. USD is available for the entire dataset period, excluding non-business days.

Install

npm install exchange-rates-rba

Usage

import getExchangeRate from 'exchange-rates-rba';

await getExchangeRate('USD', new Date(2023, 1, 22));
//=> 0.6789

await getExchangeRate('JPY', new Date(2017, 1, 1), { defaultToClosestPriorRate: true });
//=> 128.12

await getExchangeRate('USD', new Date(2023, 0, 1);
// => 0.6929

await getExchangeRate('USD', new Date(2023, 0, 1), { defaultToNull: true });
// => null

API

getExchangeRate(currency, date, options?)

Returns a Promise that resolves to the currency's exchange rate with AUD.

If an exchange rate is not available on a given date, the closest exchange rate after the date will be provided. If there is a gap of greater than 7 days between the closest exchange rate and the date provided, null will be returned.

See below options to instead provide the closest rate before the date, or return null if no rate is available on the given date.

currency

Type: string

Must be one of the following currency codes:

USD, TWI, CNY, JPY, EUR, KRW, GBP, SGD, INR, THB, NZD, TWD, MYR, IDR, VND, AED, PGK, HKD, CAD, ZAR, CHF, PHP, SDR

TWI is the trade-weighted index.

date

Type: Date object

Date to retrieve exchange rate for.

options

Type: object

defaultToClosestPriorRate

Type: boolean
Default: false

If no exchange rate is available for the given date, the closest available rate prior to the given date will be provided.

defaultToNull

Type: boolean
Default: false

If no exchange rate is available for the given date, null will be returned.