API call to update live price for text element

Hey, I am looking to call an external API for live prices. To be specific - I’d like to have a text element that updates Bitcoin’s live price. For example:

const https = require('https');

var options = {
  "method": "GET",
  "hostname": "rest.coinapi.io",
  "path": "/v1/exchangerate/BTC/USD",
  "headers": {'X-CoinAPI-Key': '73034021-THIS-IS-SAMPLE-KEY'}
};

var request = https.request(options, function (response) {
  var chunks = [];
  response.on("data", function (chunk) {
    chunks.push(chunk);
  });
});

request.end();

This API call would return a JSON structured like this:

{
  "time": "2017-08-09T14:31:18.3150000Z",
  "asset_id_base": "BTC",
  "asset_id_quote": "USD",
  "rate": 3260.3514321215056208129867667
}

Is there a way to display the rate as a text element in webflow? I’ve been searching for a solution for a while. If anybody knows a shortcut or can provide me with a learning material I would really appreciate it.

Forum is not a good place to teach programming nor do I have the time. So I will refer you to one of the excellent resources available at the Mozilla Developer Network.

1 Like