<p>There are two ways you can do this.</p>

<p>1) MtGox Polling API V2. You call the <code>getFullDepth</code> to download the full orderbook. Then you call <code>getPartialDepth</code> for updates, replacing all the orders in your <code>master</code> order book. This method is not very efficient and you can only poll at a throttled pace. </p>

<p><a href="https://github.com/timmolter/XChange/blob/develop/xchange-examples/src/main/java/com/xeiam/xchange/examples/mtgox/v2/service/marketdata/polling/MtGoxOrderBookChartDemo.java" rel="nofollow">Here's a demo</a> from the XChange open source project for simply polling for the partial order book and creating an orderbook chart.</p>

<p>2) MtGox Polling API V2 + streaming. You call the <code>getFullDepth</code> to download the full orderbook. Then you use the streaming API to receive <code>depth</code> events and update your <code>master</code> order book accordingly. Depth updates with an amount of zero mean that the orders were cancelled or filled, i.e. they don't exist anymore and you can remove them. </p>

<p><a href="https://github.com/timmolter/XChange/blob/develop/xchange-examples/src/main/java/com/xeiam/xchange/examples/mtgox/v2/service/marketdata/streaming/MtGoxWebSocketSyncronizedOrderBookDemo.java" rel="nofollow">Here's a demo</a> from the XChange open source project.</p>

CC BY-SA 3.0
2013-08-21T19:11:27.233Z
2013-08-21T19:11:27.233Z
herrtim
<p>Your link to the "old version of the API" is actually going to the <a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming" rel="nofollow">streaming API</a> which is still available.  Only the http version was updated and from there it looks difficult to obtain accurate  depth info reliably for precise time periods.</p>

<p>So I'd stick with streaming. Updated much more in real-time for your requirements.</p>

<p>Now they deprecated the depth:volume field but they still have volume_int, which is volume change * 1E8, so you could obtain volume from that:</p>

<pre><code>//js for example
var volume = volume_int * Math.pow(10,-8);
</code></pre>

<p>Check out the github samples at the bottom of the wiki page to help get started.  <a href="https://github.com/ralphtheninja/goxstream/blob/master/index.js" rel="nofollow">For example, this one</a></p>

CC BY-SA 3.0
2013-08-16T15:10:05.607Z
2013-08-16T15:10:05.607Z
Neil Neyman
<p>I'm getting started with the mtgox api. I'm primarily using <a href="https://bitbucket.org/nitrous/mtgox-api/" rel="nofollow">this page</a> to tell me how to use it. </p>

<p>What I've currently got, is I can fetch the depth and then put the bids and asks into 'buckets' (each being a range of price), and can tell you the volume at each bucket. </p>

<p>Now what I want to be able to is keep this updated every second or so. </p>

<p>So I'd need to be keeping track of: </p>

<ul>
<li><p>Trades being made (ie Bids/Asks being met). </p></li>
<li><p>New Bids/Asks.  </p></li>
<li><p>Bids/Asks being cancelled.</p></li>
</ul>

<p>It appears as if the <a href="https://en.bitcoin.it/wiki/MtGox/API/Streaming#Depth" rel="nofollow">old version of the api</a> could show the net change at each volume, but this doesn't appear to be the case for the new version.</p>

<p>How would I go about doing this?</p>

<mtgox><api>
MtGox api - keeping track of bids/asks that get cancelled
user1068446
# MtGox api - keeping track of bids/asks that get cancelled

(Asked by: username_0 on 2013-08-09)

I'm getting started with the mtgox api. I'm primarily using [this page](https://bitbucket.org/nitrous/mtgox-api/) to tell me how to use it.

What I've currently got, is I can fetch the depth and then put the bids and asks into 'buckets' (each being a range of price), and can tell you the volume at each bucket.

Now what I want to be able to is keep this updated every second or so.

So I'd need to be keeping track of:

* Trades being made (ie Bids/Asks being met).
* New Bids/Asks.
* Bids/Asks being cancelled.

It appears as if the [old version of the api](https://en.bitcoin.it/wiki/MtGox/API/Streaming#Depth) could show the net change at each volume, but this doesn't appear to be the case for the new version.

How would I go about doing this?

**Tags:** mtgox, api


---

## 2 answers

### Answer by username_1 on 2013-08-21. Score: 1 | Accepted answer

There are two ways you can do this.

1) MtGox Polling API V2. You call the `getFullDepth` to download the full orderbook. Then you call `getPartialDepth` for updates, replacing all the orders in your `master` order book. This method is not very efficient and you can only poll at a throttled pace.

[Here's a demo](https://github.com/timmolter/XChange/blob/develop/xchange-examples/src/main/java/com/xeiam/xchange/examples/mtgox/v2/service/marketdata/polling/MtGoxOrderBookChartDemo.java) from the XChange open source project for simply polling for the partial order book and creating an orderbook chart.

2) MtGox Polling API V2 + streaming. You call the `getFullDepth` to download the full orderbook. Then you use the streaming API to receive `depth` events and update your `master` order book accordingly. Depth updates with an amount of zero mean that the orders were cancelled or filled, i.e. they don't exist anymore and you can remove them.

[Here's a demo](https://github.com/timmolter/XChange/blob/develop/xchange-examples/src/main/java/com/xeiam/xchange/examples/mtgox/v2/service/marketdata/streaming/MtGoxWebSocketSyncronizedOrderBookDemo.java) from the XChange open source project.


---

### Answer by username_2 on 2013-08-16. Score: 1

Your link to the "old version of the API" is actually going to the streaming API which is still available.  Only the http version was updated and from there it looks difficult to obtain accurate  depth info reliably for precise time periods.
So I'd stick with streaming. Updated much more in real-time for your requirements.
Now they deprecated the depth:volume field but they still have volume_int, which is volume change * 1E8, so you could obtain volume from that:
//js for example
var volume = volume_int * Math.pow(10,-8);

Check out the github samples at the bottom of the wiki page to help get started.  For example, this one


---

