UNPKG

bitcloutprice

Version:
38 lines (25 loc) 966 B
const fetch = require('node-fetch') const formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2 }) const get = async () => { const date = new Date().toISOString(); const cloutprice = await fetch('https://api.bitclout.com/get-exchange-rate') const bitprice = await fetch('https://blockchain.info/ticker') const bitpricejson = (await bitprice.json()) const jsonprice = (await cloutprice.json()) const thirdprice = (`${bitpricejson.USD.last}`)/// 100000 / jsonprice.SatoshisPerBitCloutExchangeRate const fourthprice = thirdprice / 100000000 const fithprice = fourthprice * jsonprice.SatoshisPerBitCloutExchangeRate const bitcloutfinal = await formatter.format(fithprice) return { price: fithprice, dollar: bitcloutfinal, date: date, }; } module.exports = { get };