Basic pusher connection to cryptsy using javascript

0 votes

I am trying to create a basic pusher connection to cryptsy. Since I am receiving public data such as 'price', I should 'not' have to authenticate, only providing the cryptsy APP_KEY. The following code fails:

<script src="pusher.min.js">
var pusher = new Pusher('cb65d0a7a72cd94adf1f');
var channel = pusher.subscribe('ticker.160');
channel.bind('new-price', function(data) {
  alert('An event was triggered with message: ' + data.message);
});
channel.bind('pusher:subscription_error', function(status) {
  if(status == 408 || status == 503){
    // retry?
  }
});
</script>

How do I make this work?

Sep 11, 2018 in Blockchain by digger
• 26,680 points
112 views

1 answer to this question.

0 votes

Try this

<script src="//js.pusher.com/2.2/pusher.min.js" type="text/javascript"></script>
<script type="text/javascript">
var pusher = new Pusher("cb65d0a7a72cd94adf1f");
var channel = pusher.subscribe("ticker.160");
channel.bind("message", function(data) {
  //console.log(data);
  var topbuy = data.trade.topbuy;
  console.log("Price: ", topbuy.price,
              "Quantity:", topbuy.quantity);
});
</script>
answered Sep 11, 2018 by slayer
• 29,300 points

Related Questions In Blockchain

–1 vote
1 answer

How to get balance of all accounts in ethereum network using javascript?

You can write a function that will ...READ MORE

answered Jan 9, 2019 in Blockchain by Omkar
• 69,030 points
396 views
+1 vote
3 answers

Is it possible to store data about arbitrary objects on the blockchain using smart contracts?

Consider following tutorial from Hyperledger Fabric "Getting Started" pages. Basically ...READ MORE

answered Aug 30, 2018 in Blockchain by Artem
283 views
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,620 points
326 views
0 votes
1 answer

Connection failed to Ethereum Ropsten Testnet network.

 It looks like your node isn't syncing ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,810 points
562 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,680 points
20,288 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
231 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
434 views
+1 vote
4 answers

How to connect peers to a private network using geth?

Follow the below steps to connect peers ...READ MORE

answered Jul 13, 2018 in Blockchain by slayer
• 29,300 points
3,734 views
0 votes
1 answer

How to call external data using smart contracts?

Smart contracts can not directly call external ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,300 points
214 views