e-04-kencrypto v1.0.8
KenCrypto
Get the current quote and conversions of your favorite cryptos, based on the coinmarketcap api.
Description
First of all, you need to go to their website, sign in and get your personal key. Visit the Official Site.
Instalation
$ npm i e-04-kencrypto
or
$ yarn add e-04-kencrypto
How to use
import { KenCrypto } from "e-04-kencryto";
Create an instance:
const my_crypto = new KenCrypto(API_KEY)
-> Use your personal key that you got before.
That instance provides two methods:
quotes
Inside an array you can use an string with the crypto sign.
my_crypto.quotes(['BTC']);
The return is a promise where you can get the response with then()
example:
my_crypto.quotes(['BTC', 'eth']).then((response) => {
console.log(response)
});
log:
{
data: {
BTC: {
id: 1,
name: 'Bitcoin',
symbol: 'BTC',
slug: 'bitcoin',
date_added: '2013-04-28T00:00:00.000Z',
last_updated: '2022-01-27T20:23:00.000Z',
quote: {
USD: {
price: 36102.923873715255,
last_updated: '2022-01-27T20:23:00.000Z'
}
}
}
}
}
conversion
With the conversion method you can, obviously, convert currencies. For that you'll need three arguments: the amount to be converted, the origin currency, the target currency
my_crypto.conversion(1, 'BTC', ['BRL']);
--> The convertTo array can have multiple currencies, but it depends on your plan on Coin Market Cap.
Also the response is a promise where you can get the response with then()
example:
my_crypto.conversion(1, 'BTC', ['BRL']).then((response) => {
console.log(response);
});
log:
{
data: {
id: 1,
symbol: 'BTC',
name: 'Bitcoin',
amount: 1,
last_updated: '2022-01-27T22:02:00.000Z',
quote: {
BRL: {
price: 195481.12567089536,
last_updated: '2022-01-27T22:02:02.000Z'
}
}
}
}
Tecnologies
- TypeScript