-1

I am making a discord bot using discord.js, and I want to add a command that allows users to see the current bitcoin price. I am using the CoinDesk API and the data I need is contained in the JSON file located at this link: https://api.coindesk.com/v1/bpi/currentprice/BTC.json

I am somewhat new to JavaScript, and I have tried tutorials on web scraping and data handling to no prevail. I know I need to pull the data from 'bpi' > 'USD' > 'rate', but I do not know how to do so. I would greatly appreciate tips on what to use, not so much the exact code I need to write. I am not looking for anyone to solve this problem for me, I just need to be pointed in the right direction.

Caleb Suhy
  • 61
  • 7
  • You might want to refer to this issue: [https://stackoverflow.com/questions/11225001/reading-a-file-in-real-time-using-node-js](https://stackoverflow.com/questions/11225001/reading-a-file-in-real-time-using-node-js) – Adlan Arif Zakaria Oct 02 '18 at 02:31

1 Answers1

0

They have an API you can use to get price data. Here's a curl request to get it.

curl https://api.coinbase.com/v2/prices/spot?currency=USD

will return {"data":{"base":"BTC","currency":"USD","amount":"6573.63"}}

here is a link to their develop page: https://developers.coinbase.com/docs/wallet/guides/price-data

Nick Brady
  • 6,084
  • 1
  • 46
  • 71