Bitcoin Forum
May 12, 2024, 08:25:31 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help with Blockchain.info WebSocket API  (Read 2930 times)
cyrano741 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
July 24, 2013, 12:12:46 AM
 #1

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
"If you don't want people to know you're a scumbag then don't be a scumbag." -- margaritahuyan
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715502331
Hero Member
*
Offline Offline

Posts: 1715502331

View Profile Personal Message (Offline)

Ignore
1715502331
Reply with quote  #2

1715502331
Report to moderator
1715502331
Hero Member
*
Offline Offline

Posts: 1715502331

View Profile Personal Message (Offline)

Ignore
1715502331
Reply with quote  #2

1715502331
Report to moderator
1715502331
Hero Member
*
Offline Offline

Posts: 1715502331

View Profile Personal Message (Offline)

Ignore
1715502331
Reply with quote  #2

1715502331
Report to moderator
cyrano741 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
July 24, 2013, 12:22:25 AM
 #2

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"}');
      }
biteasy
Newbie
*
Offline Offline

Activity: 55
Merit: 0


View Profile WWW
March 16, 2014, 02:15:37 AM
 #3

If you are still working on this maybe you can check out our Websockets API as well:
https://www.biteasy.com/developers
xenoky
Member
**
Offline Offline

Activity: 99
Merit: 20


View Profile
June 11, 2014, 03:58:59 PM
 #4

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!
dadugan
Full Member
***
Offline Offline

Activity: 179
Merit: 100


View Profile
June 11, 2014, 04:19:59 PM
 #5

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!