<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Clark</id>
	<title>Bitcoin Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Clark"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Clark"/>
	<updated>2026-04-29T06:11:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=38119</id>
		<title>Real Time Bitcoin Market Data</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=38119"/>
		<updated>2013-05-28T20:23:19Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* External Links */ Removed defunct links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Bitcoin Data Platform by Clark Moody==&lt;br /&gt;
A financial information service that provides a real-time display of data from the [[MtGox]] exchange.&lt;br /&gt;
&lt;br /&gt;
* Combined - Includes all of the services listed below&lt;br /&gt;
* Time Sales - Time price and volume for each trade executed&lt;br /&gt;
* Ticker - Current best ask / best bid, day&#039;s high, day&#039;s low, volume and last trade for all MtGox currencies. The site also displays a synthetic forex grid, based on the immediate exchange rates between non-zero volume currencies.&lt;br /&gt;
* Order Book - The buy (bid) and sell (ask) orders along with real time trade calculators&lt;br /&gt;
&lt;br /&gt;
The Ticker and Time Sales services were announced on June 03, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=11560.0 Realtime MtGox Time and Sales with WebSockets]&amp;lt;/ref&amp;gt; and the Order Book was announced on June 10, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=14412.0 Real Time Order Book with WebSockets]&amp;lt;/ref&amp;gt;. The combined information view was announced on September 11, 2011&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=43514.0 Combined Order Book and Time &amp;amp; Sales]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin-Analytics.com==&lt;br /&gt;
Relatively new financial information analytical service which provides real-time display of data from multiple bitcoin exchanges. The service was announced on May 21, 2012&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=82768.0 Bitcoin-Analytics.com]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Supported Markets===&lt;br /&gt;
* USD - mtgoxUSD, btceUSD, cbxUSD, cryptoxUSD, intrsngUSD, bitstampUSD, bitmarketUSD, bcLRUSD, vcxUSD, btc24USD, &amp;lt;strike&amp;gt;bitfloorUSD&amp;lt;/strike&amp;gt; &lt;br /&gt;
* EUR - mtgoxEUR, bitmarketEUR, vcxEUR, intrsngEUR, bcEUR, bcLREUR, bitcurexEUR, btc24EUR&lt;br /&gt;
* CNY - btcnCNY, mtgoxCNY&lt;br /&gt;
 &lt;br /&gt;
