<p>Heres how I do it in <code>node.js</code></p>

<pre><code>var events = require('events');
var io = require('socket.io-client');

var MTGOX = function(){
    var self = this;
    var socket = io.connect('https://socketio.mtgox.com/mtgox');   

    socket.on('message', function(data){

        var message = data;

        if( message.private == "depth"){
            self.emit('depth', data.depth);    
        } else if( message.private == "ticker" ){
            self.emit('ticker', data.ticker);
        } else if( message.private == "trade" ){
            self.emit('trade', data.trade);
        }

    });
};

MTGOX.prototype.__proto__ = events.EventEmitter.prototype;
</code></pre>

<p>and then I just listen to the <code>depth</code> event. Also I found <a href="https://github.com/programmarchy/node-mtgox-websocket-client" rel="nofollow">this project</a> helpful when I was first figuring this out.</p>

CC BY-SA 3.0
2013-07-17T15:45:37.630Z
2013-07-17T15:45:37.630Z
Loourr
<p>In Java, you can use the <a href="https://github.com/timmolter/XChange" rel="nofollow">XChange</a> library which provides this and other data through a unified API for a range of exchanges.</p>

CC BY-SA 3.0
2013-07-17T18:34:46.433Z
2013-07-17T18:34:46.433Z
Gary
<p>I want to subscribe to market depth updates using the streaming API <a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming" rel="nofollow">https://en.bitcoin.it/wiki/MtGox/API/Streaming</a>. I want to receive only depth updates for a particular symbol (EUR for example) or for all symbols.  So I connect to wss://websocket.mtgox.com and send the command</p>

<pre><code>{
     "type": "depth",
     "op": "mtgox.subscribe" 
}
</code></pre>

<p>I'm expecting to receive depth updates for all symbols. But it sends me updates only for BTCUSD. Though the same subscribe command with parameter "type" = "trades" sends trades for all symbols (not only BTCUSD). That's a little confusing.</p>

<p>The currency parameter is mentioned in API documentation: websocket.mtgox.com:80/mtgox?Currency=EUR, but after connecting to this websocket I receive ticker updates as well. But I don't need ticker updates.</p>

<p>The question is how can I receive only market depth updates for particular symbol? (or all of symbols)</p>

<mtgox><api>
Subscribe for market depth updates using Mt.Gox streaming API
sergeyz
# Subscribe for market depth updates using Mt.Gox streaming API

(Asked by: username_0 on 2013-07-17)

I want to subscribe to market depth updates using the streaming API https://en.bitcoin.it/wiki/MtGox/API/Streaming. I want to receive only depth updates for a particular symbol (EUR for example) or for all symbols.  So I connect to wss://websocket.mtgox.com and send the command
{
     "type": "depth",
     "op": "mtgox.subscribe" 
}

I'm expecting to receive depth updates for all symbols. But it sends me updates only for BTCUSD. Though the same subscribe command with parameter "type" = "trades" sends trades for all symbols (not only BTCUSD). That's a little confusing.
The currency parameter is mentioned in API documentation: websocket.mtgox.com:80/mtgox?Currency=EUR, but after connecting to this websocket I receive ticker updates as well. But I don't need ticker updates.
The question is how can I receive only market depth updates for particular symbol? (or all of symbols)

**Tags:** mtgox, api


---

## 2 answers

### Answer by username_1 on 2013-07-17. Score: 1

Heres how I do it in node.js
var events = require('events');
var io = require('socket.io-client');

var MTGOX = function(){
    var self = this;
    var socket = io.connect('https://socketio.mtgox.com/mtgox');   

    socket.on('message', function(data){

        var message = data;

        if( message.private == "depth"){
            self.emit('depth', data.depth);    
        } else if( message.private == "ticker" ){
            self.emit('ticker', data.ticker);
        } else if( message.private == "trade" ){
            self.emit('trade', data.trade);
        }

    });
};

MTGOX.prototype.__proto__ = events.EventEmitter.prototype;

and then I just listen to the depth event. Also I found this project helpful when I was first figuring this out.


---

### Answer by username_2 on 2013-07-17. Score: 0

In Java, you can use the [XChange](https://github.com/timmolter/XChange) library which provides this and other data through a unified API for a range of exchanges.


---

