bitcoinaverage / api-integration-examples

Bitcoin and Ethereum price API integration examples in csharp, java, nodejs, golang, python, php and ruby
https://apiv2.bitcoinaverage.com/
63 stars 35 forks source link

Websocket API V2 #16

Open tomeroto opened 6 years ago

tomeroto commented 6 years ago

Hi all,

I try to use bitcoinaverage from NPM to using V2 method. When I call API for get ticket by this URL: https://apiv2.bitcoinaverage.com/websocket/v2/get_ticket

and set header according to this docs https://apiv2.bitcoinaverage.com/?shell#requests

but it just take response to long and get bad gateway.

I read some notes from the docs for V2, it says:

This is an integer value representing the unix epoch. This needs to be no more than 15 seconds different than our server time for the request to pass. This prevents replay attacks. If you wish to check our server time please use the "/constants/time" endpoint.

After I follow the instruction, and test run, it just get same response (BAD GATEWAY).

Please help.

KolevDarko commented 6 years ago

Hi @tomeroto We just published a new version 1.2.1 of our npm package: https://www.npmjs.com/package/bitcoinaverage There is an example on connecting to websocket v2 in the documentation on the same link. Basically you just need to use the new method: connectToTickerWebsocketV2.

Hope this helps and let us know if you run into any trouble.

Best regards, Darko, Lead developer at BitcoinAverage.

tomeroto commented 6 years ago

Hi @KolevDarko

Thank you for your response. I was update the package to version 1.2.1, but still get response below:

Error in BA response. Status Code: 502 body: <html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>

Do you have sample implementation or step to go with enterprise api key?

tachiba commented 5 years ago

Same here. Is there any update?

shaun-ba commented 5 years ago

@tachiba Did the steps in @KolevDarko 's post not work?

KolevDarko commented 5 years ago

Hey guys @tachiba @tomeroto , here is a full working example.

const ba = require('bitcoinaverage');
symbols = ['BTCUSD', 'ETHEUR'];
var pub = <public_key>
var secret = <secret_key>
function connect_ticker_v2(market, symbols) {
  var ws = ba.websocketClient(pub, secret);
  ws.connectToTickerWebsocketV2(market, symbols, function (response) {
        console.log("BTCUSD");
        console.log(response.data[market].BTCUSD);
        console.log("ETHEUR");
        console.log(response.data[market].ETHEUR);
      }, function (error) {
        console.log(error)
      },
      function () {
        console.log("Closed")
      }
  )
}
connect_ticker_v2('global', symbols);
KolevDarko commented 5 years ago

In the future you can also email us directly at: info@bitcoinaverage.com or create an Jira issue here: https://support.bitcoinaverage.com/servicedesk/customer/portal/1