1.0.2 • Published 2 years ago

kencrypto-jotaftm v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Kencrypto

Kencrypto is a module to abstract the process of obtaining quotes and converting currencies using the CoinMarketCap database.

Install

yarn add kencrypto-jotaftm

or

npm install kencrypto-jotaftm

Usage

First, import the class:

import { Kencrypto } from "kencrypto-jotaftm";
// syntax ES6

Instantiate a new object through the class, providing your API key created at this address CoinMarketCap

const cmc = new Kencrypto('your-api-key');

Example of methods:

.quotes method:

// Checking the answer to offer suggestions for autocomplete.
cmc.quotes(['BTC']).then(resp => {
    if (resp !== undefined && !isError(resp)) {
        console.log(resp)
    }
})
/*
{
  data: {
    BTC: {
      id: 1,
      name: 'Bitcoin',
      symbol: 'BTC',
      slug: 'bitcoin',
      date_added: '2013-04-28T00:00:00.000Z',
      last_updated: '2022-01-24T22:03:00.000Z',
      quote: {
        USD: {
            price: 36785.23208507061,
            last_updated: '2022-01-24T22:05:00.000Z'
        }
      }
    }
  }
}
*/

.conversion method:

// Checking the answer to offer suggestions for autocomplete.
cmc.conversion('BTC', 1, ['USD']).then(resp => {
    if (resp !== undefined && !isError(resp)) {
        console.log(resp.data)
    }
})
/*
{
  data: {
    id: 1,
    symbol: 'BTC',
    name: 'Bitcoin',
    amount: 1,
    last_updated: '2022-01-24T22:29:00.000Z',
    quote: {
      USD: {
        price: 36650.72996891165,
        last_updated: '2022-01-24T22:30:00.000Z'
      }
    }
  }
}
*/