npm.io
1.1.3 • Published 3 years ago

@cryptocodes/cryptomarket

Licence
ISC
Version
1.1.3
Deps
2
Size
8 kB
Vulns
23
Weekly
0

cryptocodes-cryptomarket

@cryptocodes-cryptomarket package provides cryptocurrency prices based on different markets

Available markets are USDT, USDC, BTC, ETH, BNB

Results

Result will be array of following object:

{ symbol: 'ETHBTC', price: '0.07673200' }

Sample Results

[ { symbol: 'ETHBTC', price: '0.07673200' },
{ symbol: 'LTCBTC', price: '0.00265000' },
{ symbol: 'BNBBTC', price: '0.01386600' },
{ symbol: 'NEOBTC', price: '0.00045800' },
{ symbol: 'QTUMETH', price: '0.00211900' },
{ symbol: 'EOSETH', price: '0.00108200' },
{ symbol: 'SNTETH', price: '0.00001754' },
{ symbol: 'BNTETH', price: '0.00029800' },
{ symbol: 'BCCBTC', price: '0.07908100' },
{ symbol: 'GASBTC', price: '0.00011970' } ]


Install

npm install @cryptocodes/cryptomarket

Usage

import market from @cryptocodes/cryptomarket

OR

const market = require("@cryptocodes/cryptomarket")

getMarket

getMarket gets array of crypto prices in specified Market.
This function returns Promise


Gets List of crypto prices in All markets

const allPrices = await market.getMarket();

OR

market
  .getMarket()
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });



Gets List of crypto prices in USDT market

const allPrices = market.getMarket("USDT");

OR

market
  .getMarket("USDT")
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });



Gets List of crypto prices in BTC market

const allPrices = market.getMarket("BTC");

OR

market
  .getMarket("BTC")
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });

Replace the market argument in market.getMarket with the one you need


getCoin

getCoin gets price of input Coin in specified Market.
This function returns Promise


Price of Coin LTC in Market USDT

const ltcPrices = await market.getCoin("LTC", "USDT");

OR

market
  .getCoin("LTC", "USDT")
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.log(error);
  });

Sample result for getCoin

{ symbol: 'LTCUSDT', price: '56.22000000' }

Issues

As this data is being fetch from Binance exchange at the moment, there may be a problem of connection in some countries.
In this case, uing proxy or VPN would be a soulotion

Keywords