===Displayed Charts===&lt;br /&gt;
* Order Book Volume Chart&lt;br /&gt;
* MKT Execution Price Chart&lt;br /&gt;
* Time Last 1000? BTC Traded Chart&lt;br /&gt;
* VWAP Last 1000? BTC Traded Chart&lt;br /&gt;
* Trade Volume Chart&lt;br /&gt;
&lt;br /&gt;
===Arbitrage Table===&lt;br /&gt;
Service provides arbitrage tables for all supported currency markets.&lt;br /&gt;
&lt;br /&gt;
===Consolidated Order Books===&lt;br /&gt;
Also service provides unique data - consolidated order books (all order books for the same currency are merged and all orders are sorted). Thus for each currency there is additional consolidated currency market: one for USD allUSD, for EUR allEUR, and for CNY allCNY.&lt;br /&gt;
&lt;br /&gt;
Consolidated order books data can help represent the behavior of the whole market.&lt;br /&gt;
For example consolidated order book charts clearly displays whether arbitrage opportunity is present among different exchanges and for how long it is present, and at what extent. Also comparing charts for different exchanges it is possible to see quickly between which exchanges this particular arbitrage apportunity currently exists.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ Combined Order Book, Time &amp;amp; Sales, and Historical Chart] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ticker Ticker] web page&lt;br /&gt;
* [http://bitcoin-analytics.com Bitcoin-Analytics.com - Multiple Exchanges Consolidated Order Books and Trades Real Time Charts] subscribtion service web page&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Financial]]&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v1&amp;diff=24504</id>
		<title>MtGox/API/HTTP/v1</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v1&amp;diff=24504"/>
		<updated>2012-03-06T21:35:24Z</updated>

		<summary type="html">&lt;p&gt;Clark: Added section on trade history&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HTTP API version 1 methods ==&lt;br /&gt;
&lt;br /&gt;
=== Multi Currency Ticker ===&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
=== Multi Currency depth ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
=== Multi currency trades ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Cancelled Trades ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
=== Full Depth ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
=== Private info ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/info&lt;br /&gt;
&lt;br /&gt;
returns information about your account, funds, fees, API privileges, withdraw limits . . .&lt;br /&gt;
&lt;br /&gt;
=== idKey ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/idkey&lt;br /&gt;
&lt;br /&gt;
Returns the idKey used to subscribe to a user&#039;s private updates channel in the websocket API. The key is valid for 24 hours.&lt;br /&gt;
&lt;br /&gt;
=== Your open orders ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/orders&lt;br /&gt;
 &lt;br /&gt;
Returns information about your current open orders. Valid order statuses are: pending, executing, post-pending, open, stop, and invalid.&lt;br /&gt;
&lt;br /&gt;
=== Your trade history ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/trades&lt;br /&gt;
 &lt;br /&gt;
Returns all of your trades. Does not include fees.&lt;br /&gt;
&lt;br /&gt;
=== Submit an order ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/private/order/add&lt;br /&gt;
&lt;br /&gt;
parameters: &lt;br /&gt;
* type (bid|ask) (easier to remember: &#039;&#039;&#039;b&#039;&#039;&#039;id == &#039;&#039;&#039;b&#039;&#039;&#039;uy, ask == sell)&lt;br /&gt;
* amount_int &amp;lt;amount as int&amp;gt;&lt;br /&gt;
* price_int &amp;lt;price as int&amp;gt; (can be omitted to place market order)&lt;br /&gt;
 &lt;br /&gt;
submits an order and returns info about success or error&lt;br /&gt;
&lt;br /&gt;
=== Currency information ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/currency&lt;br /&gt;
&lt;br /&gt;
pass parameter ?currency=&amp;lt;currency_symbol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns information about a currency ( number of decimals . . . )&lt;br /&gt;
&lt;br /&gt;
=== HOTP key ===&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/hotp_gen&lt;br /&gt;
&lt;br /&gt;
used to generate a new HOTP key ( useful for developers )&lt;br /&gt;
&lt;br /&gt;
=== Merchant System ===&lt;br /&gt;
&lt;br /&gt;
==== Order Creation ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/merchant/order/create&lt;br /&gt;
&lt;br /&gt;
===== Required Parameters: =====&lt;br /&gt;
* &#039;&#039;&#039;currency&#039;&#039;&#039;: &#039;&#039;&amp;lt;currency&amp;gt;&#039;&#039; (for now only BTC is supported)&lt;br /&gt;
* &#039;&#039;&#039;amount&#039;&#039;&#039;: &#039;&#039;&amp;lt;amount as float&amp;gt;&#039;&#039;&lt;br /&gt;
or&lt;br /&gt;
* &#039;&#039;&#039;amount_int&#039;&#039;&#039;: &#039;&#039;&amp;lt;amount as int&amp;gt;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;return_success&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; Where to redirect the user on payment success&lt;br /&gt;
* &#039;&#039;&#039;return_failure&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; Where to redirect the user on cancellation&lt;br /&gt;
&lt;br /&gt;
===== Optional Parameters: =====&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; A small description that will appear on the payment page (defaults to &amp;quot;Payment to &amp;lt;user_login&amp;gt;&amp;quot;)&lt;br /&gt;
* &#039;&#039;&#039;ipn&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; URL that will be called by our services once the payment is complete (more below)&lt;br /&gt;
* &#039;&#039;&#039;data&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; Custom data returned by the IPN&lt;br /&gt;
&lt;br /&gt;
===== Returns =====&lt;br /&gt;
* &#039;&#039;&#039;transaction&#039;&#039;&#039;: &#039;&#039;&amp;lt;uuid&amp;gt;&#039;&#039; A unique transaction ID&lt;br /&gt;
* &#039;&#039;&#039;payment_url&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; URL on which to redirect the user&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== IPN ====&lt;br /&gt;
The IPN (Instant payment notification) is a mechanism that POST data about a successful payment an a custom URL located on your website right after the payment as been validated.&lt;br /&gt;
Your website is supposed then to either acknowledge the IPN by returning &amp;quot;[OK]&amp;quot; as is. Anything else will be counted as an error and the system will try sending the IPN back every 30 minutes until it succeed.&lt;br /&gt;
&lt;br /&gt;
===== Content =====&lt;br /&gt;
The IPN POST data will always contain the following:&lt;br /&gt;
* &#039;&#039;&#039;id&#039;&#039;&#039;: &#039;&#039;&amp;lt;uuid&amp;gt;&#039;&#039; The transaction ID generated by the initial call&lt;br /&gt;
* &#039;&#039;&#039;payment_id&#039;&#039;&#039;: &#039;&#039;&amp;lt;uuid&amp;gt;&#039;&#039; The payment ID&lt;br /&gt;
* &#039;&#039;&#039;status&#039;&#039;&#039;: &#039;&#039;&amp;lt;enum&amp;gt;&#039;&#039; Either &#039;&#039;&#039;paid&#039;&#039;&#039;, &#039;&#039;&#039;cancelled&#039;&#039;&#039; or &#039;&#039;&#039;closed&#039;&#039;&#039; (3rd one shouldn&#039;t happen)&lt;br /&gt;
&lt;br /&gt;
If the transaction was successfully paid:&lt;br /&gt;
* &#039;&#039;&#039;amount&#039;&#039;&#039;: &#039;&#039;&amp;lt;amount as int&amp;gt;&#039;&#039; The amount paid by the user&lt;br /&gt;
* &#039;&#039;&#039;currency&#039;&#039;&#039;: &#039;&#039;&amp;lt;currency&amp;gt;&#039;&#039; The currency used to pay (should always be BTC for now)&lt;br /&gt;
* &#039;&#039;&#039;method&#039;&#039;&#039;: &#039;&#039;&amp;lt;enum&amp;gt;&#039;&#039; The payment method, for now MTGOXBTC&lt;br /&gt;
* &#039;&#039;&#039;date&#039;&#039;&#039;: &#039;&#039;&amp;lt;date&amp;gt;&#039;&#039; The payment date&lt;br /&gt;
&lt;br /&gt;
If data was provided in the initial call:&lt;br /&gt;
* &#039;&#039;&#039;data&#039;&#039;&#039;: &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; The data provided when creating the transaction&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== bitcoin_dealer (trading script) ===&lt;br /&gt;
&lt;br /&gt;
python (django) : https://github.com/rokj/bitcoin_dealer&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20705</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20705"/>
		<updated>2011-12-11T23:21:44Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* Depth */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides methods to access information from the market, place orders, and more.&lt;br /&gt;
&lt;br /&gt;
Two APIs are currently available: the HTTP API (available by posting to mtgox.com/code/*) and the websocket API.&lt;br /&gt;
&lt;br /&gt;
==Number Formats==&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;old API&amp;quot;, currency- and amount-values (price, volume,...) were given as &#039;&#039;&#039;float&#039;&#039;&#039;. These values are likely being deprecated and replaced by fields of the same name with &amp;quot;_int&amp;quot; as suffix. These are &#039;&#039;&#039;fixed-decimal&#039;&#039;&#039;, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.&lt;br /&gt;
&lt;br /&gt;
In order to convert the &#039;&#039;&#039;int&#039;&#039;&#039; to a &#039;&#039;&#039;decimal&#039;&#039;&#039; you can...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! kind of field !! ...divide by !! ...multiply by&lt;br /&gt;
|-&lt;br /&gt;
| BTC (volume, amount) || 1E8 (10,000,000) || 0.00000001&lt;br /&gt;
|-&lt;br /&gt;
| USD (price) || 1E5 (100,000) || 0.00001&lt;br /&gt;
|-&lt;br /&gt;
| JPY (price) || 1E3 (1,000) || 0.001&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Implementation advice: it&#039;s probably best to use &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;Decimal&#039;&#039;&#039; (if your language/db offers such a type) in your clients. Using &#039;&#039;&#039;float&#039;&#039;&#039; will likely lead to nasty rounding problems.&lt;br /&gt;
&lt;br /&gt;
== Currency Symbols ==&lt;br /&gt;
List of the currency symbols available with the API:&lt;br /&gt;
&lt;br /&gt;
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB&lt;br /&gt;
&lt;br /&gt;
== HTTP API ==&lt;br /&gt;
This API is available in &amp;lt;nowiki&amp;gt;https://mtgox.com/api/*&amp;lt;/nowiki&amp;gt;, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.  There is also a [https://rubygems.org/gems/mtgox Ruby gem] and [[Finance::MtGox|Perl module]] for interacting with the HTTP API.&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Authentication is performed by signing each request using HMAC-SHA512. The request must contain an extra value &amp;quot;nonce&amp;quot; which must be an always incrementing numeric value.  A reference implementation is provided here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function mtgox_query($path, array $req = array()) {&lt;br /&gt;
	// API settings&lt;br /&gt;
	$key = &#039;&#039;;&lt;br /&gt;
	$secret = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems&lt;br /&gt;
	$mt = explode(&#039; &#039;, microtime());&lt;br /&gt;
	$req[&#039;nonce&#039;] = $mt[1].substr($mt[0], 2, 6);&lt;br /&gt;
&lt;br /&gt;
	// generate the POST data string&lt;br /&gt;
	$post_data = http_build_query($req, &#039;&#039;, &#039;&amp;amp;&#039;);&lt;br /&gt;
&lt;br /&gt;
	// generate the extra headers&lt;br /&gt;
	$headers = array(&lt;br /&gt;
		&#039;Rest-Key: &#039;.$key,&lt;br /&gt;
		&#039;Rest-Sign: &#039;.base64_encode(hash_hmac(&#039;sha512&#039;, $post_data, base64_decode($secret), true)),&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	// our curl handle (initialize if required)&lt;br /&gt;
	static $ch = null;&lt;br /&gt;
	if (is_null($ch)) {&lt;br /&gt;
		$ch = curl_init();&lt;br /&gt;
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;
		curl_setopt($ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0 (compatible; MtGox PHP client; &#039;.php_uname(&#039;s&#039;).&#039;; PHP/&#039;.phpversion().&#039;)&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	curl_setopt($ch, CURLOPT_URL, &#039;https://mtgox.com/api/&#039;.$path);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;br /&gt;
&lt;br /&gt;
	// run the query&lt;br /&gt;
	$res = curl_exec($ch);&lt;br /&gt;
	if ($res === false) throw new Exception(&#039;Could not get reply: &#039;.curl_error($ch));&lt;br /&gt;
	$dec = json_decode($res, true);&lt;br /&gt;
	if (!$dec) throw new Exception(&#039;Invalid data received, please make sure connection is working and requested API exists&#039;);&lt;br /&gt;
	return $dec;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// example 1: get infos about the account, plus the list of rights we have access to&lt;br /&gt;
var_dump(mtgox_query(&#039;0/info.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// old api (get funds)&lt;br /&gt;
var_dump(mtgox_query(&#039;0/getFunds.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// trade example&lt;br /&gt;
// var_dump(mtgox_query(&#039;0/buyBTC.php&#039;, array(&#039;amount&#039; =&amp;gt; 1, &#039;price&#039; =&amp;gt; 15)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python version here: https://bitcointalk.org/index.php?topic=49789.msg592388#msg592388&lt;br /&gt;
&lt;br /&gt;
=== Cache ===&lt;br /&gt;
&lt;br /&gt;
All of the API methods below have cached results, ticker, depth . . . have a 10 seconds cache .&lt;br /&gt;
No need to poll more often, you wont have more results, you could just be blocked by the prolexic anti ddos features.&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 0===&lt;br /&gt;
&lt;br /&gt;
==== 0/data/getTrades.php ====&lt;br /&gt;
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* since: Passing a tid in &amp;quot;since&amp;quot; allows retrieving all trades since that trade. The passed id is may not exist. Ie. to get all trades from the very beginning one would just call https://mtgox.com/code/data/getTrades.php?since=0 . since returns only 100 trades, and you can call the method again by passing the latest trade you have imported in since.&lt;br /&gt;
&lt;br /&gt;
* data is returned in standard json format like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279408157,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;0.04951&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;20&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;4951&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;2000000000&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279424586,&amp;quot;price&amp;quot;:&amp;quot;0.05941&amp;quot;,&amp;quot;amount&amp;quot;:&amp;quot;50.01&amp;quot;,&amp;quot;price_int&amp;quot;:&amp;quot;5941&amp;quot;,&amp;quot;amount_int&amp;quot;:&amp;quot;5001000000&amp;quot;,&amp;quot;tid&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 0/getDepth.php ====&lt;br /&gt;
Get the current Market depth&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=USD&lt;br /&gt;
&lt;br /&gt;
==== 0/getFunds.php ====&lt;br /&gt;
Get your current balance&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getFunds.php&lt;br /&gt;
&lt;br /&gt;
getfunds is now deprecated since multi currency, please use info.php&lt;br /&gt;
&lt;br /&gt;
==== 0/buyBTC.php ====&lt;br /&gt;
Place an order to Buy BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/buyBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: amount=#&amp;amp;price=#&amp;amp;Currency=PLN&lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/sellBTC.php ====&lt;br /&gt;
Place an order to Sell BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/sellBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: &amp;amp;amount=#&amp;amp;price=#&amp;amp;Currency=PLN &lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/getOrders.php ====&lt;br /&gt;
Fetch a list of your open Orders&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getOrders.php&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
status: 1 for active, 2 for not enough funds&lt;br /&gt;
&lt;br /&gt;
==== 0/cancelOrder.php ====&lt;br /&gt;
Cancel an order&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/cancelOrder.php&lt;br /&gt;
&lt;br /&gt;
POST data: oid=#&amp;amp;type=#&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
==== 0/redeemCode.php ====&lt;br /&gt;
Used to redeem a mtgox coupon code&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/redeemCode.php&lt;br /&gt;
&lt;br /&gt;
* call with a post parameter &amp;quot;code&amp;quot; containing the code to redeem&lt;br /&gt;
&lt;br /&gt;
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status&lt;br /&gt;
&lt;br /&gt;
==== 0/withdraw.php ====&lt;br /&gt;
withdraw / Send BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/withdraw.php&lt;br /&gt;
&lt;br /&gt;
POST data: group1=BTC&amp;amp;btca=bitcoin_address_to_send_to&amp;amp;amount=#&lt;br /&gt;
&lt;br /&gt;
* pass btca parameter to withdraw to a btc adress&lt;br /&gt;
&lt;br /&gt;
* pass group1 for a coupon : BTC2CODE or USD2CODE&lt;br /&gt;
&lt;br /&gt;
* pass group1=DWUSD&amp;amp;dwaccount=XXX-XXX-XXXX (no btca=xxxxxxx) for a dwolla withdraw&lt;br /&gt;
&lt;br /&gt;
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )&lt;br /&gt;
* return code and status if successful&lt;br /&gt;
&lt;br /&gt;
 To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )&lt;br /&gt;
&lt;br /&gt;
==== 0/btcAddress.php ====&lt;br /&gt;
get a bitcoin deposit adress for your account &lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/btcAddress.php&lt;br /&gt;
&lt;br /&gt;
* pass POST data &amp;quot;description&amp;quot; to add a description that will appear in your history when this BTC address receive a deposit&lt;br /&gt;
&lt;br /&gt;
* returns a bitcoin deposit address&lt;br /&gt;
&lt;br /&gt;
==== 0/history_[CUR].csv ====&lt;br /&gt;
&lt;br /&gt;
Allows downloading your activity history for a given currency (BTC or USD for now).&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_BTC.csv&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_USD.csv&lt;br /&gt;
&lt;br /&gt;
==== 0/info.php ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/info.php&lt;br /&gt;
&lt;br /&gt;
returns info about your account, funds, fees, API privileges, withdraw limits . . . &lt;br /&gt;
&lt;br /&gt;
==== 0/ticker ====&lt;br /&gt;
&lt;br /&gt;
http://mtgox.com/api/0/data/ticker.php&lt;br /&gt;
&lt;br /&gt;
returns the current ticker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;ticker&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;:5.70653,&lt;br /&gt;
 &amp;quot;low&amp;quot;:5.4145,&lt;br /&gt;
 &amp;quot;avg&amp;quot;:5.561388723,&lt;br /&gt;
 &amp;quot;vwap&amp;quot;:5.610932845,&lt;br /&gt;
 &amp;quot;vol&amp;quot;:55698,&lt;br /&gt;
 &amp;quot;last&amp;quot;:5.56915,&lt;br /&gt;
 &amp;quot;buy&amp;quot;:5.51326,&lt;br /&gt;
 &amp;quot;sell&amp;quot;:5.5672&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours&lt;br /&gt;
&lt;br /&gt;
what is vwap ? &lt;br /&gt;
&lt;br /&gt;
please see http://en.wikipedia.org/wiki/VWAP&lt;br /&gt;
&lt;br /&gt;
=== API version 0 examples ===&lt;br /&gt;
&lt;br /&gt;
==== all api shell type CLI ====&lt;br /&gt;
&lt;br /&gt;
python : http://www.goxsh.info/&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/vEpgw5nW&lt;br /&gt;
&lt;br /&gt;
==== other ====&lt;br /&gt;
&lt;br /&gt;
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl&lt;br /&gt;
&lt;br /&gt;
https://github.com/sje397/mtgox-plasmoid&lt;br /&gt;
&lt;br /&gt;
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/&lt;br /&gt;
&lt;br /&gt;
==== gather data ====&lt;br /&gt;
&lt;br /&gt;
https://github.com/Lexiks/MyBitBoard&lt;br /&gt;
&lt;br /&gt;
==== gettrade ====&lt;br /&gt;
&lt;br /&gt;
bash : https://bitcointalk.org/index.php?topic=39402.0&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/raw.php?i=pmhMXZJu&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
&lt;br /&gt;
http://pastebin.com/pd0ZR4WY&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 1===&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency Ticker ====&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
==== Multi currency trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelled Trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
==== Full Depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
==== Private info ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/info&lt;br /&gt;
&lt;br /&gt;
returns information about your account, funds, fees, API privileges, withdraw limits . . .&lt;br /&gt;
&lt;br /&gt;
==== Your open orders ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/orders&lt;br /&gt;
 &lt;br /&gt;
returns information about your current open orders&lt;br /&gt;
&lt;br /&gt;
==== Currency information ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/currency&lt;br /&gt;
&lt;br /&gt;
pass parameter ?currency=&amp;lt;currency_symbol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns information about a currency ( number of decimals . . . )&lt;br /&gt;
&lt;br /&gt;
==== HOTP key ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/hotp_gen&lt;br /&gt;
&lt;br /&gt;
used to generate a new HOTP key ( useful for developpers )&lt;br /&gt;
&lt;br /&gt;
== Streaming API ==&lt;br /&gt;
Real time streaming data may be obtained over the streaming API, implemented in [http://socket.io/ Socket.io]&amp;lt;ref&amp;gt;Socket.io forum announcement by MagicalTux: https://bitcointalk.org/index.php?topic=14412.msg613271#msg613271&amp;lt;/ref&amp;gt;. The original WebSocket API&amp;lt;ref&amp;gt;Original WebSocket thread: https://bitcointalk.org/index.php?topic=5855.msg86219&amp;lt;/ref&amp;gt; is deprecated as of 11-Nov-2011.&lt;br /&gt;
&lt;br /&gt;
===Connecting===&lt;br /&gt;
The following JavaScript code establishes a connection in the browser:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://socketio.mtgox.com/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
    var conn = io.connect(&#039;https://socketio.mtgox.com/mtgox&#039;);&lt;br /&gt;
    conn.on(&#039;message&#039;, function(data) {&lt;br /&gt;
        // Handle incoming data object.&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session ID expires after 30 seconds&lt;br /&gt;
&lt;br /&gt;
===Handling Events===&lt;br /&gt;
Socket.io exposes a simple interface for handling events. Handling &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; events is shown above, but there are other events that may be handled:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
conn.on(&#039;connect&#039;,    onConnect);&lt;br /&gt;
conn.on(&#039;disconnect&#039;, onDisconnect);&lt;br /&gt;
conn.on(&#039;error&#039;,      onError);&lt;br /&gt;
conn.on(&#039;message&#039;,    onMessage);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Incoming Data===&lt;br /&gt;
Data arrives as a full object instead of as JSON text, eliminating the need to parse the data in the JavaScript handler. Messages that come across the socket to trigger the &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; event will contain the following minimum components:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;lt;OPERATION_TYPE&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;OPERATION_TYPE&amp;lt;/tt&amp;gt; field may take these values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! OPERATION_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| subscribe || Notification that the user is subscribed to a channel&lt;br /&gt;
|-&lt;br /&gt;
| unsubscribe || Messages will no longer arrive over the channel&lt;br /&gt;
|-&lt;br /&gt;
| remark || A server message, usually a warning&lt;br /&gt;
|-&lt;br /&gt;
| private || The operation for depth, trade, and ticker messages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:subscribe and op:unsubscribe===&lt;br /&gt;
The subscribe and unsubscribe message data are very simple, containing the channel and the operation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;subscribe&amp;quot; OR &amp;quot;unsubscribe&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some of the channels are:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel ID !! Description&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:remark===&lt;br /&gt;
The remark operation contains message and success fields.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;remark&amp;quot;,&lt;br /&gt;
  &amp;quot;message&amp;quot;:&amp;lt;MESSAGE FROM THE SERVER&amp;gt;,&lt;br /&gt;
  &amp;quot;success&amp;quot;:&amp;lt;boolean&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===op:private===&lt;br /&gt;
The payloads of the &amp;lt;tt&amp;gt;op:private&amp;lt;/tt&amp;gt; messages contain the real time market information. Each message follows this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;lt;MESSAGE_TYPE&amp;gt;,&lt;br /&gt;
  &amp;lt;MESSAGE_TYPE&amp;gt;:&amp;lt;DATA_PAYLOAD&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;MESSAGE_TYPE&amp;lt;/tt&amp;gt; field may take the values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MESSAGE_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| ticker || Ticker messages&lt;br /&gt;
|-&lt;br /&gt;
| trade || Trades, as they occur&lt;br /&gt;
|-&lt;br /&gt;
| depth || Orders placed or removed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Ticker====&lt;br /&gt;
Ticker messages contain the current inside Bid and Ask as well as daily highs, lows, and volume. The fields contained in the ticker match those defined in the version 1.0 API above. All fields contain &amp;lt;tt&amp;gt;currency&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;display&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;value_int&amp;lt;/tt&amp;gt; entries.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;d5f06780-30a8-4a48-a2f8-7ed181b4a13f&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;ticker&amp;quot;,&lt;br /&gt;
  &amp;quot;ticker&amp;quot;:{&lt;br /&gt;
    &amp;quot;avg&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;$2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;226847&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;buy&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;high&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last&amp;quot;:{..},&lt;br /&gt;
    &amp;quot;last_local&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last_orig&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;low&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;sell&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;vol&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;118,696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;118696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;11869602104208&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;vwap&amp;quot;:{...}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trade====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;dbf1dee9-4f2e-4a08-8cb7-748919a71b21&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
  &amp;quot;trade&amp;quot;:{&lt;br /&gt;
    &amp;quot;amount&amp;quot;:2.71,&lt;br /&gt;
    &amp;quot;amount_int&amp;quot;:&amp;quot;271000000&amp;quot;,&lt;br /&gt;
    &amp;quot;date&amp;quot;:1310279340,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:14.43,&lt;br /&gt;
    &amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;:&amp;quot;limit, mixed_currency&amp;quot;,&lt;br /&gt;
    &amp;quot;tid&amp;quot;:&amp;quot;1310279340877902&amp;quot;,&lt;br /&gt;
    &amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:&amp;quot;trade&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;trade&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| amount || the traded amount in item (BTC), float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| amount_int || the traded amount * 1E8&lt;br /&gt;
|-&lt;br /&gt;
| date || unix timestamp of trade&lt;br /&gt;
|-&lt;br /&gt;
| item || What was this trade about&lt;br /&gt;
|-&lt;br /&gt;
| price || price per unit, float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)&lt;br /&gt;
|-&lt;br /&gt;
| price_currency || currency in which trade was completed&lt;br /&gt;
|-&lt;br /&gt;
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)&lt;br /&gt;
|-&lt;br /&gt;
| trade_type || Did this trade result from the execution of a bid or a ask?&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Depth====&lt;br /&gt;
&lt;br /&gt;
Changes to the market depth data are broadcast so an up-to-date market depth can be kept by clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;24e67e0d-1cad-4cc0-9e7a-f8523ef460fe&amp;quot;,&lt;br /&gt;
  &amp;quot;depth&amp;quot;:{&lt;br /&gt;
    &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;now&amp;quot;:&amp;quot;1323644358437819&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:&amp;quot;14.43&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;total_volume_int&amp;quot;:&amp;quot;849766000&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:1,&lt;br /&gt;
    &amp;quot;type_str&amp;quot;:&amp;quot;ask&amp;quot;,&lt;br /&gt;
    &amp;quot;volume&amp;quot;:&amp;quot;-2.71&amp;quot;,&lt;br /&gt;
    &amp;quot;volume_int&amp;quot;:&amp;quot;-271000000&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;depth&amp;quot;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;depth&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| currency || the currency affected&lt;br /&gt;
|-&lt;br /&gt;
| item || the item (BTC)&lt;br /&gt;
|-&lt;br /&gt;
| price || price as a float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || the price at which volume change happened (5 decimal for USD, 3 for JPY)&lt;br /&gt;
|-&lt;br /&gt;
| type || 1=ask, 2=bid. deprecated, use type_str&lt;br /&gt;
|-&lt;br /&gt;
| type_str || type of order at this depth, either &amp;quot;ask&amp;quot; or &amp;quot;bid&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| volume || the volume change as float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| volume_int || volume change * 1E8&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Possible outgoing commands===&lt;br /&gt;
&#039;&#039;&#039;unsubscribe&#039;&#039;&#039; Stop receiving messages from a channel (parameter &amp;quot;channel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== examples ===&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
javascript, using hookio : &lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=KD5ljtNK72U&lt;br /&gt;
&lt;br /&gt;
http://github.com/hookio&lt;br /&gt;
&lt;br /&gt;
http://github.com/cronopio/hook.io-mtgox&lt;br /&gt;
&lt;br /&gt;
Another node.js project, using plain websockets (largely based on cronopio&#039;s work) :&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
==== arbitrage ====&lt;br /&gt;
https://github.com/goteppo/ArBit&lt;br /&gt;
&lt;br /&gt;
==== websocket ====&lt;br /&gt;
https://github.com/cronopio/hook.io-ws&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20704</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20704"/>
		<updated>2011-12-11T23:21:32Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* Trade */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides methods to access information from the market, place orders, and more.&lt;br /&gt;
&lt;br /&gt;
Two APIs are currently available: the HTTP API (available by posting to mtgox.com/code/*) and the websocket API.&lt;br /&gt;
&lt;br /&gt;
==Number Formats==&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;old API&amp;quot;, currency- and amount-values (price, volume,...) were given as &#039;&#039;&#039;float&#039;&#039;&#039;. These values are likely being deprecated and replaced by fields of the same name with &amp;quot;_int&amp;quot; as suffix. These are &#039;&#039;&#039;fixed-decimal&#039;&#039;&#039;, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.&lt;br /&gt;
&lt;br /&gt;
In order to convert the &#039;&#039;&#039;int&#039;&#039;&#039; to a &#039;&#039;&#039;decimal&#039;&#039;&#039; you can...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! kind of field !! ...divide by !! ...multiply by&lt;br /&gt;
|-&lt;br /&gt;
| BTC (volume, amount) || 1E8 (10,000,000) || 0.00000001&lt;br /&gt;
|-&lt;br /&gt;
| USD (price) || 1E5 (100,000) || 0.00001&lt;br /&gt;
|-&lt;br /&gt;
| JPY (price) || 1E3 (1,000) || 0.001&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Implementation advice: it&#039;s probably best to use &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;Decimal&#039;&#039;&#039; (if your language/db offers such a type) in your clients. Using &#039;&#039;&#039;float&#039;&#039;&#039; will likely lead to nasty rounding problems.&lt;br /&gt;
&lt;br /&gt;
== Currency Symbols ==&lt;br /&gt;
List of the currency symbols available with the API:&lt;br /&gt;
&lt;br /&gt;
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB&lt;br /&gt;
&lt;br /&gt;
== HTTP API ==&lt;br /&gt;
This API is available in &amp;lt;nowiki&amp;gt;https://mtgox.com/api/*&amp;lt;/nowiki&amp;gt;, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.  There is also a [https://rubygems.org/gems/mtgox Ruby gem] and [[Finance::MtGox|Perl module]] for interacting with the HTTP API.&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Authentication is performed by signing each request using HMAC-SHA512. The request must contain an extra value &amp;quot;nonce&amp;quot; which must be an always incrementing numeric value.  A reference implementation is provided here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function mtgox_query($path, array $req = array()) {&lt;br /&gt;
	// API settings&lt;br /&gt;
	$key = &#039;&#039;;&lt;br /&gt;
	$secret = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems&lt;br /&gt;
	$mt = explode(&#039; &#039;, microtime());&lt;br /&gt;
	$req[&#039;nonce&#039;] = $mt[1].substr($mt[0], 2, 6);&lt;br /&gt;
&lt;br /&gt;
	// generate the POST data string&lt;br /&gt;
	$post_data = http_build_query($req, &#039;&#039;, &#039;&amp;amp;&#039;);&lt;br /&gt;
&lt;br /&gt;
	// generate the extra headers&lt;br /&gt;
	$headers = array(&lt;br /&gt;
		&#039;Rest-Key: &#039;.$key,&lt;br /&gt;
		&#039;Rest-Sign: &#039;.base64_encode(hash_hmac(&#039;sha512&#039;, $post_data, base64_decode($secret), true)),&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	// our curl handle (initialize if required)&lt;br /&gt;
	static $ch = null;&lt;br /&gt;
	if (is_null($ch)) {&lt;br /&gt;
		$ch = curl_init();&lt;br /&gt;
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;
		curl_setopt($ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0 (compatible; MtGox PHP client; &#039;.php_uname(&#039;s&#039;).&#039;; PHP/&#039;.phpversion().&#039;)&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	curl_setopt($ch, CURLOPT_URL, &#039;https://mtgox.com/api/&#039;.$path);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;br /&gt;
&lt;br /&gt;
	// run the query&lt;br /&gt;
	$res = curl_exec($ch);&lt;br /&gt;
	if ($res === false) throw new Exception(&#039;Could not get reply: &#039;.curl_error($ch));&lt;br /&gt;
	$dec = json_decode($res, true);&lt;br /&gt;
	if (!$dec) throw new Exception(&#039;Invalid data received, please make sure connection is working and requested API exists&#039;);&lt;br /&gt;
	return $dec;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// example 1: get infos about the account, plus the list of rights we have access to&lt;br /&gt;
var_dump(mtgox_query(&#039;0/info.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// old api (get funds)&lt;br /&gt;
var_dump(mtgox_query(&#039;0/getFunds.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// trade example&lt;br /&gt;
// var_dump(mtgox_query(&#039;0/buyBTC.php&#039;, array(&#039;amount&#039; =&amp;gt; 1, &#039;price&#039; =&amp;gt; 15)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python version here: https://bitcointalk.org/index.php?topic=49789.msg592388#msg592388&lt;br /&gt;
&lt;br /&gt;
=== Cache ===&lt;br /&gt;
&lt;br /&gt;
All of the API methods below have cached results, ticker, depth . . . have a 10 seconds cache .&lt;br /&gt;
No need to poll more often, you wont have more results, you could just be blocked by the prolexic anti ddos features.&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 0===&lt;br /&gt;
&lt;br /&gt;
==== 0/data/getTrades.php ====&lt;br /&gt;
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* since: Passing a tid in &amp;quot;since&amp;quot; allows retrieving all trades since that trade. The passed id is may not exist. Ie. to get all trades from the very beginning one would just call https://mtgox.com/code/data/getTrades.php?since=0 . since returns only 100 trades, and you can call the method again by passing the latest trade you have imported in since.&lt;br /&gt;
&lt;br /&gt;
* data is returned in standard json format like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279408157,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;0.04951&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;20&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;4951&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;2000000000&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279424586,&amp;quot;price&amp;quot;:&amp;quot;0.05941&amp;quot;,&amp;quot;amount&amp;quot;:&amp;quot;50.01&amp;quot;,&amp;quot;price_int&amp;quot;:&amp;quot;5941&amp;quot;,&amp;quot;amount_int&amp;quot;:&amp;quot;5001000000&amp;quot;,&amp;quot;tid&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 0/getDepth.php ====&lt;br /&gt;
Get the current Market depth&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=USD&lt;br /&gt;
&lt;br /&gt;
==== 0/getFunds.php ====&lt;br /&gt;
Get your current balance&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getFunds.php&lt;br /&gt;
&lt;br /&gt;
getfunds is now deprecated since multi currency, please use info.php&lt;br /&gt;
&lt;br /&gt;
==== 0/buyBTC.php ====&lt;br /&gt;
Place an order to Buy BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/buyBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: amount=#&amp;amp;price=#&amp;amp;Currency=PLN&lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/sellBTC.php ====&lt;br /&gt;
Place an order to Sell BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/sellBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: &amp;amp;amount=#&amp;amp;price=#&amp;amp;Currency=PLN &lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/getOrders.php ====&lt;br /&gt;
Fetch a list of your open Orders&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getOrders.php&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
status: 1 for active, 2 for not enough funds&lt;br /&gt;
&lt;br /&gt;
==== 0/cancelOrder.php ====&lt;br /&gt;
Cancel an order&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/cancelOrder.php&lt;br /&gt;
&lt;br /&gt;
POST data: oid=#&amp;amp;type=#&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
==== 0/redeemCode.php ====&lt;br /&gt;
Used to redeem a mtgox coupon code&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/redeemCode.php&lt;br /&gt;
&lt;br /&gt;
* call with a post parameter &amp;quot;code&amp;quot; containing the code to redeem&lt;br /&gt;
&lt;br /&gt;
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status&lt;br /&gt;
&lt;br /&gt;
==== 0/withdraw.php ====&lt;br /&gt;
withdraw / Send BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/withdraw.php&lt;br /&gt;
&lt;br /&gt;
POST data: group1=BTC&amp;amp;btca=bitcoin_address_to_send_to&amp;amp;amount=#&lt;br /&gt;
&lt;br /&gt;
* pass btca parameter to withdraw to a btc adress&lt;br /&gt;
&lt;br /&gt;
* pass group1 for a coupon : BTC2CODE or USD2CODE&lt;br /&gt;
&lt;br /&gt;
* pass group1=DWUSD&amp;amp;dwaccount=XXX-XXX-XXXX (no btca=xxxxxxx) for a dwolla withdraw&lt;br /&gt;
&lt;br /&gt;
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )&lt;br /&gt;
* return code and status if successful&lt;br /&gt;
&lt;br /&gt;
 To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )&lt;br /&gt;
&lt;br /&gt;
==== 0/btcAddress.php ====&lt;br /&gt;
get a bitcoin deposit adress for your account &lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/btcAddress.php&lt;br /&gt;
&lt;br /&gt;
* pass POST data &amp;quot;description&amp;quot; to add a description that will appear in your history when this BTC address receive a deposit&lt;br /&gt;
&lt;br /&gt;
* returns a bitcoin deposit address&lt;br /&gt;
&lt;br /&gt;
==== 0/history_[CUR].csv ====&lt;br /&gt;
&lt;br /&gt;
Allows downloading your activity history for a given currency (BTC or USD for now).&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_BTC.csv&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_USD.csv&lt;br /&gt;
&lt;br /&gt;
==== 0/info.php ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/info.php&lt;br /&gt;
&lt;br /&gt;
returns info about your account, funds, fees, API privileges, withdraw limits . . . &lt;br /&gt;
&lt;br /&gt;
==== 0/ticker ====&lt;br /&gt;
&lt;br /&gt;
http://mtgox.com/api/0/data/ticker.php&lt;br /&gt;
&lt;br /&gt;
returns the current ticker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;ticker&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;:5.70653,&lt;br /&gt;
 &amp;quot;low&amp;quot;:5.4145,&lt;br /&gt;
 &amp;quot;avg&amp;quot;:5.561388723,&lt;br /&gt;
 &amp;quot;vwap&amp;quot;:5.610932845,&lt;br /&gt;
 &amp;quot;vol&amp;quot;:55698,&lt;br /&gt;
 &amp;quot;last&amp;quot;:5.56915,&lt;br /&gt;
 &amp;quot;buy&amp;quot;:5.51326,&lt;br /&gt;
 &amp;quot;sell&amp;quot;:5.5672&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours&lt;br /&gt;
&lt;br /&gt;
what is vwap ? &lt;br /&gt;
&lt;br /&gt;
please see http://en.wikipedia.org/wiki/VWAP&lt;br /&gt;
&lt;br /&gt;
=== API version 0 examples ===&lt;br /&gt;
&lt;br /&gt;
==== all api shell type CLI ====&lt;br /&gt;
&lt;br /&gt;
python : http://www.goxsh.info/&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/vEpgw5nW&lt;br /&gt;
&lt;br /&gt;
==== other ====&lt;br /&gt;
&lt;br /&gt;
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl&lt;br /&gt;
&lt;br /&gt;
https://github.com/sje397/mtgox-plasmoid&lt;br /&gt;
&lt;br /&gt;
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/&lt;br /&gt;
&lt;br /&gt;
==== gather data ====&lt;br /&gt;
&lt;br /&gt;
https://github.com/Lexiks/MyBitBoard&lt;br /&gt;
&lt;br /&gt;
==== gettrade ====&lt;br /&gt;
&lt;br /&gt;
bash : https://bitcointalk.org/index.php?topic=39402.0&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/raw.php?i=pmhMXZJu&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
&lt;br /&gt;
http://pastebin.com/pd0ZR4WY&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 1===&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency Ticker ====&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
==== Multi currency trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelled Trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
==== Full Depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
==== Private info ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/info&lt;br /&gt;
&lt;br /&gt;
returns information about your account, funds, fees, API privileges, withdraw limits . . .&lt;br /&gt;
&lt;br /&gt;
==== Your open orders ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/orders&lt;br /&gt;
 &lt;br /&gt;
returns information about your current open orders&lt;br /&gt;
&lt;br /&gt;
==== Currency information ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/currency&lt;br /&gt;
&lt;br /&gt;
pass parameter ?currency=&amp;lt;currency_symbol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns information about a currency ( number of decimals . . . )&lt;br /&gt;
&lt;br /&gt;
==== HOTP key ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/hotp_gen&lt;br /&gt;
&lt;br /&gt;
used to generate a new HOTP key ( useful for developpers )&lt;br /&gt;
&lt;br /&gt;
== Streaming API ==&lt;br /&gt;
Real time streaming data may be obtained over the streaming API, implemented in [http://socket.io/ Socket.io]&amp;lt;ref&amp;gt;Socket.io forum announcement by MagicalTux: https://bitcointalk.org/index.php?topic=14412.msg613271#msg613271&amp;lt;/ref&amp;gt;. The original WebSocket API&amp;lt;ref&amp;gt;Original WebSocket thread: https://bitcointalk.org/index.php?topic=5855.msg86219&amp;lt;/ref&amp;gt; is deprecated as of 11-Nov-2011.&lt;br /&gt;
&lt;br /&gt;
===Connecting===&lt;br /&gt;
The following JavaScript code establishes a connection in the browser:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://socketio.mtgox.com/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
    var conn = io.connect(&#039;https://socketio.mtgox.com/mtgox&#039;);&lt;br /&gt;
    conn.on(&#039;message&#039;, function(data) {&lt;br /&gt;
        // Handle incoming data object.&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session ID expires after 30 seconds&lt;br /&gt;
&lt;br /&gt;
===Handling Events===&lt;br /&gt;
Socket.io exposes a simple interface for handling events. Handling &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; events is shown above, but there are other events that may be handled:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
conn.on(&#039;connect&#039;,    onConnect);&lt;br /&gt;
conn.on(&#039;disconnect&#039;, onDisconnect);&lt;br /&gt;
conn.on(&#039;error&#039;,      onError);&lt;br /&gt;
conn.on(&#039;message&#039;,    onMessage);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Incoming Data===&lt;br /&gt;
Data arrives as a full object instead of as JSON text, eliminating the need to parse the data in the JavaScript handler. Messages that come across the socket to trigger the &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; event will contain the following minimum components:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;lt;OPERATION_TYPE&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;OPERATION_TYPE&amp;lt;/tt&amp;gt; field may take these values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! OPERATION_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| subscribe || Notification that the user is subscribed to a channel&lt;br /&gt;
|-&lt;br /&gt;
| unsubscribe || Messages will no longer arrive over the channel&lt;br /&gt;
|-&lt;br /&gt;
| remark || A server message, usually a warning&lt;br /&gt;
|-&lt;br /&gt;
| private || The operation for depth, trade, and ticker messages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:subscribe and op:unsubscribe===&lt;br /&gt;
The subscribe and unsubscribe message data are very simple, containing the channel and the operation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;subscribe&amp;quot; OR &amp;quot;unsubscribe&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some of the channels are:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel ID !! Description&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:remark===&lt;br /&gt;
The remark operation contains message and success fields.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;remark&amp;quot;,&lt;br /&gt;
  &amp;quot;message&amp;quot;:&amp;lt;MESSAGE FROM THE SERVER&amp;gt;,&lt;br /&gt;
  &amp;quot;success&amp;quot;:&amp;lt;boolean&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===op:private===&lt;br /&gt;
The payloads of the &amp;lt;tt&amp;gt;op:private&amp;lt;/tt&amp;gt; messages contain the real time market information. Each message follows this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;lt;MESSAGE_TYPE&amp;gt;,&lt;br /&gt;
  &amp;lt;MESSAGE_TYPE&amp;gt;:&amp;lt;DATA_PAYLOAD&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;MESSAGE_TYPE&amp;lt;/tt&amp;gt; field may take the values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MESSAGE_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| ticker || Ticker messages&lt;br /&gt;
|-&lt;br /&gt;
| trade || Trades, as they occur&lt;br /&gt;
|-&lt;br /&gt;
| depth || Orders placed or removed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Ticker====&lt;br /&gt;
Ticker messages contain the current inside Bid and Ask as well as daily highs, lows, and volume. The fields contained in the ticker match those defined in the version 1.0 API above. All fields contain &amp;lt;tt&amp;gt;currency&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;display&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;value_int&amp;lt;/tt&amp;gt; entries.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;d5f06780-30a8-4a48-a2f8-7ed181b4a13f&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;ticker&amp;quot;,&lt;br /&gt;
  &amp;quot;ticker&amp;quot;:{&lt;br /&gt;
    &amp;quot;avg&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;$2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;226847&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;buy&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;high&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last&amp;quot;:{..},&lt;br /&gt;
    &amp;quot;last_local&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last_orig&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;low&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;sell&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;vol&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;118,696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;118696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;11869602104208&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;vwap&amp;quot;:{...}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trade====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;dbf1dee9-4f2e-4a08-8cb7-748919a71b21&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
  &amp;quot;trade&amp;quot;:{&lt;br /&gt;
    &amp;quot;amount&amp;quot;:2.71,&lt;br /&gt;
    &amp;quot;amount_int&amp;quot;:&amp;quot;271000000&amp;quot;,&lt;br /&gt;
    &amp;quot;date&amp;quot;:1310279340,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:14.43,&lt;br /&gt;
    &amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;:&amp;quot;limit, mixed_currency&amp;quot;,&lt;br /&gt;
    &amp;quot;tid&amp;quot;:&amp;quot;1310279340877902&amp;quot;,&lt;br /&gt;
    &amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:&amp;quot;trade&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;trade&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| amount || the traded amount in item (BTC), float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| amount_int || the traded amount * 1E8&lt;br /&gt;
|-&lt;br /&gt;
| date || unix timestamp of trade&lt;br /&gt;
|-&lt;br /&gt;
| item || What was this trade about&lt;br /&gt;
|-&lt;br /&gt;
| price || price per unit, float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)&lt;br /&gt;
|-&lt;br /&gt;
| price_currency || currency in which trade was completed&lt;br /&gt;
|-&lt;br /&gt;
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)&lt;br /&gt;
|-&lt;br /&gt;
| trade_type || Did this trade result from the execution of a bid or a ask?&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Depth====&lt;br /&gt;
&lt;br /&gt;
Changes to the market depth data are broadcast so an up-to-date market depth can be kept by clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;24e67e0d-1cad-4cc0-9e7a-f8523ef460fe&amp;quot;,&lt;br /&gt;
  &amp;quot;depth&amp;quot;:{&lt;br /&gt;
    &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;now&amp;quot;:&amp;quot;1323644358437819&amp;quot;&lt;br /&gt;
    &amp;quot;price&amp;quot;:&amp;quot;14.43&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;total_volume_int&amp;quot;:&amp;quot;849766000&amp;quot;&lt;br /&gt;
    &amp;quot;type&amp;quot;:1,&lt;br /&gt;
    &amp;quot;type_str&amp;quot;:&amp;quot;ask&amp;quot;,&lt;br /&gt;
    &amp;quot;volume&amp;quot;:&amp;quot;-2.71&amp;quot;,&lt;br /&gt;
    &amp;quot;volume_int&amp;quot;:&amp;quot;-271000000&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;depth&amp;quot;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;depth&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| currency || the currency affected&lt;br /&gt;
|-&lt;br /&gt;
| item || the item (BTC)&lt;br /&gt;
|-&lt;br /&gt;
| price || price as a float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || the price at which volume change happened (5 decimal for USD, 3 for JPY)&lt;br /&gt;
|-&lt;br /&gt;
| type || 1=ask, 2=bid. deprecated, use type_str&lt;br /&gt;
|-&lt;br /&gt;
| type_str || type of order at this depth, either &amp;quot;ask&amp;quot; or &amp;quot;bid&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| volume || the volume change as float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| volume_int || volume change * 1E8&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Possible outgoing commands===&lt;br /&gt;
&#039;&#039;&#039;unsubscribe&#039;&#039;&#039; Stop receiving messages from a channel (parameter &amp;quot;channel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== examples ===&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
javascript, using hookio : &lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=KD5ljtNK72U&lt;br /&gt;
&lt;br /&gt;
http://github.com/hookio&lt;br /&gt;
&lt;br /&gt;
http://github.com/cronopio/hook.io-mtgox&lt;br /&gt;
&lt;br /&gt;
Another node.js project, using plain websockets (largely based on cronopio&#039;s work) :&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
==== arbitrage ====&lt;br /&gt;
https://github.com/goteppo/ArBit&lt;br /&gt;
&lt;br /&gt;
==== websocket ====&lt;br /&gt;
https://github.com/cronopio/hook.io-ws&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20703</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20703"/>
		<updated>2011-12-11T23:03:53Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* Depth */  Message content&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides methods to access information from the market, place orders, and more.&lt;br /&gt;
&lt;br /&gt;
Two APIs are currently available: the HTTP API (available by posting to mtgox.com/code/*) and the websocket API.&lt;br /&gt;
&lt;br /&gt;
==Number Formats==&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;old API&amp;quot;, currency- and amount-values (price, volume,...) were given as &#039;&#039;&#039;float&#039;&#039;&#039;. These values are likely being deprecated and replaced by fields of the same name with &amp;quot;_int&amp;quot; as suffix. These are &#039;&#039;&#039;fixed-decimal&#039;&#039;&#039;, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.&lt;br /&gt;
&lt;br /&gt;
In order to convert the &#039;&#039;&#039;int&#039;&#039;&#039; to a &#039;&#039;&#039;decimal&#039;&#039;&#039; you can...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! kind of field !! ...divide by !! ...multiply by&lt;br /&gt;
|-&lt;br /&gt;
| BTC (volume, amount) || 1E8 (10,000,000) || 0.00000001&lt;br /&gt;
|-&lt;br /&gt;
| USD (price) || 1E5 (100,000) || 0.00001&lt;br /&gt;
|-&lt;br /&gt;
| JPY (price) || 1E3 (1,000) || 0.001&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Implementation advice: it&#039;s probably best to use &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;Decimal&#039;&#039;&#039; (if your language/db offers such a type) in your clients. Using &#039;&#039;&#039;float&#039;&#039;&#039; will likely lead to nasty rounding problems.&lt;br /&gt;
&lt;br /&gt;
== Currency Symbols ==&lt;br /&gt;
List of the currency symbols available with the API:&lt;br /&gt;
&lt;br /&gt;
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB&lt;br /&gt;
&lt;br /&gt;
== HTTP API ==&lt;br /&gt;
This API is available in &amp;lt;nowiki&amp;gt;https://mtgox.com/api/*&amp;lt;/nowiki&amp;gt;, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.  There is also a [https://rubygems.org/gems/mtgox Ruby gem] and [[Finance::MtGox|Perl module]] for interacting with the HTTP API.&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Authentication is performed by signing each request using HMAC-SHA512. The request must contain an extra value &amp;quot;nonce&amp;quot; which must be an always incrementing numeric value.  A reference implementation is provided here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function mtgox_query($path, array $req = array()) {&lt;br /&gt;
	// API settings&lt;br /&gt;
	$key = &#039;&#039;;&lt;br /&gt;
	$secret = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems&lt;br /&gt;
	$mt = explode(&#039; &#039;, microtime());&lt;br /&gt;
	$req[&#039;nonce&#039;] = $mt[1].substr($mt[0], 2, 6);&lt;br /&gt;
&lt;br /&gt;
	// generate the POST data string&lt;br /&gt;
	$post_data = http_build_query($req, &#039;&#039;, &#039;&amp;amp;&#039;);&lt;br /&gt;
&lt;br /&gt;
	// generate the extra headers&lt;br /&gt;
	$headers = array(&lt;br /&gt;
		&#039;Rest-Key: &#039;.$key,&lt;br /&gt;
		&#039;Rest-Sign: &#039;.base64_encode(hash_hmac(&#039;sha512&#039;, $post_data, base64_decode($secret), true)),&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	// our curl handle (initialize if required)&lt;br /&gt;
	static $ch = null;&lt;br /&gt;
	if (is_null($ch)) {&lt;br /&gt;
		$ch = curl_init();&lt;br /&gt;
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;
		curl_setopt($ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0 (compatible; MtGox PHP client; &#039;.php_uname(&#039;s&#039;).&#039;; PHP/&#039;.phpversion().&#039;)&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	curl_setopt($ch, CURLOPT_URL, &#039;https://mtgox.com/api/&#039;.$path);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;br /&gt;
&lt;br /&gt;
	// run the query&lt;br /&gt;
	$res = curl_exec($ch);&lt;br /&gt;
	if ($res === false) throw new Exception(&#039;Could not get reply: &#039;.curl_error($ch));&lt;br /&gt;
	$dec = json_decode($res, true);&lt;br /&gt;
	if (!$dec) throw new Exception(&#039;Invalid data received, please make sure connection is working and requested API exists&#039;);&lt;br /&gt;
	return $dec;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// example 1: get infos about the account, plus the list of rights we have access to&lt;br /&gt;
var_dump(mtgox_query(&#039;0/info.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// old api (get funds)&lt;br /&gt;
var_dump(mtgox_query(&#039;0/getFunds.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// trade example&lt;br /&gt;
// var_dump(mtgox_query(&#039;0/buyBTC.php&#039;, array(&#039;amount&#039; =&amp;gt; 1, &#039;price&#039; =&amp;gt; 15)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python version here: https://bitcointalk.org/index.php?topic=49789.msg592388#msg592388&lt;br /&gt;
&lt;br /&gt;
=== Cache ===&lt;br /&gt;
&lt;br /&gt;
All of the API methods below have cached results, ticker, depth . . . have a 10 seconds cache .&lt;br /&gt;
No need to poll more often, you wont have more results, you could just be blocked by the prolexic anti ddos features.&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 0===&lt;br /&gt;
&lt;br /&gt;
==== 0/data/getTrades.php ====&lt;br /&gt;
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* since: Passing a tid in &amp;quot;since&amp;quot; allows retrieving all trades since that trade. The passed id is may not exist. Ie. to get all trades from the very beginning one would just call https://mtgox.com/code/data/getTrades.php?since=0 . since returns only 100 trades, and you can call the method again by passing the latest trade you have imported in since.&lt;br /&gt;
&lt;br /&gt;
* data is returned in standard json format like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279408157,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;0.04951&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;20&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;4951&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;2000000000&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279424586,&amp;quot;price&amp;quot;:&amp;quot;0.05941&amp;quot;,&amp;quot;amount&amp;quot;:&amp;quot;50.01&amp;quot;,&amp;quot;price_int&amp;quot;:&amp;quot;5941&amp;quot;,&amp;quot;amount_int&amp;quot;:&amp;quot;5001000000&amp;quot;,&amp;quot;tid&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 0/getDepth.php ====&lt;br /&gt;
Get the current Market depth&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=USD&lt;br /&gt;
&lt;br /&gt;
==== 0/getFunds.php ====&lt;br /&gt;
Get your current balance&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getFunds.php&lt;br /&gt;
&lt;br /&gt;
getfunds is now deprecated since multi currency, please use info.php&lt;br /&gt;
&lt;br /&gt;
==== 0/buyBTC.php ====&lt;br /&gt;
Place an order to Buy BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/buyBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: amount=#&amp;amp;price=#&amp;amp;Currency=PLN&lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/sellBTC.php ====&lt;br /&gt;
Place an order to Sell BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/sellBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: &amp;amp;amount=#&amp;amp;price=#&amp;amp;Currency=PLN &lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/getOrders.php ====&lt;br /&gt;
Fetch a list of your open Orders&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getOrders.php&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
status: 1 for active, 2 for not enough funds&lt;br /&gt;
&lt;br /&gt;
==== 0/cancelOrder.php ====&lt;br /&gt;
Cancel an order&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/cancelOrder.php&lt;br /&gt;
&lt;br /&gt;
POST data: oid=#&amp;amp;type=#&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
==== 0/redeemCode.php ====&lt;br /&gt;
Used to redeem a mtgox coupon code&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/redeemCode.php&lt;br /&gt;
&lt;br /&gt;
* call with a post parameter &amp;quot;code&amp;quot; containing the code to redeem&lt;br /&gt;
&lt;br /&gt;
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status&lt;br /&gt;
&lt;br /&gt;
==== 0/withdraw.php ====&lt;br /&gt;
withdraw / Send BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/withdraw.php&lt;br /&gt;
&lt;br /&gt;
POST data: group1=BTC&amp;amp;btca=bitcoin_address_to_send_to&amp;amp;amount=#&lt;br /&gt;
&lt;br /&gt;
* pass btca parameter to withdraw to a btc adress&lt;br /&gt;
&lt;br /&gt;
* pass group1 for a coupon : BTC2CODE or USD2CODE&lt;br /&gt;
&lt;br /&gt;
* pass group1=DWUSD&amp;amp;dwaccount=XXX-XXX-XXXX (no btca=xxxxxxx) for a dwolla withdraw&lt;br /&gt;
&lt;br /&gt;
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )&lt;br /&gt;
* return code and status if successful&lt;br /&gt;
&lt;br /&gt;
 To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )&lt;br /&gt;
&lt;br /&gt;
==== 0/btcAddress.php ====&lt;br /&gt;
get a bitcoin deposit adress for your account &lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/btcAddress.php&lt;br /&gt;
&lt;br /&gt;
* pass POST data &amp;quot;description&amp;quot; to add a description that will appear in your history when this BTC address receive a deposit&lt;br /&gt;
&lt;br /&gt;
* returns a bitcoin deposit address&lt;br /&gt;
&lt;br /&gt;
==== 0/history_[CUR].csv ====&lt;br /&gt;
&lt;br /&gt;
Allows downloading your activity history for a given currency (BTC or USD for now).&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_BTC.csv&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_USD.csv&lt;br /&gt;
&lt;br /&gt;
==== 0/info.php ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/info.php&lt;br /&gt;
&lt;br /&gt;
returns info about your account, funds, fees, API privileges, withdraw limits . . . &lt;br /&gt;
&lt;br /&gt;
==== 0/ticker ====&lt;br /&gt;
&lt;br /&gt;
http://mtgox.com/api/0/data/ticker.php&lt;br /&gt;
&lt;br /&gt;
returns the current ticker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;ticker&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;:5.70653,&lt;br /&gt;
 &amp;quot;low&amp;quot;:5.4145,&lt;br /&gt;
 &amp;quot;avg&amp;quot;:5.561388723,&lt;br /&gt;
 &amp;quot;vwap&amp;quot;:5.610932845,&lt;br /&gt;
 &amp;quot;vol&amp;quot;:55698,&lt;br /&gt;
 &amp;quot;last&amp;quot;:5.56915,&lt;br /&gt;
 &amp;quot;buy&amp;quot;:5.51326,&lt;br /&gt;
 &amp;quot;sell&amp;quot;:5.5672&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours&lt;br /&gt;
&lt;br /&gt;
what is vwap ? &lt;br /&gt;
&lt;br /&gt;
please see http://en.wikipedia.org/wiki/VWAP&lt;br /&gt;
&lt;br /&gt;
=== API version 0 examples ===&lt;br /&gt;
&lt;br /&gt;
==== all api shell type CLI ====&lt;br /&gt;
&lt;br /&gt;
python : http://www.goxsh.info/&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/vEpgw5nW&lt;br /&gt;
&lt;br /&gt;
==== other ====&lt;br /&gt;
&lt;br /&gt;
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl&lt;br /&gt;
&lt;br /&gt;
https://github.com/sje397/mtgox-plasmoid&lt;br /&gt;
&lt;br /&gt;
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/&lt;br /&gt;
&lt;br /&gt;
==== gather data ====&lt;br /&gt;
&lt;br /&gt;
https://github.com/Lexiks/MyBitBoard&lt;br /&gt;
&lt;br /&gt;
==== gettrade ====&lt;br /&gt;
&lt;br /&gt;
bash : https://bitcointalk.org/index.php?topic=39402.0&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/raw.php?i=pmhMXZJu&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
&lt;br /&gt;
http://pastebin.com/pd0ZR4WY&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 1===&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency Ticker ====&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
==== Multi currency trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelled Trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
==== Full Depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
==== Private info ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/info&lt;br /&gt;
&lt;br /&gt;
returns information about your account, funds, fees, API privileges, withdraw limits . . .&lt;br /&gt;
&lt;br /&gt;
==== Your open orders ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/private/orders&lt;br /&gt;
 &lt;br /&gt;
returns information about your current open orders&lt;br /&gt;
&lt;br /&gt;
==== Currency information ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/currency&lt;br /&gt;
&lt;br /&gt;
pass parameter ?currency=&amp;lt;currency_symbol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
returns information about a currency ( number of decimals . . . )&lt;br /&gt;
&lt;br /&gt;
==== HOTP key ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/generic/public/hotp_gen&lt;br /&gt;
&lt;br /&gt;
used to generate a new HOTP key ( useful for developpers )&lt;br /&gt;
&lt;br /&gt;
== Streaming API ==&lt;br /&gt;
Real time streaming data may be obtained over the streaming API, implemented in [http://socket.io/ Socket.io]&amp;lt;ref&amp;gt;Socket.io forum announcement by MagicalTux: https://bitcointalk.org/index.php?topic=14412.msg613271#msg613271&amp;lt;/ref&amp;gt;. The original WebSocket API&amp;lt;ref&amp;gt;Original WebSocket thread: https://bitcointalk.org/index.php?topic=5855.msg86219&amp;lt;/ref&amp;gt; is deprecated as of 11-Nov-2011.&lt;br /&gt;
&lt;br /&gt;
===Connecting===&lt;br /&gt;
The following JavaScript code establishes a connection in the browser:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://socketio.mtgox.com/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
    var conn = io.connect(&#039;https://socketio.mtgox.com/mtgox&#039;);&lt;br /&gt;
    conn.on(&#039;message&#039;, function(data) {&lt;br /&gt;
        // Handle incoming data object.&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session ID expires after 30 seconds&lt;br /&gt;
&lt;br /&gt;
===Handling Events===&lt;br /&gt;
Socket.io exposes a simple interface for handling events. Handling &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; events is shown above, but there are other events that may be handled:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
conn.on(&#039;connect&#039;,    onConnect);&lt;br /&gt;
conn.on(&#039;disconnect&#039;, onDisconnect);&lt;br /&gt;
conn.on(&#039;error&#039;,      onError);&lt;br /&gt;
conn.on(&#039;message&#039;,    onMessage);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Incoming Data===&lt;br /&gt;
Data arrives as a full object instead of as JSON text, eliminating the need to parse the data in the JavaScript handler. Messages that come across the socket to trigger the &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; event will contain the following minimum components:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;lt;OPERATION_TYPE&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;OPERATION_TYPE&amp;lt;/tt&amp;gt; field may take these values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! OPERATION_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| subscribe || Notification that the user is subscribed to a channel&lt;br /&gt;
|-&lt;br /&gt;
| unsubscribe || Messages will no longer arrive over the channel&lt;br /&gt;
|-&lt;br /&gt;
| remark || A server message, usually a warning&lt;br /&gt;
|-&lt;br /&gt;
| private || The operation for depth, trade, and ticker messages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:subscribe and op:unsubscribe===&lt;br /&gt;
The subscribe and unsubscribe message data are very simple, containing the channel and the operation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;subscribe&amp;quot; OR &amp;quot;unsubscribe&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some of the channels are:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel ID !! Description&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:remark===&lt;br /&gt;
The remark operation contains message and success fields.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;remark&amp;quot;,&lt;br /&gt;
  &amp;quot;message&amp;quot;:&amp;lt;MESSAGE FROM THE SERVER&amp;gt;,&lt;br /&gt;
  &amp;quot;success&amp;quot;:&amp;lt;boolean&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===op:private===&lt;br /&gt;
The payloads of the &amp;lt;tt&amp;gt;op:private&amp;lt;/tt&amp;gt; messages contain the real time market information. Each message follows this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;lt;MESSAGE_TYPE&amp;gt;,&lt;br /&gt;
  &amp;lt;MESSAGE_TYPE&amp;gt;:&amp;lt;DATA_PAYLOAD&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;MESSAGE_TYPE&amp;lt;/tt&amp;gt; field may take the values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MESSAGE_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| ticker || Ticker messages&lt;br /&gt;
|-&lt;br /&gt;
| trade || Trades, as they occur&lt;br /&gt;
|-&lt;br /&gt;
| depth || Orders placed or removed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Ticker====&lt;br /&gt;
Ticker messages contain the current inside Bid and Ask as well as daily highs, lows, and volume. The fields contained in the ticker match those defined in the version 1.0 API above. All fields contain &amp;lt;tt&amp;gt;currency&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;display&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;value_int&amp;lt;/tt&amp;gt; entries.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;d5f06780-30a8-4a48-a2f8-7ed181b4a13f&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;ticker&amp;quot;,&lt;br /&gt;
  &amp;quot;ticker&amp;quot;:{&lt;br /&gt;
    &amp;quot;avg&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;$2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;226847&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;buy&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;high&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last&amp;quot;:{..},&lt;br /&gt;
    &amp;quot;last_local&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last_orig&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;low&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;sell&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;vol&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;118,696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;118696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;11869602104208&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;vwap&amp;quot;:{...}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trade====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;dbf1dee9-4f2e-4a08-8cb7-748919a71b21&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
  &amp;quot;trade&amp;quot;:{&lt;br /&gt;
    &amp;quot;amount&amp;quot;:2.71,&lt;br /&gt;
    &amp;quot;amount_int&amp;quot;:&amp;quot;271000000&amp;quot;,&lt;br /&gt;
    &amp;quot;date&amp;quot;:1310279340,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:14.43,&lt;br /&gt;
    &amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;tid&amp;quot;:&amp;quot;1310279340877902&amp;quot;,&lt;br /&gt;
    &amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
    &amp;quot;properties&amp;quot;:&amp;quot;limit, mixed_currency&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;trade&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| amount || the traded amount in item (BTC), float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| amount_int || the traded amount * 1E8&lt;br /&gt;
|-&lt;br /&gt;
| date || unix timestamp of trade&lt;br /&gt;
|-&lt;br /&gt;
| item || What was this trade about&lt;br /&gt;
|-&lt;br /&gt;
| price || price per unit, float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)&lt;br /&gt;
|-&lt;br /&gt;
| price_currency || currency in which trade was completed&lt;br /&gt;
|-&lt;br /&gt;
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)&lt;br /&gt;
|-&lt;br /&gt;
| trade_type || Did this trade result from the execution of a bid or a ask?&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Depth====&lt;br /&gt;
&lt;br /&gt;
Changes to the market depth data are broadcast so an up-to-date market depth can be kept by clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;24e67e0d-1cad-4cc0-9e7a-f8523ef460fe&amp;quot;,&lt;br /&gt;
  &amp;quot;depth&amp;quot;:{&lt;br /&gt;
    &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;now&amp;quot;:&amp;quot;1323644358437819&amp;quot;&lt;br /&gt;
    &amp;quot;price&amp;quot;:&amp;quot;14.43&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;total_volume_int&amp;quot;:&amp;quot;849766000&amp;quot;&lt;br /&gt;
    &amp;quot;type&amp;quot;:1,&lt;br /&gt;
    &amp;quot;type_str&amp;quot;:&amp;quot;ask&amp;quot;,&lt;br /&gt;
    &amp;quot;volume&amp;quot;:&amp;quot;-2.71&amp;quot;,&lt;br /&gt;
    &amp;quot;volume_int&amp;quot;:&amp;quot;-271000000&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;depth&amp;quot;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;depth&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| currency || the currency affected&lt;br /&gt;
|-&lt;br /&gt;
| item || the item (BTC)&lt;br /&gt;
|-&lt;br /&gt;
| price || price as a float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || the price at which volume change happened (5 decimal for USD, 3 for JPY)&lt;br /&gt;
|-&lt;br /&gt;
| type || 1=ask, 2=bid. deprecated, use type_str&lt;br /&gt;
|-&lt;br /&gt;
| type_str || type of order at this depth, either &amp;quot;ask&amp;quot; or &amp;quot;bid&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| volume || the volume change as float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| volume_int || volume change * 1E8&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Possible outgoing commands===&lt;br /&gt;
&#039;&#039;&#039;unsubscribe&#039;&#039;&#039; Stop receiving messages from a channel (parameter &amp;quot;channel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== examples ===&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
javascript, using hookio : &lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=KD5ljtNK72U&lt;br /&gt;
&lt;br /&gt;
http://github.com/hookio&lt;br /&gt;
&lt;br /&gt;
http://github.com/cronopio/hook.io-mtgox&lt;br /&gt;
&lt;br /&gt;
Another node.js project, using plain websockets (largely based on cronopio&#039;s work) :&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
==== arbitrage ====&lt;br /&gt;
https://github.com/goteppo/ArBit&lt;br /&gt;
&lt;br /&gt;
==== websocket ====&lt;br /&gt;
https://github.com/cronopio/hook.io-ws&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Mt._Gox/API&amp;diff=19586</id>
		<title>Talk:Mt. Gox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Mt._Gox/API&amp;diff=19586"/>
		<updated>2011-11-18T00:26:53Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* More channels in the socket.io connection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I believe some of the inexperienced api users may have unintentionally compromised the Authentication section and examples by removing the details regarding api key &amp;amp; secret as recommended by MtGox at https://mtgox.com/support/tradeAPI. &lt;br /&gt;
The change now describes the need for user name and password. Though this old model still works in the new api model, it is not the recommended strategy because it gives applications information which would compromise the user&#039;s private account. The application SHOULD ONLY have access to the the api calls as granted by them by the user&#039;s specified api rights associated to the api key and secret.&lt;br /&gt;
&lt;br /&gt;
[[User:Automtgox|Automtgox]] 00:18, 22 September 2011 (GMT)&lt;br /&gt;
&lt;br /&gt;
== More channels in the socket.io connection ==&lt;br /&gt;
&lt;br /&gt;
Instead of the 3 channels listed in the original WebSocket connection list, I am seeing many more that I have no idea about:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel !! Description&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|-&lt;br /&gt;
| 5b234cc3-a7c1-47ce-854f-27aee4cdbda5 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 113fec5f-294d-4929-86eb-8ca4c3fd1bed || ?&lt;br /&gt;
|-&lt;br /&gt;
| 0d1ecad8-e20f-459e-8bed-0bdcf927820f || ?&lt;br /&gt;
|-&lt;br /&gt;
| 9219abb0-b50c-4007-b4d2-51d1711ab19c || ?&lt;br /&gt;
|-&lt;br /&gt;
| 057bdc6b-9f9c-44e4-bc1a-363e4443ce87 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 60c3af1b-5d40-4d0e-b9fc-ccab433d2e9c || ?&lt;br /&gt;
|-&lt;br /&gt;
| 049f65dc-3af3-4ffd-85a5-aac102b2a579 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 94483e07-d797-4dd4-bc72-dc98f1fd39e3 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 66da7fb4-6b0c-4a10-9cb7-e2944e046eb5 || ?&lt;br /&gt;
|-&lt;br /&gt;
| cedf8730-bce6-4278-b6fe-9bee42930e95 || ?&lt;br /&gt;
|-&lt;br /&gt;
| e4ff055a-f8bf-407e-af76-676cad319a21 || ?&lt;br /&gt;
|-&lt;br /&gt;
| d6412ca0-b686-464c-891a-d1ba3943f3c6 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 8f1fefaa-7c55-4420-ada0-4de15c1c38f3 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 41e5c243-3d44-4fad-b690-f39e1dbb86a8 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 67879668-532f-41f9-8eb0-55e7593a5ab8 || ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And more...&lt;br /&gt;
&lt;br /&gt;
--[[User:Clark|Clark]] 00:26, 18 November 2011 (GMT)&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Talk:Mt._Gox/API&amp;diff=19585</id>
		<title>Talk:Mt. Gox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Talk:Mt._Gox/API&amp;diff=19585"/>
		<updated>2011-11-18T00:26:30Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* More channels in the socket.io connection */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I believe some of the inexperienced api users may have unintentionally compromised the Authentication section and examples by removing the details regarding api key &amp;amp; secret as recommended by MtGox at https://mtgox.com/support/tradeAPI. &lt;br /&gt;
The change now describes the need for user name and password. Though this old model still works in the new api model, it is not the recommended strategy because it gives applications information which would compromise the user&#039;s private account. The application SHOULD ONLY have access to the the api calls as granted by them by the user&#039;s specified api rights associated to the api key and secret.&lt;br /&gt;
&lt;br /&gt;
[[User:Automtgox|Automtgox]] 00:18, 22 September 2011 (GMT)&lt;br /&gt;
&lt;br /&gt;
== More channels in the socket.io connection ==&lt;br /&gt;
&lt;br /&gt;
Instead of the 3 channels listed in the original WebSocket connection list, I am seeing many more that I have no idea about:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel !! Description&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|-&lt;br /&gt;
| 5b234cc3-a7c1-47ce-854f-27aee4cdbda5 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 113fec5f-294d-4929-86eb-8ca4c3fd1bed || ?&lt;br /&gt;
|-&lt;br /&gt;
| 0d1ecad8-e20f-459e-8bed-0bdcf927820f || ?&lt;br /&gt;
|-&lt;br /&gt;
| 9219abb0-b50c-4007-b4d2-51d1711ab19c || ?&lt;br /&gt;
|-&lt;br /&gt;
| 057bdc6b-9f9c-44e4-bc1a-363e4443ce87 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 60c3af1b-5d40-4d0e-b9fc-ccab433d2e9c || ?&lt;br /&gt;
|-&lt;br /&gt;
| 049f65dc-3af3-4ffd-85a5-aac102b2a579 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 94483e07-d797-4dd4-bc72-dc98f1fd39e3 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 66da7fb4-6b0c-4a10-9cb7-e2944e046eb5 || ?&lt;br /&gt;
|-&lt;br /&gt;
| cedf8730-bce6-4278-b6fe-9bee42930e95 || ?&lt;br /&gt;
|-&lt;br /&gt;
| e4ff055a-f8bf-407e-af76-676cad319a21 || ?&lt;br /&gt;
|-&lt;br /&gt;
| d6412ca0-b686-464c-891a-d1ba3943f3c6 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 8f1fefaa-7c55-4420-ada0-4de15c1c38f3 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 41e5c243-3d44-4fad-b690-f39e1dbb86a8 || ?&lt;br /&gt;
|-&lt;br /&gt;
| 67879668-532f-41f9-8eb0-55e7593a5ab8 || ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And more...&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=19584</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=19584"/>
		<updated>2011-11-18T00:19:49Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* Websocket API */ Heavy update of streaming data section to include socket.io&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides various methods to access different informations from the market, place orders, and more.&lt;br /&gt;
&lt;br /&gt;
Two APIs are available at this point: the HTTP api (available by posting to mtgox.com/code/*) and the websocket API.&lt;br /&gt;
&lt;br /&gt;
==Number Formats==&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;old API&amp;quot;, currency- and amount-values (price, volume,...) were given as &#039;&#039;&#039;float&#039;&#039;&#039;. These values are likely being deprecated and replaced by fields of the same name with &amp;quot;_int&amp;quot; as suffix. These are &#039;&#039;&#039;fixed-decimal&#039;&#039;&#039;, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.&lt;br /&gt;
&lt;br /&gt;
In order to convert the &#039;&#039;&#039;int&#039;&#039;&#039; to a &#039;&#039;&#039;decimal&#039;&#039;&#039; you can...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! kind of field !! ...divide by !! ...multiply by&lt;br /&gt;
|-&lt;br /&gt;
| BTC (volume, amount) || 1E8 (10,000,000) || 0.00000001&lt;br /&gt;
|-&lt;br /&gt;
| USD (price) || 1E5 (100,000) || 0.00001&lt;br /&gt;
|-&lt;br /&gt;
| JPY (price) || 1E3 (1,000) || 0.001&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Implementation advice: it&#039;s probably best to use &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;Decimal&#039;&#039;&#039; (if your language/db offers such a type) in your clients. Using &#039;&#039;&#039;float&#039;&#039;&#039; will likely lead to nasty rounding problems.&lt;br /&gt;
&lt;br /&gt;
== Currency Symbols ==&lt;br /&gt;
List of the currency symbols available with the API:&lt;br /&gt;
&lt;br /&gt;
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB&lt;br /&gt;
&lt;br /&gt;
== HTTP API ==&lt;br /&gt;
This API is available in &amp;lt;nowiki&amp;gt;https://mtgox.com/api/*&amp;lt;/nowiki&amp;gt;, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.  There is also a [https://rubygems.org/gems/mtgox Ruby gem] and [[Finance::MtGox|Perl module]] for interacting with the HTTP API.&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Authentication is performed by signing each request using HMAC-SHA512. The request must contain an extra value &amp;quot;nonce&amp;quot; which must be an always incrementing numeric value.  A reference implementation is provided here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function mtgox_query($path, array $req = array()) {&lt;br /&gt;
	// API settings&lt;br /&gt;
	$key = &#039;&#039;;&lt;br /&gt;
	$secret = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems&lt;br /&gt;
	$mt = explode(&#039; &#039;, microtime());&lt;br /&gt;
	$req[&#039;nonce&#039;] = $mt[1].substr($mt[0], 2, 6);&lt;br /&gt;
&lt;br /&gt;
	// generate the POST data string&lt;br /&gt;
	$post_data = http_build_query($req, &#039;&#039;, &#039;&amp;amp;&#039;);&lt;br /&gt;
&lt;br /&gt;
	// generate the extra headers&lt;br /&gt;
	$headers = array(&lt;br /&gt;
		&#039;Rest-Key: &#039;.$key,&lt;br /&gt;
		&#039;Rest-Sign: &#039;.base64_encode(hash_hmac(&#039;sha512&#039;, $post_data, base64_decode($secret), true)),&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	// our curl handle (initialize if required)&lt;br /&gt;
	static $ch = null;&lt;br /&gt;
	if (is_null($ch)) {&lt;br /&gt;
		$ch = curl_init();&lt;br /&gt;
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;
		curl_setopt($ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0 (compatible; MtGox PHP client; &#039;.php_uname(&#039;s&#039;).&#039;; PHP/&#039;.phpversion().&#039;)&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	curl_setopt($ch, CURLOPT_URL, &#039;https://mtgox.com/api/&#039;.$path);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;br /&gt;
&lt;br /&gt;
	// run the query&lt;br /&gt;
	$res = curl_exec($ch);&lt;br /&gt;
	if ($res === false) throw new Exception(&#039;Could not get reply: &#039;.curl_error($ch));&lt;br /&gt;
	$dec = json_decode($res, true);&lt;br /&gt;
	if (!$dec) throw new Exception(&#039;Invalid data received, please make sure connection is working and requested API exists&#039;);&lt;br /&gt;
	return $dec;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// example 1: get infos about the account, plus the list of rights we have access to&lt;br /&gt;
var_dump(mtgox_query(&#039;0/info.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// old api (get funds)&lt;br /&gt;
var_dump(mtgox_query(&#039;0/getFunds.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// trade example&lt;br /&gt;
// var_dump(mtgox_query(&#039;0/buyBTC.php&#039;, array(&#039;amount&#039; =&amp;gt; 1, &#039;price&#039; =&amp;gt; 15)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python version here: https://bitcointalk.org/index.php?topic=49789.msg592388#msg592388&lt;br /&gt;
&lt;br /&gt;
=== Cache ===&lt;br /&gt;
&lt;br /&gt;
All of the API methods below have cached results, ticker, depth . . . have a 10 seconds cache .&lt;br /&gt;
No need to poll more often, you wont have more results, you could just be blocked by the prolexic anti ddos features.&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 0===&lt;br /&gt;
&lt;br /&gt;
==== 0/data/getTrades.php ====&lt;br /&gt;
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* since: Passing a tid in &amp;quot;since&amp;quot; allows retrieving all trades since that trade. The passed id is may not exist. Ie. to get all trades from the very beginning one would just call https://mtgox.com/code/data/getTrades.php?since=0 . since returns only 100 trades, and you can call the method again by passing the latest trade you have imported in since.&lt;br /&gt;
&lt;br /&gt;
* data is returned in standard json format like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279408157,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;0.04951&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;20&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;4951&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;2000000000&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279424586,&amp;quot;price&amp;quot;:&amp;quot;0.05941&amp;quot;,&amp;quot;amount&amp;quot;:&amp;quot;50.01&amp;quot;,&amp;quot;price_int&amp;quot;:&amp;quot;5941&amp;quot;,&amp;quot;amount_int&amp;quot;:&amp;quot;5001000000&amp;quot;,&amp;quot;tid&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 0/getDepth.php ====&lt;br /&gt;
Get the current Market depth&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=USD&lt;br /&gt;
&lt;br /&gt;
==== 0/getFunds.php ====&lt;br /&gt;
Get your current balance&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getFunds.php&lt;br /&gt;
&lt;br /&gt;
getfunds is now deprecated since multi currency, please use info.php&lt;br /&gt;
&lt;br /&gt;
==== 0/buyBTC.php ====&lt;br /&gt;
Place an order to Buy BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/buyBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: amount=#&amp;amp;price=#&amp;amp;Currency=PLN&lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/sellBTC.php ====&lt;br /&gt;
Place an order to Sell BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/sellBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: &amp;amp;amount=#&amp;amp;price=#&amp;amp;Currency=PLN &lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/getOrders.php ====&lt;br /&gt;
Fetch a list of your open Orders&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getOrders.php&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
status: 1 for active, 2 for not enough funds&lt;br /&gt;
&lt;br /&gt;
==== 0/cancelOrder.php ====&lt;br /&gt;
Cancel an order&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/cancelOrder.php&lt;br /&gt;
&lt;br /&gt;
POST data: oid=#&amp;amp;type=#&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
==== 0/redeemCode.php ====&lt;br /&gt;
Used to redeem a mtgox coupon code&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/redeemCode.php&lt;br /&gt;
&lt;br /&gt;
* call with a post parameter &amp;quot;code&amp;quot; containing the code to redeem&lt;br /&gt;
&lt;br /&gt;
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status&lt;br /&gt;
&lt;br /&gt;
==== 0/withdraw.php ====&lt;br /&gt;
withdraw / Send BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/withdraw.php&lt;br /&gt;
&lt;br /&gt;
POST data: group1=BTC&amp;amp;btca=bitcoin_address_to_send_to&amp;amp;amount=#&lt;br /&gt;
&lt;br /&gt;
* pass btca parameter to withdraw to a btc adress&lt;br /&gt;
&lt;br /&gt;
* pass group1 for a coupon : BTC2CODE or USD2CODE&lt;br /&gt;
&lt;br /&gt;
* pass group1=DWUSD for a dwolla withdraw&lt;br /&gt;
&lt;br /&gt;
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )&lt;br /&gt;
* return code and status if successful&lt;br /&gt;
&lt;br /&gt;
 To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )&lt;br /&gt;
&lt;br /&gt;
==== 0/btcAddress.php ====&lt;br /&gt;
get a bitcoin deposit adress for your account &lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/btcAddress.php&lt;br /&gt;
&lt;br /&gt;
* pass POST data &amp;quot;description&amp;quot; to add a description that will appear in your history when this BTC address receive a deposit&lt;br /&gt;
&lt;br /&gt;
* returns a bitcoin deposit address&lt;br /&gt;
&lt;br /&gt;
==== 0/history_[CUR].csv ====&lt;br /&gt;
&lt;br /&gt;
Allows downloading your activity history for a given currency (BTC or USD for now).&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_BTC.csv&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_USD.csv&lt;br /&gt;
&lt;br /&gt;
==== 0/info.php ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/info.php&lt;br /&gt;
&lt;br /&gt;
returns info about your account, funds, fees, API privileges . . . &lt;br /&gt;
&lt;br /&gt;
==== 0/ticker ====&lt;br /&gt;
&lt;br /&gt;
http://mtgox.com/api/0/data/ticker.php&lt;br /&gt;
&lt;br /&gt;
returns the current ticker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;ticker&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;:5.70653,&lt;br /&gt;
 &amp;quot;low&amp;quot;:5.4145,&lt;br /&gt;
 &amp;quot;avg&amp;quot;:5.561388723,&lt;br /&gt;
 &amp;quot;vwap&amp;quot;:5.610932845,&lt;br /&gt;
 &amp;quot;vol&amp;quot;:55698,&lt;br /&gt;
 &amp;quot;last&amp;quot;:5.56915,&lt;br /&gt;
 &amp;quot;buy&amp;quot;:5.51326,&lt;br /&gt;
 &amp;quot;sell&amp;quot;:5.5672&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours&lt;br /&gt;
&lt;br /&gt;
what is vwap ? &lt;br /&gt;
&lt;br /&gt;
please see http://en.wikipedia.org/wiki/VWAP&lt;br /&gt;
&lt;br /&gt;
=== API version 0 examples ===&lt;br /&gt;
&lt;br /&gt;
==== all api shell type CLI ====&lt;br /&gt;
&lt;br /&gt;
python : http://www.goxsh.info/&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/vEpgw5nW&lt;br /&gt;
&lt;br /&gt;
==== other ====&lt;br /&gt;
&lt;br /&gt;
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl&lt;br /&gt;
&lt;br /&gt;
https://github.com/sje397/mtgox-plasmoid&lt;br /&gt;
&lt;br /&gt;
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/&lt;br /&gt;
&lt;br /&gt;
==== gather data ====&lt;br /&gt;
&lt;br /&gt;
https://github.com/Lexiks/MyBitBoard&lt;br /&gt;
&lt;br /&gt;
==== gettrade ====&lt;br /&gt;
&lt;br /&gt;
bash : https://bitcointalk.org/index.php?topic=39402.0&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/raw.php?i=pmhMXZJu&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
&lt;br /&gt;
http://pastebin.com/pd0ZR4WY&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 1===&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency Ticker ====&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
==== Multi currency trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelled Trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
==== Full Depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
== Streaming API ==&lt;br /&gt;
Real time streaming data may be obtained over the streaming API, implemented in [http://socket.io/ Socket.io]&amp;lt;ref&amp;gt;Socket.io forum announcement by MagicalTux: https://bitcointalk.org/index.php?topic=14412.msg613271#msg613271&amp;lt;/ref&amp;gt;. The original WebSocket API&amp;lt;ref&amp;gt;Original WebSocket thread: https://bitcointalk.org/index.php?topic=5855.msg86219&amp;lt;/ref&amp;gt; is deprecated as of 11-Nov-2011.&lt;br /&gt;
&lt;br /&gt;
===Connecting===&lt;br /&gt;
The following JavaScript code establishes a connection in the browser:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;https://socketio.mtgox.com/socket.io/socket.io.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
    var conn = io.connect(&#039;https://socketio.mtgox.com/mtgox&#039;);&lt;br /&gt;
    conn.on(&#039;message&#039;, function(data) {&lt;br /&gt;
        // Handle incoming data object.&lt;br /&gt;
    });&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Handling Events===&lt;br /&gt;
Socket.io exposes a simple interface for handling events. Handling &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; events is shown above, but there are other events that may be handled:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
conn.on(&#039;connect&#039;,    onConnect);&lt;br /&gt;
conn.on(&#039;disconnect&#039;, onDisconnect);&lt;br /&gt;
conn.on(&#039;error&#039;,      onError);&lt;br /&gt;
conn.on(&#039;message&#039;,    onMessage);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Incoming Data===&lt;br /&gt;
Data arrives as a full object instead of as JSON text, eliminating the need to parse the data in the JavaScript handler. Messages that come across the socket to trigger the &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; event will contain the following minimum components:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;lt;OPERATION_TYPE&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;OPERATION_TYPE&amp;lt;/tt&amp;gt; field may take a few values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! OPERATION_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| subscribe || Notification that the user is subscribed to a channel&lt;br /&gt;
|-&lt;br /&gt;
| unsubscribe || Messages will no longer arrive over the channel&lt;br /&gt;
|-&lt;br /&gt;
| remark || A server message, usually a warning&lt;br /&gt;
|-&lt;br /&gt;
| private || The operation for depth, trade, and ticker messages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:subscribe and op:unsubscribe===&lt;br /&gt;
The subscribe and unsubscribe message data are very simple, containing the channel and the operation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;subscribe&amp;quot; OR &amp;quot;unsubscribe&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some of the channels are:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel ID !! Description&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || Trades&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || Ticker&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || Depth&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===op:remark===&lt;br /&gt;
The remark operation contains message and success fields.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;remark&amp;quot;,&lt;br /&gt;
  &amp;quot;message&amp;quot;:&amp;lt;MESSAGE FROM THE SERVER&amp;gt;,&lt;br /&gt;
  &amp;quot;success&amp;quot;:&amp;lt;boolean&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===op:private===&lt;br /&gt;
The payloads of the &amp;lt;tt&amp;gt;op:private&amp;lt;/tt&amp;gt; messages contain the real time market information. Each message follows this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;lt;CHANNEL_ID&amp;gt;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;lt;MESSAGE_TYPE&amp;gt;,&lt;br /&gt;
  &amp;lt;MESSAGE_TYPE&amp;gt;:&amp;lt;DATA_PAYLOAD&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;MESSAGE_TYPE&amp;lt;/tt&amp;gt; field may take the values:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MESSAGE_TYPE !! Description&lt;br /&gt;
|-&lt;br /&gt;
| ticker || Ticker messages&lt;br /&gt;
|-&lt;br /&gt;
| trade || Trades, as they occur&lt;br /&gt;
|-&lt;br /&gt;
| depth || Orders placed or removed&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Ticker====&lt;br /&gt;
Ticker messages contain the current inside Bid and Ask as well as daily highs, lows, and volume. The fields contained in the ticker match those defined in the version 1.0 API above. All fields contain &amp;lt;tt&amp;gt;currency&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;display&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;value_int&amp;lt;/tt&amp;gt; entries.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;d5f06780-30a8-4a48-a2f8-7ed181b4a13f&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;ticker&amp;quot;,&lt;br /&gt;
  &amp;quot;ticker&amp;quot;:{&lt;br /&gt;
    &amp;quot;avg&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;$2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;2.26847&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;226847&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;buy&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;high&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last&amp;quot;:{..},&lt;br /&gt;
    &amp;quot;last_local&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;last_orig&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;low&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;sell&amp;quot;:{...},&lt;br /&gt;
    &amp;quot;vol&amp;quot;:{&lt;br /&gt;
      &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
      &amp;quot;display&amp;quot;:&amp;quot;118,696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value&amp;quot;:&amp;quot;118696.02104208&amp;quot;,&lt;br /&gt;
      &amp;quot;value_int&amp;quot;:&amp;quot;11869602104208&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;vwap&amp;quot;:{...}&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trade====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;dbf1dee9-4f2e-4a08-8cb7-748919a71b21&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
  &amp;quot;trade&amp;quot;:{&lt;br /&gt;
    &amp;quot;amount&amp;quot;:2.71,&lt;br /&gt;
    &amp;quot;amount_int&amp;quot;:&amp;quot;271000000&amp;quot;,&lt;br /&gt;
    &amp;quot;date&amp;quot;:1310279340,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:14.43,&lt;br /&gt;
    &amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;tid&amp;quot;:&amp;quot;1310279340877902&amp;quot;,&lt;br /&gt;
    &amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:&amp;quot;trade&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;trade&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| amount || the traded amount in item (BTC), float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| amount_int || the traded amount * 1E8&lt;br /&gt;
|-&lt;br /&gt;
| date || unix timestamp of trade&lt;br /&gt;
|-&lt;br /&gt;
| item || What was this trade about&lt;br /&gt;
|-&lt;br /&gt;
| price || price per unit, float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)&lt;br /&gt;
|-&lt;br /&gt;
| price_currency || currency in which trade was completed&lt;br /&gt;
|-&lt;br /&gt;
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)&lt;br /&gt;
|-&lt;br /&gt;
| trade_type || Did this trade result from the execution of a bid or a ask?&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Depth====&lt;br /&gt;
&lt;br /&gt;
Changes to the market depth data are broadcast so an up-to-date market depth can be kept by clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;24e67e0d-1cad-4cc0-9e7a-f8523ef460fe&amp;quot;,&lt;br /&gt;
  &amp;quot;depth&amp;quot;:{&lt;br /&gt;
    &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:&amp;quot;14.43&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:1,&lt;br /&gt;
    &amp;quot;type_str&amp;quot;:&amp;quot;ask&amp;quot;,&lt;br /&gt;
    &amp;quot;volume&amp;quot;:&amp;quot;-2.71&amp;quot;,&lt;br /&gt;
    &amp;quot;volume_int&amp;quot;:&amp;quot;-271000000&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;depth&amp;quot;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;depth&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| currency || the currency affected&lt;br /&gt;
|-&lt;br /&gt;
| item || the item (BTC)&lt;br /&gt;
|-&lt;br /&gt;
| price || price as a float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || the price at which volume change happened (5 decimal for USD, 3 for JPY)&lt;br /&gt;
|-&lt;br /&gt;
| type || 1=ask, 2=bid. deprecated, use type_str&lt;br /&gt;
|-&lt;br /&gt;
| type_str || type of order at this depth, either &amp;quot;ask&amp;quot; or &amp;quot;bid&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| volume || the volume change as float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| volume_int || volume change * 1E8&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Possible outgoing commands===&lt;br /&gt;
&#039;&#039;&#039;unsubscribe&#039;&#039;&#039; Stop receiving messages from a channel (parameter &amp;quot;channel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== examples ===&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
javascript, using hookio : &lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=KD5ljtNK72U&lt;br /&gt;
&lt;br /&gt;
http://github.com/hookio&lt;br /&gt;
&lt;br /&gt;
http://github.com/cronopio/hook.io-mtgox&lt;br /&gt;
&lt;br /&gt;
Another node.js project, using plain websockets (largely based on cronopio&#039;s work) :&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
==== arbitrage ====&lt;br /&gt;
https://github.com/goteppo/ArBit&lt;br /&gt;
&lt;br /&gt;
==== websocket ====&lt;br /&gt;
https://github.com/cronopio/hook.io-ws&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=19573</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=19573"/>
		<updated>2011-11-17T21:10:29Z</updated>

		<summary type="html">&lt;p&gt;Clark: /* currency symbols */  Formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides various methods to access different informations from the market, place orders, and more.&lt;br /&gt;
&lt;br /&gt;
Two APIs are available at this point: the HTTP api (available by posting to mtgox.com/code/*) and the websocket API.&lt;br /&gt;
&lt;br /&gt;
==Number Formats==&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;old API&amp;quot;, currency- and amount-values (price, volume,...) were given as &#039;&#039;&#039;float&#039;&#039;&#039;. These values are likely being deprecated and replaced by fields of the same name with &amp;quot;_int&amp;quot; as suffix. These are &#039;&#039;&#039;fixed-decimal&#039;&#039;&#039;, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.&lt;br /&gt;
&lt;br /&gt;
In order to convert the &#039;&#039;&#039;int&#039;&#039;&#039; to a &#039;&#039;&#039;decimal&#039;&#039;&#039; you can...&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! kind of field !! ...divide by !! ...multiply by&lt;br /&gt;
|-&lt;br /&gt;
| BTC (volume, amount) || 1E8 (10,000,000) || 0.00000001&lt;br /&gt;
|-&lt;br /&gt;
| USD (price) || 1E5 (100,000) || 0.00001&lt;br /&gt;
|-&lt;br /&gt;
| JPY (price) || 1E3 (1,000) || 0.001&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Implementation advice: it&#039;s probably best to use &#039;&#039;&#039;int&#039;&#039;&#039; or &#039;&#039;&#039;Decimal&#039;&#039;&#039; (if your language/db offers such a type) in your clients. Using &#039;&#039;&#039;float&#039;&#039;&#039; will likely lead to nasty rounding problems.&lt;br /&gt;
&lt;br /&gt;
== Currency Symbols ==&lt;br /&gt;
List of the currency symbols available with the API:&lt;br /&gt;
&lt;br /&gt;
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB&lt;br /&gt;
&lt;br /&gt;
== HTTP API ==&lt;br /&gt;
This API is available in &amp;lt;nowiki&amp;gt;https://mtgox.com/api/*&amp;lt;/nowiki&amp;gt;, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.  There is also a [https://rubygems.org/gems/mtgox Ruby gem] and [[Finance::MtGox|Perl module]] for interacting with the HTTP API.&lt;br /&gt;
&lt;br /&gt;
=== Authentication ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Authentication is performed by signing each request using HMAC-SHA512. The request must contain an extra value &amp;quot;nonce&amp;quot; which must be an always incrementing numeric value.  A reference implementation is provided here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function mtgox_query($path, array $req = array()) {&lt;br /&gt;
	// API settings&lt;br /&gt;
	$key = &#039;&#039;;&lt;br /&gt;
	$secret = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems&lt;br /&gt;
	$mt = explode(&#039; &#039;, microtime());&lt;br /&gt;
	$req[&#039;nonce&#039;] = $mt[1].substr($mt[0], 2, 6);&lt;br /&gt;
&lt;br /&gt;
	// generate the POST data string&lt;br /&gt;
	$post_data = http_build_query($req, &#039;&#039;, &#039;&amp;amp;&#039;);&lt;br /&gt;
&lt;br /&gt;
	// generate the extra headers&lt;br /&gt;
	$headers = array(&lt;br /&gt;
		&#039;Rest-Key: &#039;.$key,&lt;br /&gt;
		&#039;Rest-Sign: &#039;.base64_encode(hash_hmac(&#039;sha512&#039;, $post_data, base64_decode($secret), true)),&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	// our curl handle (initialize if required)&lt;br /&gt;
	static $ch = null;&lt;br /&gt;
	if (is_null($ch)) {&lt;br /&gt;
		$ch = curl_init();&lt;br /&gt;
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);&lt;br /&gt;
		curl_setopt($ch, CURLOPT_USERAGENT, &#039;Mozilla/4.0 (compatible; MtGox PHP client; &#039;.php_uname(&#039;s&#039;).&#039;; PHP/&#039;.phpversion().&#039;)&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	curl_setopt($ch, CURLOPT_URL, &#039;https://mtgox.com/api/&#039;.$path);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);&lt;br /&gt;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);&lt;br /&gt;
&lt;br /&gt;
	// run the query&lt;br /&gt;
	$res = curl_exec($ch);&lt;br /&gt;
	if ($res === false) throw new Exception(&#039;Could not get reply: &#039;.curl_error($ch));&lt;br /&gt;
	$dec = json_decode($res, true);&lt;br /&gt;
	if (!$dec) throw new Exception(&#039;Invalid data received, please make sure connection is working and requested API exists&#039;);&lt;br /&gt;
	return $dec;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// example 1: get infos about the account, plus the list of rights we have access to&lt;br /&gt;
var_dump(mtgox_query(&#039;0/info.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// old api (get funds)&lt;br /&gt;
var_dump(mtgox_query(&#039;0/getFunds.php&#039;));&lt;br /&gt;
&lt;br /&gt;
// trade example&lt;br /&gt;
// var_dump(mtgox_query(&#039;0/buyBTC.php&#039;, array(&#039;amount&#039; =&amp;gt; 1, &#039;price&#039; =&amp;gt; 15)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python version here: https://bitcointalk.org/index.php?topic=49789.msg592388#msg592388&lt;br /&gt;
&lt;br /&gt;
=== Cache ===&lt;br /&gt;
&lt;br /&gt;
All of the API methods below have cached results, ticker, depth . . . have a 10 seconds cache .&lt;br /&gt;
No need to poll more often, you wont have more results, you could just be blocked by the prolexic anti ddos features.&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 0===&lt;br /&gt;
&lt;br /&gt;
==== 0/data/getTrades.php ====&lt;br /&gt;
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* since: Passing a tid in &amp;quot;since&amp;quot; allows retrieving all trades since that trade. The passed id is may not exist. Ie. to get all trades from the very beginning one would just call https://mtgox.com/code/data/getTrades.php?since=0 . since returns only 100 trades, and you can call the method again by passing the latest trade you have imported in since.&lt;br /&gt;
&lt;br /&gt;
* data is returned in standard json format like :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
[&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279408157,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;0.04951&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;20&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;4951&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;2000000000&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;&lt;br /&gt;
},&lt;br /&gt;
{&amp;quot;date&amp;quot;:1279424586,&amp;quot;price&amp;quot;:&amp;quot;0.05941&amp;quot;,&amp;quot;amount&amp;quot;:&amp;quot;50.01&amp;quot;,&amp;quot;price_int&amp;quot;:&amp;quot;5941&amp;quot;,&amp;quot;amount_int&amp;quot;:&amp;quot;5001000000&amp;quot;,&amp;quot;tid&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&amp;quot;trade_type&amp;quot;:&amp;quot;&amp;quot;}]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 0/getDepth.php ====&lt;br /&gt;
Get the current Market depth&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/data/getDepth.php?Currency=USD&lt;br /&gt;
&lt;br /&gt;
==== 0/getFunds.php ====&lt;br /&gt;
Get your current balance&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getFunds.php&lt;br /&gt;
&lt;br /&gt;
getfunds is now deprecated since multi currency, please use info.php&lt;br /&gt;
&lt;br /&gt;
==== 0/buyBTC.php ====&lt;br /&gt;
Place an order to Buy BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/buyBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: amount=#&amp;amp;price=#&amp;amp;Currency=PLN&lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/sellBTC.php ====&lt;br /&gt;
Place an order to Sell BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/sellBTC.php&lt;br /&gt;
&lt;br /&gt;
POST data: &amp;amp;amount=#&amp;amp;price=#&amp;amp;Currency=PLN &lt;br /&gt;
&lt;br /&gt;
returns a list of your open orders&lt;br /&gt;
&lt;br /&gt;
you can omit the price to do a market order&lt;br /&gt;
&lt;br /&gt;
==== 0/getOrders.php ====&lt;br /&gt;
Fetch a list of your open Orders&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/getOrders.php&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
status: 1 for active, 2 for not enough funds&lt;br /&gt;
&lt;br /&gt;
==== 0/cancelOrder.php ====&lt;br /&gt;
Cancel an order&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/cancelOrder.php&lt;br /&gt;
&lt;br /&gt;
POST data: oid=#&amp;amp;type=#&lt;br /&gt;
&lt;br /&gt;
oid: Order ID&lt;br /&gt;
&lt;br /&gt;
type: 1 for sell order or 2 for buy order&lt;br /&gt;
&lt;br /&gt;
==== 0/redeemCode.php ====&lt;br /&gt;
Used to redeem a mtgox coupon code&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/redeemCode.php&lt;br /&gt;
&lt;br /&gt;
* call with a post parameter &amp;quot;code&amp;quot; containing the code to redeem&lt;br /&gt;
&lt;br /&gt;
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status&lt;br /&gt;
&lt;br /&gt;
==== 0/withdraw.php ====&lt;br /&gt;
withdraw / Send BTC&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/withdraw.php&lt;br /&gt;
&lt;br /&gt;
POST data: group1=BTC&amp;amp;btca=bitcoin_address_to_send_to&amp;amp;amount=#&lt;br /&gt;
&lt;br /&gt;
* pass btca parameter to withdraw to a btc adress&lt;br /&gt;
&lt;br /&gt;
* pass group1 for a coupon : BTC2CODE or USD2CODE&lt;br /&gt;
&lt;br /&gt;
* pass group1=DWUSD for a dwolla withdraw&lt;br /&gt;
&lt;br /&gt;
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )&lt;br /&gt;
* return code and status if successful&lt;br /&gt;
&lt;br /&gt;
 To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )&lt;br /&gt;
&lt;br /&gt;
==== 0/btcAddress.php ====&lt;br /&gt;
get a bitcoin deposit adress for your account &lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/btcAddress.php&lt;br /&gt;
&lt;br /&gt;
* pass POST data &amp;quot;description&amp;quot; to add a description that will appear in your history when this BTC address receive a deposit&lt;br /&gt;
&lt;br /&gt;
* returns a bitcoin deposit address&lt;br /&gt;
&lt;br /&gt;
==== 0/history_[CUR].csv ====&lt;br /&gt;
&lt;br /&gt;
Allows downloading your activity history for a given currency (BTC or USD for now).&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_BTC.csv&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/history_USD.csv&lt;br /&gt;
&lt;br /&gt;
==== 0/info.php ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/0/info.php&lt;br /&gt;
&lt;br /&gt;
returns info about your account, funds, fees, API privileges . . . &lt;br /&gt;
&lt;br /&gt;
==== 0/ticker ====&lt;br /&gt;
&lt;br /&gt;
http://mtgox.com/api/0/data/ticker.php&lt;br /&gt;
&lt;br /&gt;
returns the current ticker :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;ticker&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;:5.70653,&lt;br /&gt;
 &amp;quot;low&amp;quot;:5.4145,&lt;br /&gt;
 &amp;quot;avg&amp;quot;:5.561388723,&lt;br /&gt;
 &amp;quot;vwap&amp;quot;:5.610932845,&lt;br /&gt;
 &amp;quot;vol&amp;quot;:55698,&lt;br /&gt;
 &amp;quot;last&amp;quot;:5.56915,&lt;br /&gt;
 &amp;quot;buy&amp;quot;:5.51326,&lt;br /&gt;
 &amp;quot;sell&amp;quot;:5.5672&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours&lt;br /&gt;
&lt;br /&gt;
what is vwap ? &lt;br /&gt;
&lt;br /&gt;
please see http://en.wikipedia.org/wiki/VWAP&lt;br /&gt;
&lt;br /&gt;
=== API version 0 examples ===&lt;br /&gt;
&lt;br /&gt;
==== all api shell type CLI ====&lt;br /&gt;
&lt;br /&gt;
python : http://www.goxsh.info/&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/vEpgw5nW&lt;br /&gt;
&lt;br /&gt;
==== other ====&lt;br /&gt;
&lt;br /&gt;
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl&lt;br /&gt;
&lt;br /&gt;
https://github.com/sje397/mtgox-plasmoid&lt;br /&gt;
&lt;br /&gt;
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/&lt;br /&gt;
&lt;br /&gt;
==== gather data ====&lt;br /&gt;
&lt;br /&gt;
https://github.com/Lexiks/MyBitBoard&lt;br /&gt;
&lt;br /&gt;
==== gettrade ====&lt;br /&gt;
&lt;br /&gt;
bash : https://bitcointalk.org/index.php?topic=39402.0&lt;br /&gt;
&lt;br /&gt;
perl : http://pastebin.com/raw.php?i=pmhMXZJu&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
&lt;br /&gt;
http://pastebin.com/pd0ZR4WY&lt;br /&gt;
&lt;br /&gt;
=== Methods API version 1===&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency Ticker ====&lt;br /&gt;
&lt;br /&gt;
 https://mtgox.com/api/1/BTCUSD/public/ticker&lt;br /&gt;
 https://mtgox.com/api/1/BTCEUR/public/ticker&lt;br /&gt;
&lt;br /&gt;
 returns the current ticker for the selected currency :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;result&amp;quot;:&amp;quot;success&amp;quot;,&lt;br /&gt;
&amp;quot;return&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
 &amp;quot;high&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.70653&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;570653&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.70653&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;low&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.4145&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;541450&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.41450&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;avg&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.561119626&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556112&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56112&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vwap&amp;quot;: {&amp;quot;value&amp;quot;:&amp;quot;5.610480461&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;561048&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.61048&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;vol&amp;quot;:&lt;br /&gt;
 {&lt;br /&gt;
  &amp;quot;value&amp;quot;:&amp;quot;55829.58960346&amp;quot;,&lt;br /&gt;
  &amp;quot;value_int&amp;quot;:&amp;quot;5582958960346&amp;quot;,&lt;br /&gt;
  &amp;quot;display&amp;quot;:&amp;quot;55,829.58960346\u00a0BTC&amp;quot;,&lt;br /&gt;
  &amp;quot;currency&amp;quot;:&amp;quot;BTC&amp;quot;&lt;br /&gt;
 },&lt;br /&gt;
 &amp;quot;last_local&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last_orig&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;last&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.5594&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;555940&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.55940&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;buy&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.53587&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;553587&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.53587&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;},&lt;br /&gt;
 &amp;quot;sell&amp;quot;:{&amp;quot;value&amp;quot;:&amp;quot;5.56031&amp;quot;,&amp;quot;value_int&amp;quot;:&amp;quot;556031&amp;quot;,&amp;quot;display&amp;quot;:&amp;quot;$5.56031&amp;quot;,&amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
note : last_local include only the last trade in the selected currency, last_orig include data of the original last trade ( currency,price in currency . . . ),last can be a conversion of the last trde in another currency&lt;br /&gt;
&lt;br /&gt;
==== Multi Currency depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/depth?raw&lt;br /&gt;
&lt;br /&gt;
==== Multi currency trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCPLN/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCAUD/public/trades?raw&lt;br /&gt;
&lt;br /&gt;
to get only the trades since a given trade id, you can add the parameter since=&amp;lt;trade_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/trades?since=0&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCEUR/public/trades?since=1316312781670700&lt;br /&gt;
&lt;br /&gt;
For multi currency,also returns the primary value,&amp;quot;Y&amp;quot; or &amp;quot;N&amp;quot;, the primary currency is always the buyers currency&lt;br /&gt;
&lt;br /&gt;
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y&lt;br /&gt;
&lt;br /&gt;
example of returned data : &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;date&amp;quot;:1316312781,&lt;br /&gt;
&amp;quot;price&amp;quot;:&amp;quot;3.5599&amp;quot;,&lt;br /&gt;
&amp;quot;amount&amp;quot;:&amp;quot;3.6900096&amp;quot;,&lt;br /&gt;
&amp;quot;price_int&amp;quot;:&amp;quot;355990&amp;quot;,&lt;br /&gt;
&amp;quot;amount_int&amp;quot;:&amp;quot;369000960&amp;quot;,&lt;br /&gt;
&amp;quot;tid&amp;quot;:&amp;quot;1316312781670700&amp;quot;,&lt;br /&gt;
&amp;quot;price_currency&amp;quot;:&amp;quot;EUR&amp;quot;,&lt;br /&gt;
&amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
&amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
&amp;quot;primary&amp;quot;:&amp;quot;Y&amp;quot;,&lt;br /&gt;
&amp;quot;properties&amp;quot;:&amp;quot;limit,mixed_currency&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Cancelled Trades ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/cancelledtrades&lt;br /&gt;
&lt;br /&gt;
returns a list of all the cancelled trades this last month, list of trade ids in json format .&lt;br /&gt;
&lt;br /&gt;
==== Full Depth ====&lt;br /&gt;
&lt;br /&gt;
https://mtgox.com/api/1/BTCUSD/public/fulldepth&lt;br /&gt;
&lt;br /&gt;
returns full depth&lt;br /&gt;
&lt;br /&gt;
== Websocket API ==&lt;br /&gt;
ported on 7/10/2011 from http://forum.bitcoin.org/index.php?topic=5855.0&lt;br /&gt;
&lt;br /&gt;
===Connecting===&lt;br /&gt;
&lt;br /&gt;
You can connect via: ws://websocket.mtgox.com/mtgox&lt;br /&gt;
&lt;br /&gt;
The WebSocket protocol version used is that described in [http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00 draft-ietf-hybi-thewebsocketprotocol-00] (aka draft-00).&lt;br /&gt;
&lt;br /&gt;
===Channels===&lt;br /&gt;
&lt;br /&gt;
The websocket will subscribe you to some channels automatically:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Channel ID !! Description&lt;br /&gt;
|-&lt;br /&gt;
| dbf1dee9-4f2e-4a08-8cb7-748919a71b21 || trades (each time a trade happens, you get something here)&lt;br /&gt;
|-&lt;br /&gt;
| d5f06780-30a8-4a48-a2f8-7ed181b4a13f || the mtgox ticker (lots of updates, with often the same data)&lt;br /&gt;
|-&lt;br /&gt;
| 24e67e0d-1cad-4cc0-9e7a-f8523ef460fe || depth information in realtime (price + amount + type... type=1=Ask, type=2=Bid)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Additionally each user has a &amp;quot;own&amp;quot; channel which streams informations about orders (new order, deleted order, etc) and trades only the user&#039;s trades).&lt;br /&gt;
&lt;br /&gt;
Each message is a JSON-encoded object, with at least &amp;quot;op&amp;quot; element. The &amp;quot;op&amp;quot; element contains the operation to be done (for outgoing messages), or the type of message (for incoming messages).&lt;br /&gt;
&lt;br /&gt;
===Possible outgoing commands===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;unsubscribe&#039;&#039;&#039; Stop receiving messages from a channel (parameter &amp;quot;channel&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Incoming Data===&lt;br /&gt;
&lt;br /&gt;
====Ticker====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;d5f06780-30a8-4a48-a2f8-7ed181b4a13f&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;ticker&amp;quot;,&lt;br /&gt;
  &amp;quot;ticker&amp;quot;:{&lt;br /&gt;
    &amp;quot;buy&amp;quot;:0.9515,&lt;br /&gt;
    &amp;quot;high&amp;quot;:1,&lt;br /&gt;
    &amp;quot;low&amp;quot;:0.91,&lt;br /&gt;
    &amp;quot;sell&amp;quot;:0.9697,&lt;br /&gt;
    &amp;quot;vol&amp;quot;:34349&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ticker&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| buy || highest bid as float&lt;br /&gt;
|-&lt;br /&gt;
| sell || lowest ask as float&lt;br /&gt;
|-&lt;br /&gt;
| high || maximum rate since last close as float&lt;br /&gt;
|-&lt;br /&gt;
| low || minimum rate since last close as float&lt;br /&gt;
|-&lt;br /&gt;
| vol || traded volume since last close&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Trade====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;dbf1dee9-4f2e-4a08-8cb7-748919a71b21&amp;quot;,&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;trade&amp;quot;,&lt;br /&gt;
  &amp;quot;trade&amp;quot;:{&lt;br /&gt;
    &amp;quot;amount&amp;quot;:2.71,&lt;br /&gt;
    &amp;quot;amount_int&amp;quot;:&amp;quot;271000000&amp;quot;,&lt;br /&gt;
    &amp;quot;date&amp;quot;:1310279340,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:14.43,&lt;br /&gt;
    &amp;quot;price_currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;tid&amp;quot;:&amp;quot;1310279340877902&amp;quot;,&lt;br /&gt;
    &amp;quot;trade_type&amp;quot;:&amp;quot;bid&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:&amp;quot;trade&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;trade&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| amount || the traded amount in item (BTC), float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| amount_int || the traded amount * 1E8&lt;br /&gt;
|-&lt;br /&gt;
| date || unix timestamp of trade&lt;br /&gt;
|-&lt;br /&gt;
| item || What was this trade about&lt;br /&gt;
|-&lt;br /&gt;
| price || price per unit, float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)&lt;br /&gt;
|-&lt;br /&gt;
| price_currency || currency in which trade was completed&lt;br /&gt;
|-&lt;br /&gt;
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)&lt;br /&gt;
|-&lt;br /&gt;
| trade_type || Did this trade result from the execution of a bid or a ask?&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Depth====&lt;br /&gt;
&lt;br /&gt;
Changes to the market depth data are broadcast so an up-to-date market depth can be kept by clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;{&lt;br /&gt;
  &amp;quot;channel&amp;quot;:&amp;quot;24e67e0d-1cad-4cc0-9e7a-f8523ef460fe&amp;quot;,&lt;br /&gt;
  &amp;quot;depth&amp;quot;:{&lt;br /&gt;
    &amp;quot;currency&amp;quot;:&amp;quot;USD&amp;quot;,&lt;br /&gt;
    &amp;quot;item&amp;quot;:&amp;quot;BTC&amp;quot;,&lt;br /&gt;
    &amp;quot;price&amp;quot;:&amp;quot;14.43&amp;quot;,&lt;br /&gt;
    &amp;quot;price_int&amp;quot;:&amp;quot;1443000&amp;quot;,&lt;br /&gt;
    &amp;quot;type&amp;quot;:1,&lt;br /&gt;
    &amp;quot;type_str&amp;quot;:&amp;quot;ask&amp;quot;,&lt;br /&gt;
    &amp;quot;volume&amp;quot;:&amp;quot;-2.71&amp;quot;,&lt;br /&gt;
    &amp;quot;volume_int&amp;quot;:&amp;quot;-271000000&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;op&amp;quot;:&amp;quot;private&amp;quot;,&lt;br /&gt;
  &amp;quot;origin&amp;quot;:&amp;quot;broadcast&amp;quot;,&lt;br /&gt;
  &amp;quot;private&amp;quot;:&amp;quot;depth&amp;quot;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;depth&#039;&#039;&#039; contains the following:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Value&lt;br /&gt;
|-&lt;br /&gt;
| currency || the currency affected&lt;br /&gt;
|-&lt;br /&gt;
| item || the item (BTC)&lt;br /&gt;
|-&lt;br /&gt;
| price || price as a float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| price_int || the price at which volume change happened (5 decimal for USD, 3 for JPY)&lt;br /&gt;
|-&lt;br /&gt;
| type || 1=ask, 2=bid. deprecated, use type_str&lt;br /&gt;
|-&lt;br /&gt;
| type_str || type of order at this depth, either &amp;quot;ask&amp;quot; or &amp;quot;bid&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| volume || the volume change as float, deprecated&lt;br /&gt;
|-&lt;br /&gt;
| volume_int || volume change * 1E8&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== examples ===&lt;br /&gt;
&lt;br /&gt;
==== ticker ====&lt;br /&gt;
javascript, using hookio : &lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=KD5ljtNK72U&lt;br /&gt;
&lt;br /&gt;
http://github.com/hookio&lt;br /&gt;
&lt;br /&gt;
http://github.com/cronopio/hook.io-mtgox&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another node.js project, using plain websockets (largely based on cronopio&#039;s work) :&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;br /&gt;
&lt;br /&gt;
==== arbitrage ====&lt;br /&gt;
https://github.com/goteppo/ArBit&lt;br /&gt;
&lt;br /&gt;
==== websocket ====&lt;br /&gt;
https://github.com/cronopio/hook.io-ws&lt;br /&gt;
&lt;br /&gt;
https://github.com/dlanod/node-mtgox-websocket-client&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=18687</id>
		<title>Real Time Bitcoin Market Data</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=18687"/>
		<updated>2011-10-31T19:41:51Z</updated>

		<summary type="html">&lt;p&gt;Clark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A financial information service that provides a real-time display of data from the [[MtGox]] exchange.&lt;br /&gt;
&lt;br /&gt;
* Combined - Includes all of the services listed below&lt;br /&gt;
* Time Sales - Time price and volume for each trade executed&lt;br /&gt;
* Ticker - Current best ask / best bid, day&#039;s high, day&#039;s low, volume and last trade for all MtGox currencies. The site also displays a synthetic forex grid, based on the immediate exchange rates between non-zero volume currencies.&lt;br /&gt;
* Order Book - The buy (bid) and sell (ask) orders along with real time trade calculators&lt;br /&gt;
&lt;br /&gt;
The Ticker and Time Sales services were announced on June 03, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=11560.0 Realtime MtGox Time and Sales with WebSockets]&amp;lt;/ref&amp;gt; and the Order Book was announced on June 10, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=14412.0 Real Time Order Book with WebSockets]&amp;lt;/ref&amp;gt;. The combined information view was announced on September 11, 2011&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=43514.0 Combined Order Book and Time &amp;amp; Sales]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ Combined] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/time-sales Time Sales] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ticker Ticker] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/order-book Order Book] web page&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Financial]]&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=16516</id>
		<title>Real Time Bitcoin Market Data</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Real_Time_Bitcoin_Market_Data&amp;diff=16516"/>
		<updated>2011-09-12T19:54:02Z</updated>

		<summary type="html">&lt;p&gt;Clark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A financial information service that provides a real-time display of data from the [[MtGox]] exchange.&lt;br /&gt;
&lt;br /&gt;
* Combined - Includes all of the services listed below&lt;br /&gt;
* Time Sales - Time price and volume for each trade executed&lt;br /&gt;
* Ticker - Current best ask / best bid, day&#039;s high, day&#039;s low, volume and last trade&lt;br /&gt;
* Order Book - The buy (bid) and sell (ask) orders along with real time trade calculators&lt;br /&gt;
&lt;br /&gt;
The Ticker and Time Sales services were announced on June 03, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=11560.0 Realtime MtGox Time and Sales with WebSockets]&amp;lt;/ref&amp;gt; and the Order Book was announced on June 10, 2011&amp;lt;ref&amp;gt;[http://forum.bitcoin.org/index.php?topic=14412.0 Real Time Order Book with WebSockets]&amp;lt;/ref&amp;gt;. The combined information view was announced on September 11, 2011&amp;lt;ref&amp;gt;[https://bitcointalk.org/index.php?topic=43514.0 Combined Order Book and Time &amp;amp; Sales]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ Combined] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/time-sales Time Sales] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/ticker Ticker] web page&lt;br /&gt;
* [http://bitcoin.clarkmoody.com/order-book Order Book] web page&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Financial]]&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Mini_private_key_format&amp;diff=16337</id>
		<title>Mini private key format</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Mini_private_key_format&amp;diff=16337"/>
		<updated>2011-09-08T18:54:46Z</updated>

		<summary type="html">&lt;p&gt;Clark: Added length check in Python code CheckShortKey()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;mini private key format&#039;&#039;&#039; is a method of encoding a Bitcoin private key in 22 characters so that it can be embedded in a small space.  This private key format was first used in Casascius physical bitcoins, and is also favorable for use in QR codes.  The fewer characters encoded in a QR code, the lower dot density can be used, as well as more dots allocated to error correcting codes, and hence a QR code that is easier for a machine to read.  The mini private key format offers its own built-in check code as a small margin of protection against typos.&lt;br /&gt;
&lt;br /&gt;
An example key using this encoding is &#039;&#039;&#039;S4b3N3oGqDqR5jNuxEvDwf&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The way it might appear within a physical bitcoin is on a round card printed as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;S4b3N&amp;lt;br/&amp;gt;3oGqDq&amp;lt;br/&amp;gt;R5jNux&amp;lt;br/&amp;gt;EvDwf&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Decoding==&lt;br /&gt;
The private key encoding consists of 22 alphanumeric characters from the [[base58]] alphabet used in Bitcoin.  The first of the 22 characters is always the uppercase letter S.&lt;br /&gt;
&lt;br /&gt;
To obtain the full 256-bit private key, simply take the SHA256 hash of the entire string.  There is no encoding for breaks in the string even if printed that way - the SHA256 should be taken of exactly twenty-two bytes.&lt;br /&gt;
&lt;br /&gt;
 SHA256(&amp;quot;S4b3N3oGqDqR5jNuxEvDwf&amp;quot;) = 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D&lt;br /&gt;
&lt;br /&gt;
==Check code==&lt;br /&gt;
The check code is designed to be simple, but relatively computationally expensive so that it cannot be used to quickly reduce the key space in a brute force attack.  It offers seven bits worth of error protection (or, in other words, in the event of a typo, the typo will be caught about 127 out of 128 times, or over 99%).&lt;br /&gt;
&lt;br /&gt;
To determine whether a string passes the check code, follow these steps:&lt;br /&gt;
# Ensure it is well-formed (22 characters, base58 alphabet, starts with S).&lt;br /&gt;
# Add a question mark to the end of the string, and take the SHA256 of that.  If the SHA256 starts with eight zero bits (hex 00), then the string passes the check code.&lt;br /&gt;
# If it does not, then with the same string (ending in a question mark), do 717 (seven hundred seventeen) rounds of SHA256 on the string.  If the result after the 717th round starts with eight zero bits (hex 00), then the string passes the check code.&lt;br /&gt;
# If the results of SHA256 after both tests don&#039;t start with eight zero bits, then the check fails.&lt;br /&gt;
&lt;br /&gt;
==Creating mini private keys==&lt;br /&gt;
Creating mini private keys is relatively simple.  One program which can create such keys is [[Casascius Bitcoin Utility]].&lt;br /&gt;
&lt;br /&gt;
Mini private keys must be created &amp;quot;from scratch&amp;quot;, as the conversion from mini private key to full-size private key is one-way.  In other words, there is no way to convert an existing full-size private key into a mini private key.&lt;br /&gt;
&lt;br /&gt;
To create mini private keys, simply create random strings that satisfy the well-formedness requirement, and then eliminate the ones that do not pass the typo check.  (This means eliminating more than 99% of the candidates.)  Then use SHA256 to compute the corresponding private key, and in turn, the matching Bitcoin address.  The Bitcoin address can always be computed from just the private key.&lt;br /&gt;
&lt;br /&gt;
In all cases, you should use a secure cryptographic random number generator to eliminate risks of predictability of the random strings.  Also, for stronger security, accept only the strings that pass the typo check on the 717th round rather than the first.&lt;br /&gt;
&lt;br /&gt;
==Python Code==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import random&lt;br /&gt;
import hashlib&lt;br /&gt;
&lt;br /&gt;
BASE58 = &#039;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#039;&lt;br /&gt;
&lt;br /&gt;
def Candidate():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Generate a random, well-formed mini private key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return(&#039;%s%s&#039; % (&#039;S&#039;, &#039;&#039;.join(&lt;br /&gt;
        [BASE58[ random.randrange(0,len(BASE58)) ] for i in range(21)])))&lt;br /&gt;
&lt;br /&gt;
def GenerateKeys(numKeys = 10, additionalSecurity = False):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Generate mini private keys and output the mini key as well as the full&lt;br /&gt;
    private key. numKeys is The number of keys to generate, and &lt;br /&gt;
    additionalSecurity controls whether to do 717 rounds of SHA256&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    keysGenerated = 0&lt;br /&gt;
    totalCandidates = 0&lt;br /&gt;
    while keysGenerated &amp;lt; numKeys:&lt;br /&gt;
        try:&lt;br /&gt;
            cand = Candidate()&lt;br /&gt;
            # Do typo check&lt;br /&gt;
            t = &#039;%s?&#039; % cand&lt;br /&gt;
            # Take one round of SHA256&lt;br /&gt;
            candHash = hashlib.sha256(t).digest()&lt;br /&gt;
            if additionalSecurity:&lt;br /&gt;
                # Do the other 716 rounds for additional security&lt;br /&gt;
                for i in range(716):&lt;br /&gt;
                    candHash = hashlib.sha256(candHash).digest()&lt;br /&gt;
            # Check if the first eight bits of the hash are 0&lt;br /&gt;
            if candHash[0] == &#039;\x00&#039;:&lt;br /&gt;
                privateKey = GetPrivateKey(cand)&lt;br /&gt;
                print(&#039;\n%s\nSHA256( ): %s\nsha256(?): %s&#039; %&lt;br /&gt;
                      (cand, privateKey, candHash.encode(&#039;hex_codec&#039;)))&lt;br /&gt;
                if CheckShortKey(cand):&lt;br /&gt;
                    print(&#039;Validated.&#039;)&lt;br /&gt;
                else:&lt;br /&gt;
                    print(&#039;Invalid!&#039;)&lt;br /&gt;
                keysGenerated += 1&lt;br /&gt;
            totalCandidates += 1&lt;br /&gt;
        except KeyboardInterrupt:&lt;br /&gt;
            break&lt;br /&gt;
    print(&#039;\n%s: %i\n%s: %i\n%s: %r\n%s: %.1f&#039; %&lt;br /&gt;
          (&#039;Keys Generated&#039;, keysGenerated,&lt;br /&gt;
           &#039;Total Candidates&#039;, totalCandidates,&lt;br /&gt;
           &#039;Additional Security&#039;, additionalSecurity,&lt;br /&gt;
           &#039;Reject Percentage&#039;,&lt;br /&gt;
           100*(1.0-keysGenerated/float(totalCandidates))))&lt;br /&gt;
&lt;br /&gt;
def GetPrivateKey(shortKey):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Returns the hexadecimal representation of the private key corresponding&lt;br /&gt;
    to the given short key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if CheckShortKey(shortKey):&lt;br /&gt;
        return hashlib.sha256(shortKey).hexdigest()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&#039;Typo detected in private key!&#039;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def CheckShortKey(shortKey):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Checks for typos in the short key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if len(shortKey) != 22:&lt;br /&gt;
        return False&lt;br /&gt;
    t = &#039;%s?&#039; % shortKey&lt;br /&gt;
    tHash = hashlib.sha256(t).digest()&lt;br /&gt;
    # Check to see that first byte is \x00&lt;br /&gt;
    if tHash[0] == &#039;\x00&#039;:&lt;br /&gt;
        return True&lt;br /&gt;
    else:&lt;br /&gt;
        # Do an additional 716 rounds&lt;br /&gt;
        for i in range(716):&lt;br /&gt;
            tHash = hashlib.sha256(tHash).digest()&lt;br /&gt;
        # Check again for \x00&lt;br /&gt;
        if tHash[0] == &#039;\x00&#039;:&lt;br /&gt;
            return True&lt;br /&gt;
    return False&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Mini_private_key_format&amp;diff=16336</id>
		<title>Mini private key format</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Mini_private_key_format&amp;diff=16336"/>
		<updated>2011-09-08T18:24:10Z</updated>

		<summary type="html">&lt;p&gt;Clark: Added Python code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;mini private key format&#039;&#039;&#039; is a method of encoding a Bitcoin private key in 22 characters so that it can be embedded in a small space.  This private key format was first used in Casascius physical bitcoins, and is also favorable for use in QR codes.  The fewer characters encoded in a QR code, the lower dot density can be used, as well as more dots allocated to error correcting codes, and hence a QR code that is easier for a machine to read.  The mini private key format offers its own built-in check code as a small margin of protection against typos.&lt;br /&gt;
&lt;br /&gt;
An example key using this encoding is &#039;&#039;&#039;S4b3N3oGqDqR5jNuxEvDwf&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The way it might appear within a physical bitcoin is on a round card printed as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;S4b3N&amp;lt;br/&amp;gt;3oGqDq&amp;lt;br/&amp;gt;R5jNux&amp;lt;br/&amp;gt;EvDwf&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Decoding==&lt;br /&gt;
The private key encoding consists of 22 alphanumeric characters from the [[base58]] alphabet used in Bitcoin.  The first of the 22 characters is always the uppercase letter S.&lt;br /&gt;
&lt;br /&gt;
To obtain the full 256-bit private key, simply take the SHA256 hash of the entire string.  There is no encoding for breaks in the string even if printed that way - the SHA256 should be taken of exactly twenty-two bytes.&lt;br /&gt;
&lt;br /&gt;
 SHA256(&amp;quot;S4b3N3oGqDqR5jNuxEvDwf&amp;quot;) = 0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D&lt;br /&gt;
&lt;br /&gt;
==Check code==&lt;br /&gt;
The check code is designed to be simple, but relatively computationally expensive so that it cannot be used to quickly reduce the key space in a brute force attack.  It offers seven bits worth of error protection (or, in other words, in the event of a typo, the typo will be caught about 127 out of 128 times, or over 99%).&lt;br /&gt;
&lt;br /&gt;
To determine whether a string passes the check code, follow these steps:&lt;br /&gt;
# Ensure it is well-formed (22 characters, base58 alphabet, starts with S).&lt;br /&gt;
# Add a question mark to the end of the string, and take the SHA256 of that.  If the SHA256 starts with eight zero bits (hex 00), then the string passes the check code.&lt;br /&gt;
# If it does not, then with the same string (ending in a question mark), do 717 (seven hundred seventeen) rounds of SHA256 on the string.  If the result after the 717th round starts with eight zero bits (hex 00), then the string passes the check code.&lt;br /&gt;
# If the results of SHA256 after both tests don&#039;t start with eight zero bits, then the check fails.&lt;br /&gt;
&lt;br /&gt;
==Creating mini private keys==&lt;br /&gt;
Creating mini private keys is relatively simple.  One program which can create such keys is [[Casascius Bitcoin Utility]].&lt;br /&gt;
&lt;br /&gt;
Mini private keys must be created &amp;quot;from scratch&amp;quot;, as the conversion from mini private key to full-size private key is one-way.  In other words, there is no way to convert an existing full-size private key into a mini private key.&lt;br /&gt;
&lt;br /&gt;
To create mini private keys, simply create random strings that satisfy the well-formedness requirement, and then eliminate the ones that do not pass the typo check.  (This means eliminating more than 99% of the candidates.)  Then use SHA256 to compute the corresponding private key, and in turn, the matching Bitcoin address.  The Bitcoin address can always be computed from just the private key.&lt;br /&gt;
&lt;br /&gt;
In all cases, you should use a secure cryptographic random number generator to eliminate risks of predictability of the random strings.  Also, for stronger security, accept only the strings that pass the typo check on the 717th round rather than the first.&lt;br /&gt;
&lt;br /&gt;
==Python Code==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import random&lt;br /&gt;
import hashlib&lt;br /&gt;
&lt;br /&gt;
BASE58 = &#039;123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz&#039;&lt;br /&gt;
&lt;br /&gt;
def Candidate():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Generate a random, well-formed mini private key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return(&#039;%s%s&#039; % (&#039;S&#039;, &#039;&#039;.join(&lt;br /&gt;
        [BASE58[ random.randrange(0,len(BASE58)) ] for i in range(21)])))&lt;br /&gt;
&lt;br /&gt;
def GenerateKeys(numKeys = 10, additionalSecurity = False):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Generate mini private keys and output the mini key as well as the full&lt;br /&gt;
    private key. numKeys is The number of keys to generate, and &lt;br /&gt;
    additionalSecurity controls whether to do 717 rounds of SHA256&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    keysGenerated = 0&lt;br /&gt;
    totalCandidates = 0&lt;br /&gt;
    while keysGenerated &amp;lt; numKeys:&lt;br /&gt;
        try:&lt;br /&gt;
            cand = Candidate()&lt;br /&gt;
            # Do typo check&lt;br /&gt;
            t = &#039;%s?&#039; % cand&lt;br /&gt;
            # Take one round of SHA256&lt;br /&gt;
            candHash = hashlib.sha256(t).digest()&lt;br /&gt;
            if additionalSecurity:&lt;br /&gt;
                # Do the other 716 rounds for additional security&lt;br /&gt;
                for i in range(716):&lt;br /&gt;
                    candHash = hashlib.sha256(candHash).digest()&lt;br /&gt;
            # Check if the first eight bits of the hash are 0&lt;br /&gt;
            if candHash[0] == &#039;\x00&#039;:&lt;br /&gt;
                privateKey = GetPrivateKey(cand)&lt;br /&gt;
                print(&#039;\n%s\nSHA256( ): %s\nsha256(?): %s&#039; %&lt;br /&gt;
                      (cand, privateKey, candHash.encode(&#039;hex_codec&#039;)))&lt;br /&gt;
                if CheckShortKey(cand):&lt;br /&gt;
                    print(&#039;Validated.&#039;)&lt;br /&gt;
                else:&lt;br /&gt;
                    print(&#039;Invalid!&#039;)&lt;br /&gt;
                keysGenerated += 1&lt;br /&gt;
            totalCandidates += 1&lt;br /&gt;
        except KeyboardInterrupt:&lt;br /&gt;
            break&lt;br /&gt;
    print(&#039;\n%s: %i\n%s: %i\n%s: %r\n%s: %.1f&#039; %&lt;br /&gt;
          (&#039;Keys Generated&#039;, keysGenerated,&lt;br /&gt;
           &#039;Total Candidates&#039;, totalCandidates,&lt;br /&gt;
           &#039;Additional Security&#039;, additionalSecurity,&lt;br /&gt;
           &#039;Reject Percentage&#039;,&lt;br /&gt;
           100*(1.0-keysGenerated/float(totalCandidates))))&lt;br /&gt;
&lt;br /&gt;
def GetPrivateKey(shortKey):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Returns the hexadecimal representation of the private key corresponding&lt;br /&gt;
    to the given short key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if CheckShortKey(shortKey):&lt;br /&gt;
        return hashlib.sha256(shortKey).hexdigest()&lt;br /&gt;
    else:&lt;br /&gt;
        print(&#039;Typo detected in private key!&#039;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
def CheckShortKey(shortKey):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Checks for typos in the short key.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    t = &#039;%s?&#039; % shortKey&lt;br /&gt;
    tHash = hashlib.sha256(t).digest()&lt;br /&gt;
    # Check to see that first byte is \x00&lt;br /&gt;
    if tHash[0] == &#039;\x00&#039;:&lt;br /&gt;
        return True&lt;br /&gt;
    else:&lt;br /&gt;
        # Do an additional 716 rounds&lt;br /&gt;
        for i in range(716):&lt;br /&gt;
            tHash = hashlib.sha256(tHash).digest()&lt;br /&gt;
        # Check again for \x00&lt;br /&gt;
        if tHash[0] == &#039;\x00&#039;:&lt;br /&gt;
            return True&lt;br /&gt;
    return False&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=How_bitcoin_works&amp;diff=16333</id>
		<title>How bitcoin works</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=How_bitcoin_works&amp;diff=16333"/>
		<updated>2011-09-08T16:30:36Z</updated>

		<summary type="html">&lt;p&gt;Clark: Typo correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page explains the basic framework of Bitcoin&#039;s functionality.&lt;br /&gt;
&lt;br /&gt;
==Cryptography==&lt;br /&gt;
&lt;br /&gt;
There are several cryptographic technologies that make up the essence of Bitcoin. &lt;br /&gt;
&lt;br /&gt;
First is [http://en.wikipedia.org/wiki/Public-key_cryptography public key cryptography]. Each coin is associated with its current owner&#039;s public [http://en.wikipedia.org/wiki/Elliptic_Curve_DSA ECDSA] key. When you send some bitcoins to someone, you create a message ([[transaction]]), attaching the new owner&#039;s public key to this amount of coins, and sign it with your private key. When this transaction is broadcast to the bitcoin network, this lets everyone know that the new owner of these coins is the owner of the new key. Your signature on the message verifies for everyone that the message is authentic. The complete history of transactions is kept by everyone, so anyone can verify who is the current owner of any particular group of coins.&lt;br /&gt;
&lt;br /&gt;
This complete record of transactions is kept in the [[block chain]], which is a sequence of records called [[block|blocks]]. All computers in the network have a copy of the block chain, which they keep updated by passing along new blocks to each other. Each block contains a group of transactions that have been sent since the previous block. In order to preserve the integrity of the block chain, each block in the chain confirms the integrity of the previous one, all the way back to the first one, the [[genesis block]]. Record insertion is costly because each block must meet certain requirements that make it [[difficulty|difficult]] to generate a valid block. This way, no party can overwrite previous records by just forking the chain.&lt;br /&gt;
&lt;br /&gt;
Both the chaining, and the difficulty, are achieved via the [http://en.wikipedia.org/wiki/SHA-2 SHA256] [http://en.wikipedia.org/wiki/Cryptographic_hash_function cryptographic hash function]. The hash function essentially takes a block of data, and transforms it, in an effectively-impossible to reverse or to predict way, into a large integer. Making the slightest change to a block of data changes its hash unpredictably, so nobody can create a different block of data that gives exactly the same hash. Therefore, by being given a short hash, you can confirm that it matches only a particular long block of data. This way, Bitcoin blocks don&#039;t have to contain serial numbers, as blocks can be identified by their hash, which serves the dual purpose of identification as well as integrity verification.&lt;br /&gt;
&lt;br /&gt;
The [[difficulty]] factor is achieved by requiring that this integer is below a certain threshold - the data in the block is perturbed by a [[nonce]] value, until the data in the block hashes to produce an integer below the threshold - which takes a lot of processing power. This low hash value for the block serves as an easily-verifiable [[proof of work]] - every node on the network can instantly verify that the block meets the required criteria.&lt;br /&gt;
&lt;br /&gt;
With this framework, we are able to achieve the essential functions of the Bitcoin system. We have verifiable ownership of bitcoins, and a distributed database of all transactions, which prevents [[#Double_spending|double spending]].&lt;br /&gt;
&lt;br /&gt;
==Bitcoin mining==&lt;br /&gt;
&lt;br /&gt;
We have mentioned in the previous section that adding a block to the block chain is difficult, requiring time and processing power to accomplish. So what incentive does anyone have to spend the effort to produce a block, if it takes up all these resources? The answer is that the person who manages to produce a block gets a reward. This reward is two-fold. First, the block producer gets a bounty of some number of bitcoins, which is agreed-upon by the network. (Currently this bounty is 50 bitcoins; this value will halve every 210,000 blocks.) Second, any [[transaction fees]] that may be present in the transactions included in the block, get claimed by the block producer. &lt;br /&gt;
&lt;br /&gt;
This gives rise to the activity known as &amp;quot;bitcoin mining&amp;quot; - using processing power to try to produce a valid block, and as a result &#039;mine&#039; some bitcoins. The network rules are such that the [[difficulty]] is adjusted to keep block production to approximately 1 block per 10 minutes. Thus, the more miners engage in the mining activity, the more difficult it becomes for each individual miner to produce a block. The higher the total difficulty, the harder it is for an attacker to overwrite the tip of the block chain with his own blocks (which enables him to double-spend his coins. See the [[weaknesses]] page for more details).&lt;br /&gt;
&lt;br /&gt;
Besides being important for maintaining the transaction database, mining is also the mechanism by which bitcoins get created and distributed among the people in the bitcoin economy. The network rules are such that over the next hundred years, give or take a few decades, a total of 21 million bitcoins will be created. Rather than dropping money out of a helicopter, the bitcoins are awarded to those who contribute to the network by creating [[block]]s in the [[block chain]].&lt;br /&gt;
&lt;br /&gt;
For those who want to get into mining without much difficulty, click [http://www.iscyspace.com Here] for a free 10 step guide on iscyspace.&lt;br /&gt;
&lt;br /&gt;
==Double spending==&lt;br /&gt;
&lt;br /&gt;
The block chain which is constantly being generated by the Bitcoin network works as a common agreement about the order in which bitcoin transactions have taken place. Placing the transactions in a sequence is necessary so that things like the double-spending of coins and negative balances can be avoided. Simply announcing each transaction is not enough to establish the order of the transactions, because different computers may receive the announcement at different times.&lt;br /&gt;
&lt;br /&gt;
Unlike conventional banking systems, there is no central place where this &amp;quot;log&amp;quot; of transactions is stored. What happens is the broadcasting of small pieces (the blocks), each stating that it is a continuation of a previous block. Thus, it is possible for many proposed continuations to the block chain to exist at the same time. There can also be multiple continuations to each of these continuations, forming many branches and sub-branches, like a tree. When this happens, each computer in the network must decide for itself which branch is the &amp;quot;correct&amp;quot; one that should be accepted and extended further.&lt;br /&gt;
&lt;br /&gt;
The rule in this case is to accept the &amp;quot;longest&amp;quot; valid branch. Choose from the branches of blocks that you have received, the path, the total &amp;quot;difficulty&amp;quot; of which is the highest. This is the sequence of blocks that is assumed to have required the most work (CPU time) to generate. For Bitcoin, this will be the &amp;quot;true&amp;quot; order of events, and this is what it will take into account when calculating the balance to show to the user. &amp;quot;Valid&amp;quot; means that Bitcoin will reject branches which don&#039;t contain a strong enough [[proof of work]] or contain invalid transactions (i.e. calculating a wrong balance, giving more money than you have, generating more bitcoins than is allowed at the time, etc).&lt;br /&gt;
&lt;br /&gt;
It is still possible that, as new blocks are constantly being generated, at some later time, some other branch will become the longest branch. However, it takes significant effort to extend a branch, and nodes work to extend the branch that they have received and accepted (which is normally the longest one). So, the longer this branch becomes compared to the second-longest branch, the more effort it will take for the second-longest branch to catch up and overcome the first in length. Also, the more nodes in the network hear about the longest branch, the more unlikely it becomes for other branches to be extended the next time a block is generated, since the nodes will accept the longest chain.&lt;br /&gt;
&lt;br /&gt;
Therefore, the more time a transaction has been part of the longest block chain, the more likely it is to remain part of the chain indefinitely. This is what makes transactions non-reversible and this is what prevents people from double-spending their coins. What the receiver of each transaction does, after money has been supposedly transferred to him/her is to check how long the block chain following the said transaction has become, because the more blocks are added to the longest branch after the transaction, the less likely is it that some other branch will overcome it.&lt;br /&gt;
&lt;br /&gt;
When the block chain after the transaction has become long enough, it becomes near-impossible for another branch to overcome it, and so people can start accepting the transaction as true. This is why &#039;blocks&#039; also serve as &#039;confirmations&#039; for a transaction. Even if another branch does overcome the one with the transaction, most of the blocks will have been generated by people who have no affiliation with the sender of the coins, as a large number of people are working to generate blocks. Since transactions are broadcasted to all nodes in the network, these blocks are just as likely to contain the transaction as the blocks in the previously-accepted branch.&lt;br /&gt;
&lt;br /&gt;
Bitcoin relies on the fact that no single entity can control most of the CPU power on the network for any significant length of time, since, if they could, they would be able to extend any branch of the tree they chose, and faster than any other branch can be extended, making it the longest branch, and then permanently controlling which transactions appear in it.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Introduction]]&lt;br /&gt;
* [[Getting started]]&lt;br /&gt;
* [[Using Bitcoin]]&lt;br /&gt;
* Bitcoin [[FAQ]]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* http://www.bitcoin.org/smf/index.php?topic=2487.0 A forum thread with some good &#039;for-the-layperson&#039; explanations of how bitcoin works.&lt;br /&gt;
&lt;br /&gt;
[[Category:Introduction]]&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Scalability&amp;diff=16202</id>
		<title>Scalability</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Scalability&amp;diff=16202"/>
		<updated>2011-09-06T15:28:41Z</updated>

		<summary type="html">&lt;p&gt;Clark: Typo correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The core BitCoin network can scale to very high [[transactions|transaction]] rates assuming a distributed version of the node software is built. This would not be very complicated.&lt;br /&gt;
&lt;br /&gt;
==Note to readers==&lt;br /&gt;
&lt;br /&gt;
If you&#039;re coming here because of Dan Kaminsky&#039;s criticisms related to this page, you can find a discussion of his points on the [[Talk:Scalability]] page.&lt;br /&gt;
&lt;br /&gt;
==Scalability targets==&lt;br /&gt;
&lt;br /&gt;
VISA handles on average around 2,000 transactions/sec, so call it a daily peak rate of 4,000/sec. They have burst capacity for over 10,000 transactions per second which they need to handle the busiest points of the holiday period (~8,500tps). [http://investor.visa.com/phoenix.zhtml?c=215693&amp;amp;p=irol-newsArticle_print&amp;amp;ID=1355716]&lt;br /&gt;
&lt;br /&gt;
PayPal, in contrast, handles around 4 million transactions per day for an average of 46tps or a probably peak rate of 100tps.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take 4,000 tps as starting goal. Obviously if we want BitCoin to scale to all economic transactions worldwide, including cash, it&#039;d be a lot higher than that, perhaps more in the region of a few hundred thousand transactions/sec. And the need to be able to withstand DoS attacks (which VISA does not have to deal with) implies we would want to scale far beyond the standard peak rates. Still, picking a target let us do some basic calculations even if it&#039;s a little arbitrary.&lt;br /&gt;
&lt;br /&gt;
==Current bottlenecks==&lt;br /&gt;
&lt;br /&gt;
Today the BitCoin network is restricted to a sustained rate of 7 tps by some artificial limits. These were put in place to stop people from ballooning the size of the block chain before the network and community was ready for it. Once those limits are lifted, the maximum transaction rate will go up significantly.&lt;br /&gt;
&lt;br /&gt;
==CPU==&lt;br /&gt;
&lt;br /&gt;
The protocol has two parts. Nodes send &amp;quot;inv&amp;quot; messages to other nodes telling them they have a new transaction. If the receiving node doesn&#039;t have that transaction it requests it with a getdata.&lt;br /&gt;
&lt;br /&gt;
The big cost is the crypto and block chain lookups involved with verifying the transaction. An ECDSA verification of a transaction input takes around 3msec on a modern Intel core. RIPEMD-160 runs at 106 megabytes/sec (call it 100 for simplicity) and SHA256 is about the same. So hashing 1 megabyte should take around 10 milliseconds and hashing 1 kilobyte would take 0.01 milliseconds, ie it&#039;s dwarfed by the cost of the ECDSA and thus can be ignored.&lt;br /&gt;
&lt;br /&gt;
So the slowest part of verifying a transaction is verifying its inputs, which is ~3 msec per input on todays hardware. It seems like in the current blockchain most transactions have only one input, and a few have more like 5/6 inputs. Let&#039;s call it an average of 2 inputs overall.  However each transaction input is verified twice: once when first received, and a second time when a block containing that transaction is received, so call it 12msec in total per transaction.&lt;br /&gt;
&lt;br /&gt;
This means a single core today can probably, with tuning and the block chain held in RAM but no special hardware beyond that, verify and accept about 80 transactions/sec. This means a network node capable of keeping up with VISA would need roughly 50 cores + whatever is used for mining (done by separate machines/GPUs). Whilst building a single machine with 50 cores would be kind of a pain load balancing inbound &amp;quot;tx&amp;quot; messages over multiple machines would be very easy. Certainly a single machine could easily load balance all of VISAs transactions to a small group of verification machines which would then send the verified tx hash to the miners for incorporation into the merkle tree.&lt;br /&gt;
&lt;br /&gt;
For receiving and handling all the &amp;quot;tx&amp;quot; messages, you therefore could build a rack of 12 4-core machines that would keep up.&lt;br /&gt;
&lt;br /&gt;
That leaves the inbound inv messages. The cost of handling an inv is basically reading a small message from the network and then doing a RAM lookup to see if we already have the transaction. This is really, really fast. A single core could easily handle several thousand inv messages per second before breaking a sweat, even assuming it needs to read from a sharded in-memory block chain index.&lt;br /&gt;
&lt;br /&gt;
==Network==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s assume an average rate of 2000tps, so just VISA. Transactions vary in size from about 0.2 kilobytes to over 1 kilobyte, but from looking at the block explorer it&#039;s probably averaging half a kilobyte today. So let&#039;s assume the way people use BitCoin gets more complicated and call it 1kb per transaction.&lt;br /&gt;
&lt;br /&gt;
A solved block will then be around (1024 bytes * 2000tps * 60 seconds in a minute * 10minutes) / 1024 bytes in a kilobyte / 1024 kilobytes in a megabyte / 1024 megabytes in a gigabyte = 1.14 gigabytes per block.&lt;br /&gt;
&lt;br /&gt;
But you only have to transmit a solved block to your connected peers. If we assume these big futuristic supernodes have something like 40 or 50 peered connections, that means in the worst case scenario where you solve a block OR you receive a block but none of your peers have it yet (unlikely), you have to send ~57 gigabytes of data (call it 60).&lt;br /&gt;
&lt;br /&gt;
Shifting 60 gigabytes of data in, say, 60 seconds means an average rate of 1 gigabyte per second, or 8 gigabits per second.&lt;br /&gt;
&lt;br /&gt;
The real question you want to know is how much does that sort of bandwidth cost? Well, bandwidth prices are a very tricky thing as some of the largest consumers pay the least due to how peering agreements work. The Googles and Akamais of this world will pay way less for a 10G wave than a small operator would. And, you wouldn&#039;t be hitting the 8Gbps very frequently .... only when you solve a block, really, as when relaying a block the peers you connect to will likely have already received it from some other peer anyway so only a subset would need to receive it from you. &lt;br /&gt;
&lt;br /&gt;
Luckily, a node would very likely not have to transfer this much data this quickly. Assuming all nodes are equally well connected to other nodes with the same number of connections, each node would only have to send one copy of each block received, on average. Even if you are the first node to become aware of a block, once you send the block to 3 or 4 others, it would propagate among the others in exponentially growing numbers, similar to the bit-torrent protocol. &lt;br /&gt;
&lt;br /&gt;
Take a look at [http://icecolo.com/colocation-packages] to get a feel for data transfer costs.&lt;br /&gt;
&lt;br /&gt;
==Storage==&lt;br /&gt;
&lt;br /&gt;
At very high transaction rates each block can be over a gigabyte in size. These blocks must be stored somewhere. Whilst for speed it&#039;d be ideal to store the block chain entirely in RAM, for cheapness storing only the hot parts in RAM and the rest on disk is the way to go. A 3 terabyte hard disk costs less than $200 today and will be cheaper still in future, so you&#039;d need one such disk for every 21 days of operation (at 1gb per block).&lt;br /&gt;
&lt;br /&gt;
==Network structure==&lt;br /&gt;
&lt;br /&gt;
Today BitCoin is a flat peer to peer network in which all nodes are equal. However the intention is to evolve it towards a more typical two-tier structure in which low powered client nodes connect to long-lived, high powered supernodes. The protocol already has some support for this (see the services flags in the version/address messages). However client mode is only partially implemented and no code exists to decide if and when to switch between supernode/client node status.&lt;br /&gt;
&lt;br /&gt;
As the network scales up, the costs of running a supernode that stores the full block chain and verifies every transaction will get progressively higher, but the two tier structure ensures everyone can still get started quickly. Client nodes only need to download a small number of headers the first time they connect (from their last checkpoint until the chain head). It&#039;s quite possible to run such nodes on a modern smartphone. The security model for lightweight clients is slightly different to a full node: whilst they don&#039;t need to talk to a trusted node (ie any network node will do), in that configuration it&#039;s important that the network be very difficult to attack as the block contents are not verified.&lt;br /&gt;
&lt;br /&gt;
==Optimizations==&lt;br /&gt;
&lt;br /&gt;
The description above applies to the current software. However several optimizations exist that can dramatically cheapen the cost of running a node and these are fairly easy to implement.&lt;br /&gt;
&lt;br /&gt;
===CPU===&lt;br /&gt;
&lt;br /&gt;
The CPU cost of a transaction is doubled by the fact that the current software verifies each input twice. There&#039;s no need for this. Once a transaction is received the fact that it passed verification can be stored, and when it re-appears in a block the second verification can be skipped. This would roughly double per-core capacity, ie you would need only 25 cores to verify VISA-level traffic loads. This can actually fit into a single high-end server.&lt;br /&gt;
&lt;br /&gt;
===Storage===&lt;br /&gt;
&lt;br /&gt;
The storage costs of the block chain calculated above assume transactions are never deleted. Satoshi&#039;s paper explains how transactions with fully spent outputs can be pruned from long term storage due to how they are arranged in a Merkle tree. Nodes try to avoid accumulating lots of small unspent outputs as that means to send a reasonable quantity of coins would require transactions with lots of inputs and thus, be large and perhaps requiring a fee. Because nodes fight fragmentation, as time goes by it&#039;s likely that many blocks can be completely pruned of all or nearly all transactions, reducing their storage costs in the best case down to 80 bytes. As of May, 2011, the software does not implement pruning, and the potential savings are [http://forum.bitcoin.org/index.php?topic=9461.msg137059#msg137059 calculated] at 71% of transactions or 73% of raw block bytes.&lt;br /&gt;
&lt;br /&gt;
===Bandwidth===&lt;br /&gt;
&lt;br /&gt;
The network costs of distributing blocks can be minimized by changing the protocol to send blocks as a header plus a list of hashes. Because nodes are very likely to have already seen a transaction when it was first broadcast, this means the size of a block to download would be trivial (80 bytes + 32 bytes per transaction). If a node didn&#039;t see a transaction broadcast, it can ask the connected node to provide it.&lt;br /&gt;
&lt;br /&gt;
===Network structure===&lt;br /&gt;
&lt;br /&gt;
The peer-finding mechanism today relies on IRC. Switching to DNS would give dramatically faster startup times that do not scale with the size of the network. NOTE: This is done in 0.3.24&lt;br /&gt;
&lt;br /&gt;
===Simplified payment verification===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to build a Bitcoin implementation that does not verify everything, but instead relies on either connecting to a trusted node, or puts its faith in high difficulty as a proxy for proof of validity. [[BitCoinJ]] is an implementation of this mode.&lt;br /&gt;
&lt;br /&gt;
In SPV mode, named after the section of Satoshis paper that describes it, clients connect to an arbitrary full node and download only the block headers. They verify the chain headers connect together correctly and that the difficulty is high enough. They then request transactions matching particular patterns from the remote node (ie, payments to your addresses), which provides copies of those transactions along with a Merkle branch linking them to the block in which they appeared. This exploits the Merkle tree structure to allow proof of inclusion without needing the full contents of the block. The pattern matching protocol message isn&#039;t implemented yet, [http://forum.bitcoin.org/index.php?topic=7972.msg116285#msg116285 a proposal] was discussed in May 2011.&lt;br /&gt;
&lt;br /&gt;
As a further optimization, block headers that are buried sufficiently deep can be thrown away after some time (eg, you only really need to store say 1000 blocks).&lt;br /&gt;
&lt;br /&gt;
The level of difficulty required to obtain confidence the remote node is not feeding you fictional transactions depends on your threat model. If you are connecting to a node that is known to be reliable, the difficulty doesn&#039;t matter. If you want to pick a random node, the cost for an attacker to mine a block sequence containing a bogus transaction should be higher than the value to be obtained by defrauding you. By changing how deeply buried the block must be, you can trade off confirmation time vs cost of an attack.&lt;br /&gt;
&lt;br /&gt;
Programs implementing this approach can have fixed storage/network overhead in the null case of no usage, and resource usage proportional to received/sent transactions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=User:Clark&amp;diff=13513</id>
		<title>User:Clark</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=User:Clark&amp;diff=13513"/>
		<updated>2011-07-23T16:02:42Z</updated>

		<summary type="html">&lt;p&gt;Clark: Created page with &amp;quot;I am the creator of the Real Time Bitcoin Market Data services.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am the creator of the [[Real Time Bitcoin Market Data]] services.&lt;/div&gt;</summary>
		<author><name>Clark</name></author>
	</entry>
</feed>