e04-kencrypto-lucasbrasil
v1.0.4
Published
Biblioteca com o objetivo de analisar os valores das criptomoedas e fazer a taxa de conversão entre elas.
Downloads
11
Readme
KenCrypto
Biblioteca com o objetivo de analisar os valores das criptomoedas e fazer a taxa de conversão entre elas.
Para utilizar a biblioteca faça a seguinte importação:
import { KenCrypto } from "e04-kencrypto-lucasbrasil";
Configure o seu ambiente virtual para receber a variável API_KEY, que pode ser obtida em https://coinmarketcap.com/api/ e siga os passos abaixo para executar as funções.
Detalhes da cripto
Para obter os detalhes de uma ou mais criptos deve fazer os seguintes passos:
1 - Criar uma constante chamando os métodos da biblioteca:
const krypto = new KenCrypto()
2 - Utilizar a seguinte função para obter os detalhes da cripto escolhida
const quotes_data = krypto.quotes(["BTC"]).then((resp) => {
console.log(resp);})
Onde "BTC" é um exemplo de sigla da cripto.
Além disso, mais de um valor pode ser passado como parâmetro. Exemplo:
krypto.quotes(["BTC", "ETH"])
3 - Após executar a função, obterá a seguinte resposta no console:
{
BTC: {
id: 1,
name: 'Bitcoin',
symbol: 'BTC',
slug: 'bitcoin',
num_market_pairs: 9120,
date_added: '2013-04-28T00:00:00.000Z',
tags: [
'mineable',
'pow',
'sha-256',
'store-of-value',
'state-channel',
'coinbase-ventures-portfolio',
'three-arrows-capital-portfolio',
'polychain-capital-portfolio',
'binance-labs-portfolio',
'blockchain-capital-portfolio',
'boostvc-portfolio',
'cms-holdings-portfolio',
'dcg-portfolio',
'dragonfly-capital-portfolio',
'electric-capital-portfolio',
'fabric-ventures-portfolio',
'framework-ventures-portfolio',
'galaxy-digital-portfolio',
'huobi-capital-portfolio',
'alameda-research-portfolio',
'a16z-portfolio',
'1confirmation-portfolio',
'winklevoss-capital-portfolio',
'usv-portfolio',
'placeholder-ventures-portfolio',
'pantera-capital-portfolio',
'multicoin-capital-portfolio',
'paradigm-portfolio'
],
max_supply: 21000000,
circulating_supply: 18941768,
total_supply: 18941768,
is_active: 1,
platform: null,
cmc_rank: 1,
is_fiat: 0,
self_reported_circulating_supply: null,
self_reported_market_cap: null,
last_updated: '2022-01-28T03:40:00.000Z',
quote: { USD: [Object] }
}
}
Conversão de criptos
Para obter a conversão entre as criptos deve seguir os seguintes passos:
1 - Criar uma constante chamando os métodos da biblioteca:
const krypto = new KenCrypto()
2 - Utilizar a seguinte função para obter os detalhes da cripto escolhida
const conversion_data = krypto.conversion("BTC", 25.67, "ETH").then((resp) =>
console.log(resp);});
Onde "BTC" é a moeda a ser convertida, 25.67 é o valor a ser convertido e "ETH" é a moeda que o valor será convertido.
3 - Após executar a função, obterá a seguinte resposta no console:
{
"id": 1,
"symbol": "BTC",
"name": "Bitcoin",
"amount": 25.67,
"last_updated": "2022-01-28T03:41:00.000Z",
"quote": {
"ETH": {
"price": 392.1596270213585,
"last_updated": "2022-01-28T03:40:00.000Z"
}
}
}