Skip to content

Websocket

martin-nginio edited this page May 27, 2019 · 3 revisions

Note: this version of the WebSocket is being deprecated. Please refer to V2 for the latest documentation.

BTC Markets provides real-time public market as well as account related trading events using websocket.

Public market events

endpoint: https://socket.btcmarkets.net

sample code in node.js in order to receive tick events

var socket = require('socket.io-client')('https://socket.btcmarkets.net', {secure: true, transports: ['websocket'], upgrade: false});
var instrument = 'BTC';
var currency = 'AUD';
var eventName = 'newTicker'; 
var channelName = 'Ticker-BTCMarkets-' + instrument + "-" + currency;

socket.on('connect', function(){
	console.log('connected');
	socket.emit('join', channelName);
});

socket.on(eventName, function(data){
    console.log(data);
});

socket.on('disconnect', function(){
	console.log('disconnected');
});

sample tick event received via websocket

{ volume24h: 56524541285,
  bestBid: 287602000000,
  bestAsk: 288817000000,
  lastPrice: 287602000000,
  timestamp: 1500349863621,
  currency: 'AUD',
  instrument: 'BTC' }

orderbook events

Use the following channel name and event name in order to receive orderbook events

var instrument = 'BTC';
var currency = 'AUD';
var eventName = 'OrderBookChange';
var channelName = 'Orderbook_' + instrument + currency;

trade events

Use the following channel name and event name in order to receive trade events

var instrument = 'BTC';
var currency = 'AUD';
var eventName = 'MarketTrade';
var channelName = 'TRADE_' + instrument + currency; 

Account related Events

coming soon

Introduction updated 9/28/18

Authentication

Pagination

WebSocket v2

WebSocket v1 deprecated

Market Data API updated 7/24/19

Trading API updated 08/19/19

Transaction API

Account API updated 3/14/19

Fund Transfer API updated 08/06/19

FAQ

Clone this wiki locally