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-converter-ken

v1.0.3

Published

<h2>Node application to convert crypto coins.</h2>

Downloads

3

Readme

Crypto Converter Kenzie

It creates a small library in Typescript that handles information about normal and crypto currencies and dealt conversion between coins.

Requirements

Node

Warning

Please, for more stability use node version 14 ou 16.

If you do not know which version you are using, type this on terminal:

$ node --version

If you do want to change your version of Node, type this on terminal:

$ nvm use 14
$ nvm use 16

To start

You are going to need an API key from Coin Market Cap.

  • Check the documentation of the used API HERE!

Installation

First, you need to install this lib. On terminal, at the root of your project, type:

$ npm i crypto-converter-ken

Create an .env file and insert the key you got at Coin Market Cap. Example:

API_KEY_COIN_MARKET = a0000000-000e-0d00-0c00-000cd00d00e0

Working

First, import KenCrypto to your file (e.g. app.js), like this:

import { KenCrypto } from "crypto-converter-ken";

Then, instance our lib into a variable, like this:

const ken = new KenCrypto();

Now you can use Quotes and Conversion

Examples:

  • It must bring the current quote data for the informed currency(s) comapred to USD (United States Dollar).
ken.quotes(["BTC"]).then((res) => console.log((res as IQuotes).data.BTC));

Output in console:

{
  id: 1,
  name: 'Bitcoin',
  symbol: 'BTC',
  slug: 'bitcoin',
  date_added: '2013-04-28T00:00:00.000Z',
  last_updated: '2022-01-28T02:43:00.000Z',
  quote: {
    USD: {
      price: 36837.90739073404,
      last_updated: '2022-01-28T02:43:00.000Z'
    }
  }
}

In the same example, you can use a variable too:

let quote_data = ken.quotes(["ETH"]).then((res) => console.log((res as IQuotes).data.ETH));

Output in console:

{
  id: 1027,
  name: 'Ethereum',
  symbol: 'ETH',
  slug: 'ethereum',
  date_added: '2015-08-07T00:00:00.000Z',
  last_updated: '2022-01-28T02:51:00.000Z',
  quote: {
    USD: {
      price: 2391.531036761025,
      last_updated: '2022-01-28T02:51:00.000Z'
    }
  }
}

If you want to use more than one currency:

ken.quotes(["BTC", "ETH"]).then((res) => console.log(res as IQuotes));

Output in console:

{
  data: {
    BTC: {
      id: 1,
      name: 'Bitcoin',
      symbol: 'BTC',
      slug: 'bitcoin',
      date_added: '2013-04-28T00:00:00.000Z',
      last_updated: '2022-01-28T02:55:00.000Z',
      quote: [Object]
    },
    ETH: {
      id: 1027,
      name: 'Ethereum',
      symbol: 'ETH',
      slug: 'ethereum',
      date_added: '2015-08-07T00:00:00.000Z',
      last_updated: '2022-01-28T02:55:00.000Z',
      quote: [Object]
    }
  }
}
  • It should bring the conversion values ​​between the desired currencies.

Convert between two crypto coins:

ken
  .conversion("BTC", 0.005, ["ETH"])
  .then((res) => console.log((res as IConversion).data.BTC));

Output in console:

{
    id: 1,
    symbol: 'BTC',
    name: 'Bitcoin',
    amount: 0.005,
    last_updated: '2022-01-28T02:22:00.000Z',
    quote: {
        ETH: {
        price: 0.07733428157310678,
        last_updated: '2022-01-28T02:21:00.000Z'
        }
    }
}

Convert between a crypto currency and a regular currency (like Great Britain Pound, GBP):

ken
  .conversion("BTC", 0.005, ["GBP"])
  .then((res) => console.log((res as IConversion).data.BTC));

Output in console:

{
  id: 1,
  symbol: 'BTC',
  name: 'Bitcoin',
  amount: 0.005,
  last_updated: '2022-01-28T03:02:00.000Z',
  quote: {
    GBP: {
      price: 137.89626528901127,
      last_updated: '2022-01-28T03:02:02.000Z'
    }
  }
}

THANK YOU VERY MUCH!