hcryptocvn
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

HCryptoCvn

A lib to get response of crypto value and conversions, based on the coinmarketcap api.

Description

To use the lib u gonna need the key that u can generate on the Official Site.

Instalation

$ npm install hcryptocvn

or

$ yarn add hcryptocvn

How to use

import { hCryptoCvn } from "hcryptocvn";

Create an instance:

const hcryptocvn = new hCryptoCvn(API_KEY)

With that instance u can use two methods:

  • quotes

Inside an array you can use an string with the crypto sign.

hcryptocvn.quotes(['BTC'])

The return is a promise where u can get the response with then()

example:

hcryptocvn.quotes(['BTC']).then((response) => 
  console.log(response)
});

response:

{
  "data": {
    "BTC": {
      "id": 1,
      "name": "Bitcoin",
      "symbol": "BTC",
      "slug": "bitcoin",
      "date_added": "2013-04-28T00:00:00.000Z",
      "last_updated": "2021-08-26T17:44:11.000Z",
      "quote": {
        "USD": {
          "price": 46963.215165006586,
          "last_updated": "2021-08-26T17:44:11.000Z"
        }
      }
    }
  }
}
  • conversion

The conversion receive 3 parameters: first parameter is the crypto sign to conversion, the second is the value of the conversion and e the third is an array with the signs to be converted.

hcryptocvn.conversion('BTC', 0.010, ['ETC'])

Also the response is a promise where u can get the response with then()

example:

hcryptocvn.conversion('BTC', 0.010, ['ETC']).then((response) => {
  console.log(response)
});

response:

{
  "data": {
    "id": 1,
    "symbol": "BTC",
    "name": "Bitcoin",
    "amount": 25.67,
    "last_updated": "2021-08-26T18:30:17.000Z",
    "quote": {
      "ETH": {
        "price": 386.5352847529818,
        "last_updated": "2021-08-26T18:30:16.000Z"
      }
    }
  }
}

Technologies

-TypeScript

Readme

Keywords

none

Package Sidebar

Install

npm i hcryptocvn

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

24.1 kB

Total Files

14

Last publish

Collaborators

  • hirokz7