README
Table of Contents
- Installing
- Example usage with "async-await" construct:
- Example usage with ".then" construct:
- API Used
- License
Installing
npm i crypto-values
Example usage with "async-await" construct:
To pull all data
const cryptoValues = require('crypto-values');
const allData = async () => {
let Data = await cryptoValues('bitcoin');
console.log(Data);
};
allData();
/*{
name: 'Bitcoin',
genesisDate: '03.01.2009',
updated: '22.06.2021 20:10:18',
marketDataUpdated: '22.06.2021 20:10:18',
id: 'bitcoin',
symbol: 'btc',
price: { usd: 32477, try: 281064, eur: 27213, gbp: 23297 },
price_changein24h: { usd: 269.75, try: -1299.039861928206, eur: 190.63, gbp: 166.63 },
athPrice: { usd: 64805, try: 525937, eur: 54205, gbp: 47095 },
highestPrice_in24h: { usd: 33179, try: 291642, eur: 27854, gbp: 23842 },
lowestPrice_in24h: { usd: 29155, try: 253739, eur: 24498, gbp: 20985 },
categories: [ 'Cryptocurrency' ]
}*/
If you want to pull certain data
const cryptoValues = require('crypto-values');
const ethereumData = async () => {
let Data = await cryptoValues('ethereum');
console.log(`
Ethereum Symbol: ${Data.symbol}
Ethereum Price for USD: ${Data.price.usd}
Ethereum Categories: ${Data.categories.join(', ')}
`);
};
ethereumData();
/* Output:
Ethereum Symbol: eth
Ethereum Price for USD: 1911.42
Ethereum Categories: Smart Contract Platform
*/
Example usage with ".then" construct:
To pull all data
const cryptoValues = require('crypto-values');
cryptoValues('bitcoin').then(res => {
console.log(res)
})
/*{
name: 'Bitcoin',
genesisDate: '03.01.2009',
updated: '22.06.2021 20:10:18',
marketDataUpdated: '22.06.2021 20:10:18',
id: 'bitcoin',
symbol: 'btc',
price: { usd: 32477, try: 281064, eur: 27213, gbp: 23297 },
price_changein24h: { usd: 269.75, try: -1299.039861928206, eur: 190.63, gbp: 166.63 },
athPrice: { usd: 64805, try: 525937, eur: 54205, gbp: 47095 },
highestPrice_in24h: { usd: 33179, try: 291642, eur: 27854, gbp: 23842 },
lowestPrice_in24h: { usd: 29155, try: 253739, eur: 24498, gbp: 20985 },
categories: [ 'Cryptocurrency' ]
}*/
If you want to pull certain data
const cryptoValues = require('crypto-values');
cryptoValues("ethereum").then(res => {
console.log(`
Ethereum Symbol: ${res.symbol}
Ethereum Price for USD: ${res.price.usd}
Ethereum Categories: ${res.categories.join(', ')}
`)
})
/* Output:
Ethereum Symbol: eth
Ethereum Price for USD: 1911.42
Ethereum Categories: Smart Contract Platform
*/
API Used
- coingecko.com