node.bittrex.api icon indicating copy to clipboard operation
node.bittrex.api copied to clipboard

Ticket for a single market

Open AndrewKralovec opened this issue 7 years ago • 5 comments

So I'm trying to figure out how to get the status (ticker) of a single market. I can do this via the public api by going to this url https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC. However, if i want a listen to the changes, like you do with the web socket, i don't see a way to do this. The code below listens to all the markets, I'm trying to just listen for BTC-LTC. Can this be done ?

  const web = bittrex.websockets.listen( function( data ) {
    if (data.M === 'updateSummaryState') {
      data.A.forEach(function(data_for) {
        data_for.Deltas.forEach(function(marketsDelta) {
          console.log('Ticker Update for '+ marketsDelta.MarketName, marketsDelta);
        });
      });
    }
  });

AndrewKralovec avatar Aug 08 '17 01:08 AndrewKralovec

You will have to connect using a websocket and then subscribe to the market you wanna listen to using the "SubscribeToExchangeDeltas" which will then update you whenever the orderbook or the trade history changes. The reply when you subscribe is "updateExchangeState".

ghost avatar Aug 08 '17 06:08 ghost

@Squeaky-bed Are you referring to the bittrex web sockets subscribe function? Because if you are that gives you the orders of the markets your are subscribing to. How do i subscribe to the response of that?

  // market orders
  const websocketsclient = bittrex.websockets.subscribe(['BTC-ETH','BTC-SC','BTC-ZEN'], function(data) {
    if (data.M === 'updateExchangeState') {
      data.A.forEach(function(data_for) {
        console.log('Market Update for '+ data_for.MarketName, data_for);
      });
    }
  });

AndrewKralovec avatar Aug 08 '17 12:08 AndrewKralovec

At this stage there is not a ticker via the WS, at least not that we've found and not that the Bittrex website currently uses themselves. They currently do polling of the Ticker API (see attached image). Mostly all of us use the subscribe function to build our own picture of the ticker in real-time, but I also poll the ticker every few seconds, too.

Their WS is a work in progress so perhaps this will be implemented eventually.

image

dparlevliet avatar Aug 08 '17 12:08 dparlevliet

Hi Guys, I just discovered this amazing api :-), and well I encountered the very same issue as Andrew. Are there any news regarding the ticker via WS? @dparlevliet would you mind showing the way how you use the subscribe function to build your own picture of the ticker in real-time ^^?

arturovivas avatar Dec 28 '17 13:12 arturovivas

Hi guys. Any news regarding the ticker building using the SubscribeToExchangeDeltas WebSocket? I would like to switch from the heavyweight API calls to the WebSockets and make some more available resources for anyone who needs it.

sguryev avatar May 24 '18 21:05 sguryev