n0mad01 / node.bittrex.api

No longer maintained
MIT License
183 stars 189 forks source link

Ticket for a single market #39

Open AndrewKralovec opened 7 years ago

AndrewKralovec commented 7 years ago

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);
        });
      });
    }
  });
ghost commented 7 years ago

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".

AndrewKralovec commented 7 years ago

@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);
      });
    }
  });
dparlevliet commented 7 years ago

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

arturovivas commented 6 years ago

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 ^^?

sguryev commented 6 years ago

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.