Get the current quote and conversions of your favorite cryptos, based on the coinmarketcap api.
First of all, you need to go to their website, sign in and get your personal key. Visit the Official Site.
$ npm i e-04-kencrypto
$ yarn add e-04-kencrypto
import { KenCrypto } from "e-04-kencryto";
const my_crypto = new KenCrypto(API_KEY)
-> Use your personal key that you got before.
- 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'
}
}
}
}
- TypeScript