2

hi i am trying to get the real time price of bitcoin using the coinbase api in the documentation it says it discourages polling of the price data so i was wandering if it is possible to get it from their web socket feed if so what channel and what value would it be. i have tried the ticker channel but it is not what i am looking for

enter image description here

this code works but i warns not to poll

function get_price() {
  const callback = (error, response, data) => {
    if(error){
      console.log(error);
    }else{
      xPrice = data.price;
    }
  };
  authedClient.getProductTicker(a2, callback);
}

enter image description here

here is the code to subscribe to the web socket feed

const websocket = new CoinbasePro.WebsocketClient(
  ["BTC-EUR"],
  "wss://ws-feed-public.sandbox.pro.coinbase.com",
  null,
  {
    channels: ['ticker']
  }
);

enter image description here