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

crypto-prices-converter

v1.2.6

Published

Convert Crypto Prices To Real Currencies

Downloads

15

Readme

crypto-prices-converter

crypto-prices-converter is an npm package that provides a simple way to retrieve cryptocurrency prices and convert them into different fiat currencies. It supports various cryptocurrencies, including Bitcoin, Ethereum, Binance Coin (BNB), Ripple (XRP), and more. The package requires the currency names to be specified in the format of lowercase ISO 4217 currency codes (e.g., "usd" for United States Dollar).

Installation

To install crypto-prices-converter, use npm:

npm install crypto-prices-converter

Usage

To use the package, you need to require the crypto-prices-converter module:

const { convertCurrency, convertCrypto } = require("crypto-prices-converter");

The getCryptoPrice function allows you to retrieve the price of a cryptocurrency in a specific fiat currency. It takes two parameters: the cryptocurrency symbol and the fiat currency code. Here's an example:

console.log(getCryptoPrice("bitcoin", 2, "usd"));

The package provides two functions: convertCurrency and convertCrypto.

convertCurrency(currencyCode, quantity, cryptoName) This function converts a specified quantity of a cryptocurrency into the specified fiat currency. It takes three parameters: the target fiat currency code, the quantity of the cryptocurrency, and the name of the cryptocurrency. Here's an example:

const { convertCurrency } = require("crypto-prices-converter");

(async () => {
  try {
    const cryptoQuantity = await convertCurrency("usd", 2, "bitcoin");
    console.log(cryptoQuantity);
  } catch (err) {
    console.error(err);
  }
})();

This example converts 2 Bitcoins into US Dollars (USD) and logs the converted quantity to the console.

convertCrypto(cryptoName, quantity, currencyCode) This function converts a specified quantity of a cryptocurrency into the specified fiat currency. It takes three parameters: the name of the cryptocurrency, the quantity of the cryptocurrency, and the target fiat currency code. Here's an example:

const { convertCrypto } = require("crypto-prices-converter");

(async () => {
  try {
    const totalCryptoPrice = await convertCrypto("bitcoin", 2, "usd");
    console.log(totalCryptoPrice);
  } catch (err) {
    console.error(err);
  }
})();

This example calculates the total price of 2 Bitcoins in US Dollars (USD) and logs the result to the console.

All supported currencies:

  • AED: United Arab Emirates Dirham
  • ARS: Argentine Peso
  • AUD: Australian Dollar
  • BDT: Bangladeshi Taka
  • BHD: Bahraini Dinar
  • BMD: Bermudian Dollar
  • BRL: Brazilian Real
  • CAD: Canadian Dollar
  • CHF: Swiss Franc
  • CLP: Chilean Peso
  • CNY: Chinese Yuan
  • CZK: Czech Koruna
  • DKK: Danish Krone
  • EUR: Euro
  • GBP: British Pound Sterling
  • HKD: Hong Kong Dollar
  • HUF: Hungarian Forint
  • IDR: Indonesian Rupiah
  • INR: Indian Rupee
  • JPY: Japanese Yen
  • KRW: South Korean Won
  • KWD: Kuwaiti Dinar
  • LKR: Sri Lankan Rupee
  • MXN: Mexican Peso
  • MYR: Malaysian Ringgit
  • NGN: Nigerian Naira
  • NOK: Norwegian Krone
  • NZD: New Zealand Dollar
  • PHP: Philippine Peso
  • PKR: Pakistani Rupee
  • PLN: Polish Złoty
  • RUB: Russian Ruble
  • SAR: Saudi Riyal
  • SEK: Swedish Krona
  • SGD: Singapore Dollar
  • THB: Thai Baht
  • TRY: Turkish Lira
  • TWD: New Taiwan Dollar
  • UAH: Ukrainian Hryvnia
  • USD: United States Dollar
  • VEF: Venezuelan Bolívar
  • VND: Vietnamese Đồng
  • XAG: Silver Ounce
  • XAU: Gold Ounce
  • XDR: Special Drawing Rights (IMF

Repository

For more information and updates, you can visit the GitHub repository of crypto-prices-converter:

https://github.com/Mouizeddine/crypto-converter-library

Feel free to explore the repository, contribute, or submit any issues or feature requests.