Bitcoin Forum

Other => Beginners & Help => Topic started by: cyrano741 on July 24, 2013, 12:12:46 AM



Title: Help with Blockchain.info WebSocket API
Post by: cyrano741 on July 24, 2013, 12:12:46 AM
I am try to access the blockchain.info WebSocket API, but I can't get it to work. The connection opens, but then no messages are received. Can anyone give advice on what I'm doing wrong?

<html>
  <head>
    <script type="text/javascript">
      var conn = new WebSocket('ws://ws.blockchain.info/inv');
      conn.onopen = function () {
        console.log('open');
      }
      conn.onclose = function () {
        console.log('close');
      }
      conn.onerror = function (error) {
        console.log('websocket error: ' + error);
      }
      conn.onmessage = function (e) {
        console.log(e);
      }
    </script>
  </head>
  <body>
  </body>
</html>


The console output is:

open
close


Title: Re: Help with Blockchain.info WebSocket API
Post by: cyrano741 on July 24, 2013, 12:22:25 AM
My mistake; you have to send an op to the API. Correct code below for others' reference.


      var conn = new WebSocket('ws://ws.blockchain.info/inv');
      conn.onopen = function () {
        console.log('open');
        conn.send('{"op":"unconfirmed_sub"}');
      }


Title: Re: Help with Blockchain.info WebSocket API
Post by: biteasy on March 16, 2014, 02:15:37 AM
If you are still working on this maybe you can check out our Websockets API as well:
https://www.biteasy.com/developers


Title: Re: Help with Blockchain.info WebSocket API
Post by: xenoky on June 11, 2014, 03:58:59 PM
If you are still working on this maybe you can check out our Websockets API as well:
https://www.biteasy.com/developers

i was searching for this! Thanks!


Title: Re: Help with Blockchain.info WebSocket API
Post by: dadugan on June 11, 2014, 04:19:59 PM
If you are still working on this maybe you can check out our Websockets API as well:
https://www.biteasy.com/developers

Good reference for new developer out there.