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

@ittkm/exchangeratesapi

v1.0.6

Published

Client of https://exchangeratesapi.io/ with your free subscription plan. You can perform 'Source Currency Switching', 'Currency Conversion' and 'Time-Frame Queries' at no cost.

Downloads

23

Readme

Free client for exchangeratesapi.io

npm version npm downloads MIT License Build Status Coverage Status

This is client of Exchangerates API with your free subscription plan.
You can perform 'Source Currency Switching', 'Currency Conversion' and 'Time-Frame Queries' at no cost.

Exchangerates API ( https://exchangeratesapi.io/ ) became a registration system from April 2021, and the following functions can not be used without a paid subscription.

  • Source Currency Switching
  • Currency Conversion
  • Time-Frame Queries

With this package, you can get the same response as the paid function above with a free API key.

Installation

# via npm
npm install --save @ittkm/exchangeratesapi

# via yarn
yarn add @ittkm/exchangeratesapi

Usage

import exchangeratesapi from "@ittkm/exchangeratesapi";
// // or
// const exchangeratesapi = require("@ittkm/exchangeratesapi").default;

// Please get your API Access Key at https://exchangeratesapi.io/
// and then replace here
const API_KEY = "1234567890abcdefghijklmnopqrstuv";

async function exchangeratesapiSamples() {
  // Initialize with your API Key
  const api = new exchangeratesapi(API_KEY);

  // Call the API you want to run
  const exchangeRates = await api.latest();
  console.dir(exchangeRates);
}

Sample calls

Here are some examples:

/**
 * Latest Rates (with default settings)
 *  - Source Currency: EUR
 *  - Symbols: All symbols
 */
console.dir(await api.latest());

/**
 * Latest Rates (with Parameters)
 *  - Source Currency: USD
 *  - Symbols: GBP, JPY, EUR
 */
const latestParameters = {
  base: "USD",
  symbols: ["GBP", "JPY", "EUR"],
};
console.dir(await api.latest(latestParameters));

/**
 * Historical Rates (with default settings)
 *  - Get latest rates
 *  - Source Currency: EUR
 *  - Symbols: All symbols
 */
console.dir(await api.historical({}));

/**
 * Historical Rates (with Parameters)
 *  - Date: 2013-12-24
 *  - Source Currency: GBP
 *  - Symbols: USD, CAD, EUR
 */
const historicalParameters = {
  date: "2013-12-24",
  base: "GBP",
  symbols: ["USD", "CAD", "EUR"],
};
console.dir(await api.historical(historicalParameters));

/**
 * Convert (use latest rates)
 *  - Convert from GBP to JPY
 *  - amount: 25
 */
console.dir(
  await api.convert({
    from: "GBP",
    to: "JPY",
    amount: 25,
  })
);

/**
 * Convert (use historical rates)
 *  - Convert from GBP to JPY
 *  - amount: 25
 *  - Date: 2018-02-22
 */
const convertParameters = {
  from: "GBP",
  to: "JPY",
  amount: 25,
  date: "2018-02-22",
};
console.dir(await api.convert(convertParameters));

/**
 * Time-Series (with minimum options)
 *  - Symbols: All symbols
 */
console.dir(
  await api.timeseries({
    start_date: "2012-05-01",
    end_date: "2012-05-03",
  })
);

/**
 * Time-Series (with limit currencies)
 *  - Source Currency: EUR
 *  - Symbols: USD, AUD, CAD
 */
const timeseriesParameters = {
  start_date: "2012-05-01",
  end_date: "2012-05-03",
  base: "EUR",
  symbols: ["USD", "AUD", "CAD"],
};
console.dir(await api.timeseries(timeseriesParameters));

Response

The format of the response is compatible with the original Exchangerates API.

See the official documentation for details.

Examples

After having cloned this repository, run the following commands:

# Please define your API Access Key on the '.env' file
cp .env.example .env
vi .env

# Initialize the example project
cd example/ && npm install

# Excecute example
npm run import-sample
# # or
# npm run require-sample

License

This library is licensed under the MIT License.