exchange.js
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

exchange.js

exchange.js is a Node.js currencies (and in future cryptocurrencies) converter.

npm version install size GitHub GitHub last commit


Disclaimer

This package makes use of puppeteer to scrape the data from www.google.com.
This package is not affiliated with Google in any way and it should not be used for commercial purposes, but only for educational purposes.
The author of this package is not responsible for any damage caused by the use of this package.

Installation

npm install exchange.js

Loading the module

exchange.js supports both CommonJS and ESM.

ESM / Typescript (Recommended)

import { convert } from 'exchange.js';

CommonJS

const { convert } = require('exchange.js');

Usage

convert()

import { convert } from 'exchange.js';

// convert(from: string (Currency type), to: string (Currency type), amount: number) => Promise<number>
convert('USD', 'EUR', 10).then((result) => {
    console.log(result); // This will log the value of 10 USD in EUR
});

convertCrypto()

import { convertCrypto } from 'exchange.js';

// convertCrypto(from: string (Currency type), to: string (Currency type), amount: number) => Promise<number>
convertCrypto('BTC', 'ETH', 10).then((result) => {
    console.log(result); // This will log the value of 10 BTC in ETH
});

Supported currencies / cryptocurrencies

import { supportedCurrencies, supportedCryptoCurrencies } from 'exchange.js';

console.log(supportedCurrencies);
// This will log an array of supported currencies

console.log(supportedCryptoCurrencies);
// This will log an array of supported cryptocurrencies

Typescript support (TS only)

import { Currency } from 'exchange.js';

const currency1: Currency = 'USD';
const currency2: Currency = 'EUR';

convert(currency1, currency2, 10).then((result) => {
    console.log(result); // This will log the value of 10 USD in EUR
});

License

MIT

Package Sidebar

Install

npm i exchange.js

Weekly Downloads

8

Version

2.0.0

License

MIT

Unpacked Size

23.3 kB

Total Files

15

Last publish

Collaborators

  • alessandrofoglia07