<?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=Brec</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=Brec"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Brec"/>
	<updated>2026-05-14T00:57:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22738</id>
		<title>P2Pool</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22738"/>
		<updated>2012-01-25T15:23:15Z</updated>

		<summary type="html">&lt;p&gt;Brec: /* Stales */ link PPLNS to page containing explanation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:P2pool_chain.png‎|thumb|350px|right|Visualization of the P2Pool share chain]]&lt;br /&gt;
P2Pool is a decentralized [[Bitcoin]] [[Bitcoin Pool|mining pool]] that works by creating a peer-to-peer network of miner nodes.&lt;br /&gt;
&lt;br /&gt;
Decentralized payout pooling solves the problem of centralized mining pools degrading the decentralization of Bitcoin, avoids the risk of hard to detect theft by pool operators, and has better fundamental resistance to DoS attacks than centralized pools.&lt;br /&gt;
&lt;br /&gt;
Miners are configured to connect to a P2Pool node that can be run locally, alongside the miner. P2Pool users must run a full Bitcoin node which serves the purpose of independently validating transactions and the Bitcoin blockchain. P2Pool also supports merged mining and several alternative blockchains.&lt;br /&gt;
&lt;br /&gt;
P2Pool nodes work on a chain of shares similar to Bitcoin&#039;s blockchain. Each node works on a block that includes payouts to the previous shares&#039; owners and the node itself, which can also result in a share if it meets P2Pool&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
Because of the importance of strengthening Bitcoin&#039;s decentralization some Bitcoin supporters donate to P2Pool miners, resulting in returns above 100% of the expected reward.  &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
P2Pool shares form a &amp;quot;sharechain&amp;quot; with each share referencing the previous share&#039;s hash. Each share contains a standard Bitcoin block header, some P2Pool-specific data that is used to compute the generation transaction (total subsidy, payout script of this share, a nonce, the previous share&#039;s hash, and the current target for shares), and a Merkle branch linking that generation transaction to the block header&#039;s Merkle hash.&lt;br /&gt;
&lt;br /&gt;
The chain continuously regulates its target to keep generation around one share every ten seconds, just as Bitcoin regulates it to generate one block every ten minutes.&lt;br /&gt;
&lt;br /&gt;
Unlike Bitcoin, nodes do not know the entire chain - instead they only hold the last 8640 shares (the last day&#039;s worth). In order to prevent an attacker from working on a chain in secret and then releasing it, overriding the existing chain, chains are judged by how much work they have since a point in the past. To ascertain that the work has been done since that point, nodes look at the Bitcoin blocks that the shares reference, establishing a provable timestamp. (If a share points to a block, it was definitely made after that block was made.)&lt;br /&gt;
&lt;br /&gt;
=== Payout logic ===&lt;br /&gt;
&lt;br /&gt;
Each share contains a generation transaction that pays to the previous &#039;&#039;n&#039;&#039; shares, where &#039;&#039;n&#039;&#039; is the number of shares whose total work is equal to 3 times the average work required to solve a block, or 8640, whichever is smaller. Payouts are weighted based on the amount of work each share took to solve, which is proportional to the p2pool difficulty at that time.&lt;br /&gt;
&lt;br /&gt;
The block reward (currently 50BTC) and the transaction fees are combined and apportioned according to these rules:&lt;br /&gt;
&lt;br /&gt;
A subsidy of 0.5% is sent to the node that solved the block in order to discourage not sharing solutions that qualify as a block. (A miner with the aim to harm others could withhold the block, thereby preventing anybody from getting paid. He can NOT redirect the payout to himself.) The remaining 99.5% is distributed evenly to miners based on work done recently.&lt;br /&gt;
&lt;br /&gt;
In the event that a share qualifies as a block, this generation transaction is exposed to the Bitcoin network and takes effect, transferring each node its payout.&lt;br /&gt;
&lt;br /&gt;
=== Stales ===&lt;br /&gt;
&lt;br /&gt;
P2Pool stales don&#039;t work the same way as stales on centralized pools. On a centralized pool a stale is work which is too old to be accepted by the pool&#039;s Bitcoin node; this kind of stale is very rare in P2Pool because each user runs their own local bitcoind.&lt;br /&gt;
&lt;br /&gt;
On P2Pool stales refer to shares which can&#039;t make it into the sharechain.  Because the sharechain is 60 times faster than the Bitcoin chain many stales are common and expected. However, because the payout is [[Comparison_of_mining_pools|PPLNS]] only your stale rate relative to other nodes is relevant; the absolute rate is not.&lt;br /&gt;
&lt;br /&gt;
There are two reported kinds of stales in P2Pool: &amp;quot;DEAD ON ARRIVAL&amp;quot; shares and orphan shares. Dead shares were too old by the time they arrived at your local P2Pool. Very high dead rates can indicate miner misconfiguration. Orphan shares are shares which were not extended by the rest of the P2Pool network, because some other miner&#039;s share was accepted first. Very high orphan rates may indicate network connectivity problems. &lt;br /&gt;
&lt;br /&gt;
The P2Pool console output shows your relative stale rate compared to other P2Pool miners in the &#039;Own efficiency&#039; column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2012-01-07 20:57:51.797420 Pool stales: 13% Own: 13±2% Own efficiency: 100±2%&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you first start P2Pool claimed efficiency will be low and the error bounds on this estimate will be large, but as it runs the numbers will converge to their correct values.&lt;br /&gt;
&lt;br /&gt;
If your efficiency is unusually low, make sure your network connection isn&#039;t overloaded, that your miners support long polling and are not set to work for excessive amounts of time, and that your bitcoind has multiple connections.&lt;br /&gt;
&lt;br /&gt;
== Joining the pool ==&lt;br /&gt;
&lt;br /&gt;
Follow these steps to join the pool:&lt;br /&gt;
&lt;br /&gt;
* Run Bitcoin with the RPC interface enabled: put rpcuser=USER, rpcpassword=PASS, and server=1 in bitcoin.conf&lt;br /&gt;
** Bitcoin 0.5 or later is required&lt;br /&gt;
** It&#039;s important that your Bitcoin client be fully synchronized before starting. It&#039;s also better if you have the Bitcoin port forwarded&lt;br /&gt;
* Download p2pool:&lt;br /&gt;
** Windows binary: See http://forum.bitcoin.org/index.php?topic=18313.0&lt;br /&gt;
** Source download: https://github.com/forrestv/p2pool/tags&lt;br /&gt;
** git: git clone git://github.com/forrestv/p2pool.git&lt;br /&gt;
* Run p2pool: (See below for additional options.)&lt;br /&gt;
** Windows py2exe: run_p2pool.exe USER PASS&lt;br /&gt;
** Source: python run_p2pool.py USER PASS&lt;br /&gt;
* Run a miner daemon with long polling connecting to 127.0.0.1 (or the IP of the host running p2pool if you&#039;re mining remotely) on port 9332 with any username and password&lt;br /&gt;
** cgminer -O u:p -o http://127.0.0.1:9332/&lt;br /&gt;
&lt;br /&gt;
Dependencies if running from source:&lt;br /&gt;
* Python 2.6 or higher&lt;br /&gt;
* python-argparse for Python 2.6 and lower&lt;br /&gt;
* Twisted (Ubuntu package python-twisted)&lt;br /&gt;
&lt;br /&gt;
=== Miners ===&lt;br /&gt;
&lt;br /&gt;
This is all for the latest p2pool version, as it includes several new workarounds. With all miners, using a high FPS target (100?) or a low aggression, and waiting for p2pool to completely start (line shows &amp;gt; 17000 shares) helps a lot with reducing stales.&lt;br /&gt;
&lt;br /&gt;
P2Pool uses higher difficulty shares than most centralized pools, so you&#039;ll see fewer shares reported. This is normal and doesn&#039;t reduce your payments.  It&#039;s also normal to see longpoll messages once per every ten seconds on average.&lt;br /&gt;
&lt;br /&gt;
==== Works as-is ====&lt;br /&gt;
&lt;br /&gt;
===== cgminer =====&lt;br /&gt;
Works very well as is.&lt;br /&gt;
&lt;br /&gt;
===== ufasoft ===== &lt;br /&gt;
Works as is.&lt;br /&gt;
&lt;br /&gt;
===== DiabloMiner =====&lt;br /&gt;
Works fine after commit 3b731b9b54.&lt;br /&gt;
&lt;br /&gt;
==== Needs patch to reduce stales ====&lt;br /&gt;
&lt;br /&gt;
===== Poclbm =====&lt;br /&gt;
Waits a full second between long polls.&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/poclbm&lt;br /&gt;
Pull request: https://github.com/m0mchil/poclbm/pull/41&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone git://github.com/forrestv/poclbm.git&lt;br /&gt;
cd poclbm&lt;br /&gt;
git checkout fast_long_polling&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/wodukkea/p2pool-poclbm_win32_5590e7c.zip&lt;br /&gt;
&lt;br /&gt;
===== Phoenix =====&lt;br /&gt;
(Works fine after commit 8263f65!)&lt;br /&gt;
&lt;br /&gt;
Has a similar bug (waiting a full second).&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/phoenix-miner&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/ycvzejfm/phoenix-miner-fba48d2-5.zip&lt;br /&gt;
&lt;br /&gt;
==== Not-compatible ====&lt;br /&gt;
&lt;br /&gt;
===== puddinpop&#039;s RPC Miners =====&lt;br /&gt;
Does not have long polling so will not work at all.&lt;br /&gt;
&lt;br /&gt;
=== Option Reference ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: run_p2pool.py [-h] [--version] [--net {bitcoin, litecoin, namecoin}]&lt;br /&gt;
                     [--testnet] [--debug] [-a ADDRESS] [--logfile LOGFILE]&lt;br /&gt;
                     [--merged-url MERGED_URL]&lt;br /&gt;
                     [--merged-userpass MERGED_USERPASS]&lt;br /&gt;
                     [--give-author DONATION_PERCENTAGE] [--p2pool-port PORT]&lt;br /&gt;
                     [-n ADDR[:PORT]] [--disable-upnp] [-w PORT]&lt;br /&gt;
                     [-f FEE_PERCENTAGE] [--bitcoind-address BITCOIND_ADDRESS]&lt;br /&gt;
                     [--bitcoind-rpc-port BITCOIND_RPC_PORT]&lt;br /&gt;
                     [--bitcoind-p2p-port BITCOIND_P2P_PORT]&lt;br /&gt;
                     [BITCOIND_RPCUSER] BITCOIND_RPCPASSWORD&lt;br /&gt;
&lt;br /&gt;
p2pool (version 31cbeea)&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  --version             show program&#039;s version number and exit&lt;br /&gt;
  --net {bitcoin, litecoin, namecoin}&lt;br /&gt;
                        use specified network (default: bitcoin)&lt;br /&gt;
  --testnet             use the network&#039;s testnet&lt;br /&gt;
  --debug               enable debugging mode&lt;br /&gt;
  -a ADDRESS, --address ADDRESS&lt;br /&gt;
                        generate payouts to this address (default: &amp;lt;address&lt;br /&gt;
                        requested from bitcoind&amp;gt;)&lt;br /&gt;
  --logfile LOGFILE     log to this file (default: data/&amp;lt;NET&amp;gt;/log)&lt;br /&gt;
  --merged-url MERGED_URL&lt;br /&gt;
                        call getauxblock on this url to get work for merged&lt;br /&gt;
                        mining (example: http://127.0.0.1:10332/)&lt;br /&gt;
  --merged-userpass MERGED_USERPASS&lt;br /&gt;
                        use this user and password when requesting merged&lt;br /&gt;
                        mining work (example: ncuser:ncpass)&lt;br /&gt;
  --give-author DONATION_PERCENTAGE&lt;br /&gt;
                        donate this percentage of work to author of p2pool&lt;br /&gt;
                        (default: 0.5)&lt;br /&gt;
  --disable-upnp        don&#039;t attempt to use UPnP to forward p2pool&#039;s P2P port&lt;br /&gt;
                        from the Internet to this computer&lt;br /&gt;
&lt;br /&gt;
p2pool interface:&lt;br /&gt;
  --p2pool-port PORT    use port PORT to listen for connections (forward this&lt;br /&gt;
                        port from your router!) (default: bitcoin:9333,&lt;br /&gt;
                        litecoin:9338, namecoin:9334)&lt;br /&gt;
  -n ADDR[:PORT], --p2pool-node ADDR[:PORT]&lt;br /&gt;
                        connect to existing p2pool node at ADDR listening on&lt;br /&gt;
                        port PORT (defaults to default p2pool P2P port) in&lt;br /&gt;
                        addition to builtin addresses&lt;br /&gt;
&lt;br /&gt;
worker interface:&lt;br /&gt;
  -w PORT, --worker-port PORT&lt;br /&gt;
                        listen on PORT for RPC connections from miners&lt;br /&gt;
                        (default: bitcoin:9332, litecoin:9327, namecoin:9331)&lt;br /&gt;
  -f FEE_PERCENTAGE, --fee FEE_PERCENTAGE&lt;br /&gt;
                        charge workers mining to their own bitcoin address (by&lt;br /&gt;
                        setting their miner&#039;s username to a bitcoin address)&lt;br /&gt;
                        this percentage fee to mine on your p2pool instance.&lt;br /&gt;
                        Amount displayed at http://127.0.0.1:WORKER_PORT/fee&lt;br /&gt;
                        (default: 0)&lt;br /&gt;
&lt;br /&gt;
bitcoind interface:&lt;br /&gt;
  --bitcoind-address BITCOIND_ADDRESS&lt;br /&gt;
                        connect to this address (default: 127.0.0.1)&lt;br /&gt;
  --bitcoind-rpc-port BITCOIND_RPC_PORT&lt;br /&gt;
                        connect to JSON-RPC interface at this port (default:&lt;br /&gt;
                        bitcoin:8332, litecoin:9332, namecoin:8332)&lt;br /&gt;
  --bitcoind-p2p-port BITCOIND_P2P_PORT&lt;br /&gt;
                        connect to P2P interface at this port (default:&lt;br /&gt;
                        bitcoin:8333, litecoin:9333, namecoin:8334)&lt;br /&gt;
  BITCOIND_RPCUSER      bitcoind RPC interface username (default: &amp;lt;empty&amp;gt;)&lt;br /&gt;
  BITCOIND_RPCPASSWORD  bitcoind RPC interface password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Protocol description ==&lt;br /&gt;
&lt;br /&gt;
P2Pool&#039;s protocol mirrors Bitcoin&#039;s P2P protocol in many ways. It uses the same framing (prefix, command, length, checksum, payload) and similar commands:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;version&#039;&#039;&#039; - sent to establish a connection - contains (&#039;&#039;version&#039;&#039;, &#039;&#039;services&#039;&#039;, &#039;&#039;addr_to&#039;&#039;, &#039;&#039;addr_from&#039;&#039;, &#039;&#039;nonce&#039;&#039;, &#039;&#039;sub_version&#039;&#039;, &#039;&#039;mode&#039;&#039;, &#039;&#039;best_share_hash&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;setmode&#039;&#039;&#039; - sent to update the &#039;&#039;mode&#039;&#039; sent in the &#039;&#039;&#039;version&#039;&#039;&#039; message - contains (&#039;&#039;mode&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;ping&#039;&#039;&#039; - sent to keep connection alive - contains ()&lt;br /&gt;
* &#039;&#039;&#039;addrme&#039;&#039;&#039; - request that the receiving node send out an addr for the sending node - contains (&#039;&#039;port&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;addrs&#039;&#039;&#039; - broadcast list of nodes&#039; addresses - contains (&#039;&#039;addrs&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getaddrs&#039;&#039;&#039; - request that the receiving node send &#039;&#039;count&#039;&#039; addrs - contains (&#039;&#039;count&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getshares&#039;&#039;&#039; - request that the receiving node send the shares referenced by &#039;&#039;hashes&#039;&#039; and &#039;&#039;parents&#039;&#039; of their parents, stopping at any share referenced by &#039;&#039;stops&#039;&#039; - contains (&#039;&#039;hashes&#039;&#039;, &#039;&#039;parents&#039;&#039;, &#039;&#039;stops&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;shares&#039;&#039;&#039; - broadcast message of the contents of shares - contains (&#039;&#039;shares&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
This project was announced on June 17, 2011 by Forrest Voight&amp;lt;ref&amp;gt;[https://forum.bitcoin.org/index.php?topic=18313.0 p2pool: Decentralized, DoS-resistant, Hop-Proof - Now active on mainnet!]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The began testing against mainnet in mid-July, 2011.  The pool was reviewed on a [[Bitcoin Miner]] post on July 26, 2011&amp;lt;ref&amp;gt;[http://www.bitcoinminer.com/post/8101660461 P2Pool Decentralized Pool Nearly Ready For Prime-Time]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The software author&#039;s address for donations can be found in the signature section of his [http://forum.bitcoin.org/index.php?action=profile;u=6447 forum profile].&lt;br /&gt;
&lt;br /&gt;
==Donating to P2Pool miners==&lt;br /&gt;
In order to encourage people to mine to P2Pool you can donate to the recent miners in proportion using a sendmany:&lt;br /&gt;
&lt;br /&gt;
E.g. a bash script to donate 10 btc is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~/src/bitcoin/src/bitcoind sendmany &amp;quot;&amp;quot; &amp;quot;$(GET http://forre.st:9332/patron_sendmany?total=10.0)&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can replace &amp;quot;&amp;quot; with &amp;quot;accountname&amp;quot; if you want to pay from some specific bitcoind account, and you can replace forre.st with 127.0.0.1 if you&#039;re running a P2Pool node locally, so you don&#039;t have to trust that the URL gives accurate figures.&lt;br /&gt;
&lt;br /&gt;
If you decide to donate you should announce it on the forums so that your donations provide the most incentive possible.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Comparison of mining pools]]&lt;br /&gt;
* [[Pooled Mining]]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://forum.bitcoin.org/index.php?topic=18313.0 P2Pool forum]&lt;br /&gt;
* [https://github.com/forrestv/p2pool p2pool] project on GitHub&lt;br /&gt;
* {{Freenode IRC|p2pool}} discussion and support&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Pool Operators]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22737</id>
		<title>P2Pool</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22737"/>
		<updated>2012-01-25T15:15:46Z</updated>

		<summary type="html">&lt;p&gt;Brec: /* Stales */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:P2pool_chain.png‎|thumb|350px|right|Visualization of the P2Pool share chain]]&lt;br /&gt;
P2Pool is a decentralized [[Bitcoin]] [[Bitcoin Pool|mining pool]] that works by creating a peer-to-peer network of miner nodes.&lt;br /&gt;
&lt;br /&gt;
Decentralized payout pooling solves the problem of centralized mining pools degrading the decentralization of Bitcoin, avoids the risk of hard to detect theft by pool operators, and has better fundamental resistance to DoS attacks than centralized pools.&lt;br /&gt;
&lt;br /&gt;
Miners are configured to connect to a P2Pool node that can be run locally, alongside the miner. P2Pool users must run a full Bitcoin node which serves the purpose of independently validating transactions and the Bitcoin blockchain. P2Pool also supports merged mining and several alternative blockchains.&lt;br /&gt;
&lt;br /&gt;
P2Pool nodes work on a chain of shares similar to Bitcoin&#039;s blockchain. Each node works on a block that includes payouts to the previous shares&#039; owners and the node itself, which can also result in a share if it meets P2Pool&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
Because of the importance of strengthening Bitcoin&#039;s decentralization some Bitcoin supporters donate to P2Pool miners, resulting in returns above 100% of the expected reward.  &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
P2Pool shares form a &amp;quot;sharechain&amp;quot; with each share referencing the previous share&#039;s hash. Each share contains a standard Bitcoin block header, some P2Pool-specific data that is used to compute the generation transaction (total subsidy, payout script of this share, a nonce, the previous share&#039;s hash, and the current target for shares), and a Merkle branch linking that generation transaction to the block header&#039;s Merkle hash.&lt;br /&gt;
&lt;br /&gt;
The chain continuously regulates its target to keep generation around one share every ten seconds, just as Bitcoin regulates it to generate one block every ten minutes.&lt;br /&gt;
&lt;br /&gt;
Unlike Bitcoin, nodes do not know the entire chain - instead they only hold the last 8640 shares (the last day&#039;s worth). In order to prevent an attacker from working on a chain in secret and then releasing it, overriding the existing chain, chains are judged by how much work they have since a point in the past. To ascertain that the work has been done since that point, nodes look at the Bitcoin blocks that the shares reference, establishing a provable timestamp. (If a share points to a block, it was definitely made after that block was made.)&lt;br /&gt;
&lt;br /&gt;
=== Payout logic ===&lt;br /&gt;
&lt;br /&gt;
Each share contains a generation transaction that pays to the previous &#039;&#039;n&#039;&#039; shares, where &#039;&#039;n&#039;&#039; is the number of shares whose total work is equal to 3 times the average work required to solve a block, or 8640, whichever is smaller. Payouts are weighted based on the amount of work each share took to solve, which is proportional to the p2pool difficulty at that time.&lt;br /&gt;
&lt;br /&gt;
The block reward (currently 50BTC) and the transaction fees are combined and apportioned according to these rules:&lt;br /&gt;
&lt;br /&gt;
A subsidy of 0.5% is sent to the node that solved the block in order to discourage not sharing solutions that qualify as a block. (A miner with the aim to harm others could withhold the block, thereby preventing anybody from getting paid. He can NOT redirect the payout to himself.) The remaining 99.5% is distributed evenly to miners based on work done recently.&lt;br /&gt;
&lt;br /&gt;
In the event that a share qualifies as a block, this generation transaction is exposed to the Bitcoin network and takes effect, transferring each node its payout.&lt;br /&gt;
&lt;br /&gt;
=== Stales ===&lt;br /&gt;
&lt;br /&gt;
P2Pool stales don&#039;t work the same way as stales on centralized pools. On a centralized pool a stale is work which is too old to be accepted by the pool&#039;s Bitcoin node; this kind of stale is very rare in P2Pool because each user runs their own local bitcoind.&lt;br /&gt;
&lt;br /&gt;
On P2Pool stales refer to shares which can&#039;t make it into the sharechain.  Because the sharechain is 60 times faster than the Bitcoin chain many stales are common and expected. However, because the payout is PPLNS only your stale rate relative to other nodes is relevant; the absolute rate is not.&lt;br /&gt;
&lt;br /&gt;
There are two reported kinds of stales in P2Pool: &amp;quot;DEAD ON ARRIVAL&amp;quot; shares and orphan shares. Dead shares were too old by the time they arrived at your local P2Pool. Very high dead rates can indicate miner misconfiguration. Orphan shares are shares which were not extended by the rest of the P2Pool network, because some other miner&#039;s share was accepted first. Very high orphan rates may indicate network connectivity problems. &lt;br /&gt;
&lt;br /&gt;
The P2Pool console output shows your relative stale rate compared to other P2Pool miners in the &#039;Own efficiency&#039; column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2012-01-07 20:57:51.797420 Pool stales: 13% Own: 13±2% Own efficiency: 100±2%&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you first start P2Pool claimed efficiency will be low and the error bounds on this estimate will be large, but as it runs the numbers will converge to their correct values.&lt;br /&gt;
&lt;br /&gt;
If your efficiency is unusually low, make sure your network connection isn&#039;t overloaded, that your miners support long polling and are not set to work for excessive amounts of time, and that your bitcoind has multiple connections.&lt;br /&gt;
&lt;br /&gt;
== Joining the pool ==&lt;br /&gt;
&lt;br /&gt;
Follow these steps to join the pool:&lt;br /&gt;
&lt;br /&gt;
* Run Bitcoin with the RPC interface enabled: put rpcuser=USER, rpcpassword=PASS, and server=1 in bitcoin.conf&lt;br /&gt;
** Bitcoin 0.5 or later is required&lt;br /&gt;
** It&#039;s important that your Bitcoin client be fully synchronized before starting. It&#039;s also better if you have the Bitcoin port forwarded&lt;br /&gt;
* Download p2pool:&lt;br /&gt;
** Windows binary: See http://forum.bitcoin.org/index.php?topic=18313.0&lt;br /&gt;
** Source download: https://github.com/forrestv/p2pool/tags&lt;br /&gt;
** git: git clone git://github.com/forrestv/p2pool.git&lt;br /&gt;
* Run p2pool: (See below for additional options.)&lt;br /&gt;
** Windows py2exe: run_p2pool.exe USER PASS&lt;br /&gt;
** Source: python run_p2pool.py USER PASS&lt;br /&gt;
* Run a miner daemon with long polling connecting to 127.0.0.1 (or the IP of the host running p2pool if you&#039;re mining remotely) on port 9332 with any username and password&lt;br /&gt;
** cgminer -O u:p -o http://127.0.0.1:9332/&lt;br /&gt;
&lt;br /&gt;
Dependencies if running from source:&lt;br /&gt;
* Python 2.6 or higher&lt;br /&gt;
* python-argparse for Python 2.6 and lower&lt;br /&gt;
* Twisted (Ubuntu package python-twisted)&lt;br /&gt;
&lt;br /&gt;
=== Miners ===&lt;br /&gt;
&lt;br /&gt;
This is all for the latest p2pool version, as it includes several new workarounds. With all miners, using a high FPS target (100?) or a low aggression, and waiting for p2pool to completely start (line shows &amp;gt; 17000 shares) helps a lot with reducing stales.&lt;br /&gt;
&lt;br /&gt;
P2Pool uses higher difficulty shares than most centralized pools, so you&#039;ll see fewer shares reported. This is normal and doesn&#039;t reduce your payments.  It&#039;s also normal to see longpoll messages once per every ten seconds on average.&lt;br /&gt;
&lt;br /&gt;
==== Works as-is ====&lt;br /&gt;
&lt;br /&gt;
===== cgminer =====&lt;br /&gt;
Works very well as is.&lt;br /&gt;
&lt;br /&gt;
===== ufasoft ===== &lt;br /&gt;
Works as is.&lt;br /&gt;
&lt;br /&gt;
===== DiabloMiner =====&lt;br /&gt;
Works fine after commit 3b731b9b54.&lt;br /&gt;
&lt;br /&gt;
==== Needs patch to reduce stales ====&lt;br /&gt;
&lt;br /&gt;
===== Poclbm =====&lt;br /&gt;
Waits a full second between long polls.&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/poclbm&lt;br /&gt;
Pull request: https://github.com/m0mchil/poclbm/pull/41&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone git://github.com/forrestv/poclbm.git&lt;br /&gt;
cd poclbm&lt;br /&gt;
git checkout fast_long_polling&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/wodukkea/p2pool-poclbm_win32_5590e7c.zip&lt;br /&gt;
&lt;br /&gt;
===== Phoenix =====&lt;br /&gt;
(Works fine after commit 8263f65!)&lt;br /&gt;
&lt;br /&gt;
Has a similar bug (waiting a full second).&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/phoenix-miner&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/ycvzejfm/phoenix-miner-fba48d2-5.zip&lt;br /&gt;
&lt;br /&gt;
==== Not-compatible ====&lt;br /&gt;
&lt;br /&gt;
===== puddinpop&#039;s RPC Miners =====&lt;br /&gt;
Does not have long polling so will not work at all.&lt;br /&gt;
&lt;br /&gt;
=== Option Reference ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: run_p2pool.py [-h] [--version] [--net {bitcoin, litecoin, namecoin}]&lt;br /&gt;
                     [--testnet] [--debug] [-a ADDRESS] [--logfile LOGFILE]&lt;br /&gt;
                     [--merged-url MERGED_URL]&lt;br /&gt;
                     [--merged-userpass MERGED_USERPASS]&lt;br /&gt;
                     [--give-author DONATION_PERCENTAGE] [--p2pool-port PORT]&lt;br /&gt;
                     [-n ADDR[:PORT]] [--disable-upnp] [-w PORT]&lt;br /&gt;
                     [-f FEE_PERCENTAGE] [--bitcoind-address BITCOIND_ADDRESS]&lt;br /&gt;
                     [--bitcoind-rpc-port BITCOIND_RPC_PORT]&lt;br /&gt;
                     [--bitcoind-p2p-port BITCOIND_P2P_PORT]&lt;br /&gt;
                     [BITCOIND_RPCUSER] BITCOIND_RPCPASSWORD&lt;br /&gt;
&lt;br /&gt;
p2pool (version 31cbeea)&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  --version             show program&#039;s version number and exit&lt;br /&gt;
  --net {bitcoin, litecoin, namecoin}&lt;br /&gt;
                        use specified network (default: bitcoin)&lt;br /&gt;
  --testnet             use the network&#039;s testnet&lt;br /&gt;
  --debug               enable debugging mode&lt;br /&gt;
  -a ADDRESS, --address ADDRESS&lt;br /&gt;
                        generate payouts to this address (default: &amp;lt;address&lt;br /&gt;
                        requested from bitcoind&amp;gt;)&lt;br /&gt;
  --logfile LOGFILE     log to this file (default: data/&amp;lt;NET&amp;gt;/log)&lt;br /&gt;
  --merged-url MERGED_URL&lt;br /&gt;
                        call getauxblock on this url to get work for merged&lt;br /&gt;
                        mining (example: http://127.0.0.1:10332/)&lt;br /&gt;
  --merged-userpass MERGED_USERPASS&lt;br /&gt;
                        use this user and password when requesting merged&lt;br /&gt;
                        mining work (example: ncuser:ncpass)&lt;br /&gt;
  --give-author DONATION_PERCENTAGE&lt;br /&gt;
                        donate this percentage of work to author of p2pool&lt;br /&gt;
                        (default: 0.5)&lt;br /&gt;
  --disable-upnp        don&#039;t attempt to use UPnP to forward p2pool&#039;s P2P port&lt;br /&gt;
                        from the Internet to this computer&lt;br /&gt;
&lt;br /&gt;
p2pool interface:&lt;br /&gt;
  --p2pool-port PORT    use port PORT to listen for connections (forward this&lt;br /&gt;
                        port from your router!) (default: bitcoin:9333,&lt;br /&gt;
                        litecoin:9338, namecoin:9334)&lt;br /&gt;
  -n ADDR[:PORT], --p2pool-node ADDR[:PORT]&lt;br /&gt;
                        connect to existing p2pool node at ADDR listening on&lt;br /&gt;
                        port PORT (defaults to default p2pool P2P port) in&lt;br /&gt;
                        addition to builtin addresses&lt;br /&gt;
&lt;br /&gt;
worker interface:&lt;br /&gt;
  -w PORT, --worker-port PORT&lt;br /&gt;
                        listen on PORT for RPC connections from miners&lt;br /&gt;
                        (default: bitcoin:9332, litecoin:9327, namecoin:9331)&lt;br /&gt;
  -f FEE_PERCENTAGE, --fee FEE_PERCENTAGE&lt;br /&gt;
                        charge workers mining to their own bitcoin address (by&lt;br /&gt;
                        setting their miner&#039;s username to a bitcoin address)&lt;br /&gt;
                        this percentage fee to mine on your p2pool instance.&lt;br /&gt;
                        Amount displayed at http://127.0.0.1:WORKER_PORT/fee&lt;br /&gt;
                        (default: 0)&lt;br /&gt;
&lt;br /&gt;
bitcoind interface:&lt;br /&gt;
  --bitcoind-address BITCOIND_ADDRESS&lt;br /&gt;
                        connect to this address (default: 127.0.0.1)&lt;br /&gt;
  --bitcoind-rpc-port BITCOIND_RPC_PORT&lt;br /&gt;
                        connect to JSON-RPC interface at this port (default:&lt;br /&gt;
                        bitcoin:8332, litecoin:9332, namecoin:8332)&lt;br /&gt;
  --bitcoind-p2p-port BITCOIND_P2P_PORT&lt;br /&gt;
                        connect to P2P interface at this port (default:&lt;br /&gt;
                        bitcoin:8333, litecoin:9333, namecoin:8334)&lt;br /&gt;
  BITCOIND_RPCUSER      bitcoind RPC interface username (default: &amp;lt;empty&amp;gt;)&lt;br /&gt;
  BITCOIND_RPCPASSWORD  bitcoind RPC interface password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Protocol description ==&lt;br /&gt;
&lt;br /&gt;
P2Pool&#039;s protocol mirrors Bitcoin&#039;s P2P protocol in many ways. It uses the same framing (prefix, command, length, checksum, payload) and similar commands:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;version&#039;&#039;&#039; - sent to establish a connection - contains (&#039;&#039;version&#039;&#039;, &#039;&#039;services&#039;&#039;, &#039;&#039;addr_to&#039;&#039;, &#039;&#039;addr_from&#039;&#039;, &#039;&#039;nonce&#039;&#039;, &#039;&#039;sub_version&#039;&#039;, &#039;&#039;mode&#039;&#039;, &#039;&#039;best_share_hash&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;setmode&#039;&#039;&#039; - sent to update the &#039;&#039;mode&#039;&#039; sent in the &#039;&#039;&#039;version&#039;&#039;&#039; message - contains (&#039;&#039;mode&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;ping&#039;&#039;&#039; - sent to keep connection alive - contains ()&lt;br /&gt;
* &#039;&#039;&#039;addrme&#039;&#039;&#039; - request that the receiving node send out an addr for the sending node - contains (&#039;&#039;port&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;addrs&#039;&#039;&#039; - broadcast list of nodes&#039; addresses - contains (&#039;&#039;addrs&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getaddrs&#039;&#039;&#039; - request that the receiving node send &#039;&#039;count&#039;&#039; addrs - contains (&#039;&#039;count&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getshares&#039;&#039;&#039; - request that the receiving node send the shares referenced by &#039;&#039;hashes&#039;&#039; and &#039;&#039;parents&#039;&#039; of their parents, stopping at any share referenced by &#039;&#039;stops&#039;&#039; - contains (&#039;&#039;hashes&#039;&#039;, &#039;&#039;parents&#039;&#039;, &#039;&#039;stops&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;shares&#039;&#039;&#039; - broadcast message of the contents of shares - contains (&#039;&#039;shares&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
This project was announced on June 17, 2011 by Forrest Voight&amp;lt;ref&amp;gt;[https://forum.bitcoin.org/index.php?topic=18313.0 p2pool: Decentralized, DoS-resistant, Hop-Proof - Now active on mainnet!]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The began testing against mainnet in mid-July, 2011.  The pool was reviewed on a [[Bitcoin Miner]] post on July 26, 2011&amp;lt;ref&amp;gt;[http://www.bitcoinminer.com/post/8101660461 P2Pool Decentralized Pool Nearly Ready For Prime-Time]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The software author&#039;s address for donations can be found in the signature section of his [http://forum.bitcoin.org/index.php?action=profile;u=6447 forum profile].&lt;br /&gt;
&lt;br /&gt;
==Donating to P2Pool miners==&lt;br /&gt;
In order to encourage people to mine to P2Pool you can donate to the recent miners in proportion using a sendmany:&lt;br /&gt;
&lt;br /&gt;
E.g. a bash script to donate 10 btc is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~/src/bitcoin/src/bitcoind sendmany &amp;quot;&amp;quot; &amp;quot;$(GET http://forre.st:9332/patron_sendmany?total=10.0)&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can replace &amp;quot;&amp;quot; with &amp;quot;accountname&amp;quot; if you want to pay from some specific bitcoind account, and you can replace forre.st with 127.0.0.1 if you&#039;re running a P2Pool node locally, so you don&#039;t have to trust that the URL gives accurate figures.&lt;br /&gt;
&lt;br /&gt;
If you decide to donate you should announce it on the forums so that your donations provide the most incentive possible.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Comparison of mining pools]]&lt;br /&gt;
* [[Pooled Mining]]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://forum.bitcoin.org/index.php?topic=18313.0 P2Pool forum]&lt;br /&gt;
* [https://github.com/forrestv/p2pool p2pool] project on GitHub&lt;br /&gt;
* {{Freenode IRC|p2pool}} discussion and support&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Pool Operators]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22736</id>
		<title>P2Pool</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=P2Pool&amp;diff=22736"/>
		<updated>2012-01-25T15:13:54Z</updated>

		<summary type="html">&lt;p&gt;Brec: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:P2pool_chain.png‎|thumb|350px|right|Visualization of the P2Pool share chain]]&lt;br /&gt;
P2Pool is a decentralized [[Bitcoin]] [[Bitcoin Pool|mining pool]] that works by creating a peer-to-peer network of miner nodes.&lt;br /&gt;
&lt;br /&gt;
Decentralized payout pooling solves the problem of centralized mining pools degrading the decentralization of Bitcoin, avoids the risk of hard to detect theft by pool operators, and has better fundamental resistance to DoS attacks than centralized pools.&lt;br /&gt;
&lt;br /&gt;
Miners are configured to connect to a P2Pool node that can be run locally, alongside the miner. P2Pool users must run a full Bitcoin node which serves the purpose of independently validating transactions and the Bitcoin blockchain. P2Pool also supports merged mining and several alternative blockchains.&lt;br /&gt;
&lt;br /&gt;
P2Pool nodes work on a chain of shares similar to Bitcoin&#039;s blockchain. Each node works on a block that includes payouts to the previous shares&#039; owners and the node itself, which can also result in a share if it meets P2Pool&#039;s difficulty.&lt;br /&gt;
&lt;br /&gt;
Because of the importance of strengthening Bitcoin&#039;s decentralization some Bitcoin supporters donate to P2Pool miners, resulting in returns above 100% of the expected reward.  &lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
P2Pool shares form a &amp;quot;sharechain&amp;quot; with each share referencing the previous share&#039;s hash. Each share contains a standard Bitcoin block header, some P2Pool-specific data that is used to compute the generation transaction (total subsidy, payout script of this share, a nonce, the previous share&#039;s hash, and the current target for shares), and a Merkle branch linking that generation transaction to the block header&#039;s Merkle hash.&lt;br /&gt;
&lt;br /&gt;
The chain continuously regulates its target to keep generation around one share every ten seconds, just as Bitcoin regulates it to generate one block every ten minutes.&lt;br /&gt;
&lt;br /&gt;
Unlike Bitcoin, nodes do not know the entire chain - instead they only hold the last 8640 shares (the last day&#039;s worth). In order to prevent an attacker from working on a chain in secret and then releasing it, overriding the existing chain, chains are judged by how much work they have since a point in the past. To ascertain that the work has been done since that point, nodes look at the Bitcoin blocks that the shares reference, establishing a provable timestamp. (If a share points to a block, it was definitely made after that block was made.)&lt;br /&gt;
&lt;br /&gt;
=== Payout logic ===&lt;br /&gt;
&lt;br /&gt;
Each share contains a generation transaction that pays to the previous &#039;&#039;n&#039;&#039; shares, where &#039;&#039;n&#039;&#039; is the number of shares whose total work is equal to 3 times the average work required to solve a block, or 8640, whichever is smaller. Payouts are weighted based on the amount of work each share took to solve, which is proportional to the p2pool difficulty at that time.&lt;br /&gt;
&lt;br /&gt;
The block reward (currently 50BTC) and the transaction fees are combined and apportioned according to these rules:&lt;br /&gt;
&lt;br /&gt;
A subsidy of 0.5% is sent to the node that solved the block in order to discourage not sharing solutions that qualify as a block. (A miner with the aim to harm others could withhold the block, thereby preventing anybody from getting paid. He can NOT redirect the payout to himself.) The remaining 99.5% is distributed evenly to miners based on work done recently.&lt;br /&gt;
&lt;br /&gt;
In the event that a share qualifies as a block, this generation transaction is exposed to the Bitcoin network and takes effect, transferring each node its payout.&lt;br /&gt;
&lt;br /&gt;
=== Stales ===&lt;br /&gt;
&lt;br /&gt;
P2Pool stales don&#039;t work the same way as stales on centralized pools. On a centralized pool a stale is work which is too old to be accepted by the pool&#039;s Bitcoin node; this kind of stale is very rare in P2Pool because each user runs their own local bitcoind.&lt;br /&gt;
&lt;br /&gt;
On P2Pool stales refer to shares which can&#039;t make it into the sharechain.  Because the sharechain is 60 times faster than the Bitcoin chain many stales are common and expected. However, because the payout is PPLNS the absolute amount of of stales is irrelevant, only your stale rate relative to other nodes.&lt;br /&gt;
&lt;br /&gt;
There are two reported kinds of stales in P2Pool: &amp;quot;DEAD ON ARRIVAL&amp;quot; shares and orphan shares. Dead shares were too old by the time they arrived at your local P2Pool. Very high dead rates can indicate miner misconfiguration. Orphan shares are shares which were not extended by the rest of the P2Pool network, because some other miner&#039;s share was accepted first. Very high orphan rates may indicate network connectivity problems. &lt;br /&gt;
&lt;br /&gt;
The P2Pool console output shows your relative stale rate compared to other P2Pool miners in the &#039;Own efficiency&#039; column:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
2012-01-07 20:57:51.797420 Pool stales: 13% Own: 13±2% Own efficiency: 100±2%&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you first start P2Pool claimed efficiency will be low and the error bounds on this estimate will be large, but as it runs the numbers will converge to their correct values.&lt;br /&gt;
&lt;br /&gt;
If your efficiency is unusually low, make sure your network connection isn&#039;t overloaded, that your miners support long polling and are not set to work for excessive amounts of time, and that your bitcoind has multiple connections.&lt;br /&gt;
&lt;br /&gt;
== Joining the pool ==&lt;br /&gt;
&lt;br /&gt;
Follow these steps to join the pool:&lt;br /&gt;
&lt;br /&gt;
* Run Bitcoin with the RPC interface enabled: put rpcuser=USER, rpcpassword=PASS, and server=1 in bitcoin.conf&lt;br /&gt;
** Bitcoin 0.5 or later is required&lt;br /&gt;
** It&#039;s important that your Bitcoin client be fully synchronized before starting. It&#039;s also better if you have the Bitcoin port forwarded&lt;br /&gt;
* Download p2pool:&lt;br /&gt;
** Windows binary: See http://forum.bitcoin.org/index.php?topic=18313.0&lt;br /&gt;
** Source download: https://github.com/forrestv/p2pool/tags&lt;br /&gt;
** git: git clone git://github.com/forrestv/p2pool.git&lt;br /&gt;
* Run p2pool: (See below for additional options.)&lt;br /&gt;
** Windows py2exe: run_p2pool.exe USER PASS&lt;br /&gt;
** Source: python run_p2pool.py USER PASS&lt;br /&gt;
* Run a miner daemon with long polling connecting to 127.0.0.1 (or the IP of the host running p2pool if you&#039;re mining remotely) on port 9332 with any username and password&lt;br /&gt;
** cgminer -O u:p -o http://127.0.0.1:9332/&lt;br /&gt;
&lt;br /&gt;
Dependencies if running from source:&lt;br /&gt;
* Python 2.6 or higher&lt;br /&gt;
* python-argparse for Python 2.6 and lower&lt;br /&gt;
* Twisted (Ubuntu package python-twisted)&lt;br /&gt;
&lt;br /&gt;
=== Miners ===&lt;br /&gt;
&lt;br /&gt;
This is all for the latest p2pool version, as it includes several new workarounds. With all miners, using a high FPS target (100?) or a low aggression, and waiting for p2pool to completely start (line shows &amp;gt; 17000 shares) helps a lot with reducing stales.&lt;br /&gt;
&lt;br /&gt;
P2Pool uses higher difficulty shares than most centralized pools, so you&#039;ll see fewer shares reported. This is normal and doesn&#039;t reduce your payments.  It&#039;s also normal to see longpoll messages once per every ten seconds on average.&lt;br /&gt;
&lt;br /&gt;
==== Works as-is ====&lt;br /&gt;
&lt;br /&gt;
===== cgminer =====&lt;br /&gt;
Works very well as is.&lt;br /&gt;
&lt;br /&gt;
===== ufasoft ===== &lt;br /&gt;
Works as is.&lt;br /&gt;
&lt;br /&gt;
===== DiabloMiner =====&lt;br /&gt;
Works fine after commit 3b731b9b54.&lt;br /&gt;
&lt;br /&gt;
==== Needs patch to reduce stales ====&lt;br /&gt;
&lt;br /&gt;
===== Poclbm =====&lt;br /&gt;
Waits a full second between long polls.&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/poclbm&lt;br /&gt;
Pull request: https://github.com/m0mchil/poclbm/pull/41&lt;br /&gt;
&amp;lt;pre&amp;gt;git clone git://github.com/forrestv/poclbm.git&lt;br /&gt;
cd poclbm&lt;br /&gt;
git checkout fast_long_polling&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/wodukkea/p2pool-poclbm_win32_5590e7c.zip&lt;br /&gt;
&lt;br /&gt;
===== Phoenix =====&lt;br /&gt;
(Works fine after commit 8263f65!)&lt;br /&gt;
&lt;br /&gt;
Has a similar bug (waiting a full second).&lt;br /&gt;
&lt;br /&gt;
GitHub fork: https://github.com/forrestv/phoenix-miner&lt;br /&gt;
&lt;br /&gt;
Windows binary: http://u.forre.st/u/ycvzejfm/phoenix-miner-fba48d2-5.zip&lt;br /&gt;
&lt;br /&gt;
==== Not-compatible ====&lt;br /&gt;
&lt;br /&gt;
===== puddinpop&#039;s RPC Miners =====&lt;br /&gt;
Does not have long polling so will not work at all.&lt;br /&gt;
&lt;br /&gt;
=== Option Reference ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage: run_p2pool.py [-h] [--version] [--net {bitcoin, litecoin, namecoin}]&lt;br /&gt;
                     [--testnet] [--debug] [-a ADDRESS] [--logfile LOGFILE]&lt;br /&gt;
                     [--merged-url MERGED_URL]&lt;br /&gt;
                     [--merged-userpass MERGED_USERPASS]&lt;br /&gt;
                     [--give-author DONATION_PERCENTAGE] [--p2pool-port PORT]&lt;br /&gt;
                     [-n ADDR[:PORT]] [--disable-upnp] [-w PORT]&lt;br /&gt;
                     [-f FEE_PERCENTAGE] [--bitcoind-address BITCOIND_ADDRESS]&lt;br /&gt;
                     [--bitcoind-rpc-port BITCOIND_RPC_PORT]&lt;br /&gt;
                     [--bitcoind-p2p-port BITCOIND_P2P_PORT]&lt;br /&gt;
                     [BITCOIND_RPCUSER] BITCOIND_RPCPASSWORD&lt;br /&gt;
&lt;br /&gt;
p2pool (version 31cbeea)&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  --version             show program&#039;s version number and exit&lt;br /&gt;
  --net {bitcoin, litecoin, namecoin}&lt;br /&gt;
                        use specified network (default: bitcoin)&lt;br /&gt;
  --testnet             use the network&#039;s testnet&lt;br /&gt;
  --debug               enable debugging mode&lt;br /&gt;
  -a ADDRESS, --address ADDRESS&lt;br /&gt;
                        generate payouts to this address (default: &amp;lt;address&lt;br /&gt;
                        requested from bitcoind&amp;gt;)&lt;br /&gt;
  --logfile LOGFILE     log to this file (default: data/&amp;lt;NET&amp;gt;/log)&lt;br /&gt;
  --merged-url MERGED_URL&lt;br /&gt;
                        call getauxblock on this url to get work for merged&lt;br /&gt;
                        mining (example: http://127.0.0.1:10332/)&lt;br /&gt;
  --merged-userpass MERGED_USERPASS&lt;br /&gt;
                        use this user and password when requesting merged&lt;br /&gt;
                        mining work (example: ncuser:ncpass)&lt;br /&gt;
  --give-author DONATION_PERCENTAGE&lt;br /&gt;
                        donate this percentage of work to author of p2pool&lt;br /&gt;
                        (default: 0.5)&lt;br /&gt;
  --disable-upnp        don&#039;t attempt to use UPnP to forward p2pool&#039;s P2P port&lt;br /&gt;
                        from the Internet to this computer&lt;br /&gt;
&lt;br /&gt;
p2pool interface:&lt;br /&gt;
  --p2pool-port PORT    use port PORT to listen for connections (forward this&lt;br /&gt;
                        port from your router!) (default: bitcoin:9333,&lt;br /&gt;
                        litecoin:9338, namecoin:9334)&lt;br /&gt;
  -n ADDR[:PORT], --p2pool-node ADDR[:PORT]&lt;br /&gt;
                        connect to existing p2pool node at ADDR listening on&lt;br /&gt;
                        port PORT (defaults to default p2pool P2P port) in&lt;br /&gt;
                        addition to builtin addresses&lt;br /&gt;
&lt;br /&gt;
worker interface:&lt;br /&gt;
  -w PORT, --worker-port PORT&lt;br /&gt;
                        listen on PORT for RPC connections from miners&lt;br /&gt;
                        (default: bitcoin:9332, litecoin:9327, namecoin:9331)&lt;br /&gt;
  -f FEE_PERCENTAGE, --fee FEE_PERCENTAGE&lt;br /&gt;
                        charge workers mining to their own bitcoin address (by&lt;br /&gt;
                        setting their miner&#039;s username to a bitcoin address)&lt;br /&gt;
                        this percentage fee to mine on your p2pool instance.&lt;br /&gt;
                        Amount displayed at http://127.0.0.1:WORKER_PORT/fee&lt;br /&gt;
                        (default: 0)&lt;br /&gt;
&lt;br /&gt;
bitcoind interface:&lt;br /&gt;
  --bitcoind-address BITCOIND_ADDRESS&lt;br /&gt;
                        connect to this address (default: 127.0.0.1)&lt;br /&gt;
  --bitcoind-rpc-port BITCOIND_RPC_PORT&lt;br /&gt;
                        connect to JSON-RPC interface at this port (default:&lt;br /&gt;
                        bitcoin:8332, litecoin:9332, namecoin:8332)&lt;br /&gt;
  --bitcoind-p2p-port BITCOIND_P2P_PORT&lt;br /&gt;
                        connect to P2P interface at this port (default:&lt;br /&gt;
                        bitcoin:8333, litecoin:9333, namecoin:8334)&lt;br /&gt;
  BITCOIND_RPCUSER      bitcoind RPC interface username (default: &amp;lt;empty&amp;gt;)&lt;br /&gt;
  BITCOIND_RPCPASSWORD  bitcoind RPC interface password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Protocol description ==&lt;br /&gt;
&lt;br /&gt;
P2Pool&#039;s protocol mirrors Bitcoin&#039;s P2P protocol in many ways. It uses the same framing (prefix, command, length, checksum, payload) and similar commands:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;version&#039;&#039;&#039; - sent to establish a connection - contains (&#039;&#039;version&#039;&#039;, &#039;&#039;services&#039;&#039;, &#039;&#039;addr_to&#039;&#039;, &#039;&#039;addr_from&#039;&#039;, &#039;&#039;nonce&#039;&#039;, &#039;&#039;sub_version&#039;&#039;, &#039;&#039;mode&#039;&#039;, &#039;&#039;best_share_hash&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;setmode&#039;&#039;&#039; - sent to update the &#039;&#039;mode&#039;&#039; sent in the &#039;&#039;&#039;version&#039;&#039;&#039; message - contains (&#039;&#039;mode&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;ping&#039;&#039;&#039; - sent to keep connection alive - contains ()&lt;br /&gt;
* &#039;&#039;&#039;addrme&#039;&#039;&#039; - request that the receiving node send out an addr for the sending node - contains (&#039;&#039;port&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;addrs&#039;&#039;&#039; - broadcast list of nodes&#039; addresses - contains (&#039;&#039;addrs&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getaddrs&#039;&#039;&#039; - request that the receiving node send &#039;&#039;count&#039;&#039; addrs - contains (&#039;&#039;count&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;getshares&#039;&#039;&#039; - request that the receiving node send the shares referenced by &#039;&#039;hashes&#039;&#039; and &#039;&#039;parents&#039;&#039; of their parents, stopping at any share referenced by &#039;&#039;stops&#039;&#039; - contains (&#039;&#039;hashes&#039;&#039;, &#039;&#039;parents&#039;&#039;, &#039;&#039;stops&#039;&#039;)&lt;br /&gt;
* &#039;&#039;&#039;shares&#039;&#039;&#039; - broadcast message of the contents of shares - contains (&#039;&#039;shares&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
&lt;br /&gt;
This project was announced on June 17, 2011 by Forrest Voight&amp;lt;ref&amp;gt;[https://forum.bitcoin.org/index.php?topic=18313.0 p2pool: Decentralized, DoS-resistant, Hop-Proof - Now active on mainnet!]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The began testing against mainnet in mid-July, 2011.  The pool was reviewed on a [[Bitcoin Miner]] post on July 26, 2011&amp;lt;ref&amp;gt;[http://www.bitcoinminer.com/post/8101660461 P2Pool Decentralized Pool Nearly Ready For Prime-Time]&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The software author&#039;s address for donations can be found in the signature section of his [http://forum.bitcoin.org/index.php?action=profile;u=6447 forum profile].&lt;br /&gt;
&lt;br /&gt;
==Donating to P2Pool miners==&lt;br /&gt;
In order to encourage people to mine to P2Pool you can donate to the recent miners in proportion using a sendmany:&lt;br /&gt;
&lt;br /&gt;
E.g. a bash script to donate 10 btc is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
~/src/bitcoin/src/bitcoind sendmany &amp;quot;&amp;quot; &amp;quot;$(GET http://forre.st:9332/patron_sendmany?total=10.0)&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can replace &amp;quot;&amp;quot; with &amp;quot;accountname&amp;quot; if you want to pay from some specific bitcoind account, and you can replace forre.st with 127.0.0.1 if you&#039;re running a P2Pool node locally, so you don&#039;t have to trust that the URL gives accurate figures.&lt;br /&gt;
&lt;br /&gt;
If you decide to donate you should announce it on the forums so that your donations provide the most incentive possible.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Comparison of mining pools]]&lt;br /&gt;
* [[Pooled Mining]]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
* [http://forum.bitcoin.org/index.php?topic=18313.0 P2Pool forum]&lt;br /&gt;
* [https://github.com/forrestv/p2pool p2pool] project on GitHub&lt;br /&gt;
* {{Freenode IRC|p2pool}} discussion and support&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Pool Operators]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Miner_fees&amp;diff=21204</id>
		<title>Miner fees</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Miner_fees&amp;diff=21204"/>
		<updated>2011-12-24T03:45:29Z</updated>

		<summary type="html">&lt;p&gt;Brec: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:fee.png|thumb|Receiving a transaction fee of 0.44 BC]]&lt;br /&gt;
Transaction fees may be included with any transfer of bitcoins from one address to another.  At the moment, many [[transactions]] are typically processed in a way where no fee is expected at all, but for transactions which draw coins from many bitcoin addresses and therefore have a large data size, a small transaction fee is usually expected.&lt;br /&gt;
&lt;br /&gt;
The transaction fee is processed by and received by the bitcoin miner.  When a new bitcoin block is generated with a successful hash, the information for all of the transactions is included with the block and all transaction fees are collected by that user creating the block, who is free to assign those fees to himself.&lt;br /&gt;
&lt;br /&gt;
Transaction fees are voluntary on the part of the person making the bitcoin transaction, as the person attempting to make a transaction can include any fee or none at all in the transaction. On the other hand, nobody mining new bitcoins necessarily needs to accept the transactions and include them in the new block being created.  The transaction fee is therefore an incentive on the part of the bitcoin user to make sure that a particular transaction will get included into the next block which is generated.&lt;br /&gt;
&lt;br /&gt;
It is envisioned that over time the cumulative effect of collecting transaction fees will allow somebody creating new blocks to &amp;quot;earn&amp;quot; more bitcoins than will be mined from new bitcoins created by the new block itself.  This is also an incentive to keep trying to create new blocks even if the value of the newly created block from the mining activity is zero in the far future.&lt;br /&gt;
&lt;br /&gt;
It works like this:&lt;br /&gt;
* Whoever sends the transaction is often able to guess an appropriate fee based on their own fee rules.  The [[Original Bitcoin client|original client]] will always assess the transaction, and if a fee will typically be expected, it will not allow you to send the transaction without the calculated fee.&lt;br /&gt;
* The user is prompted to confirm the fee before the transaction is sent.&lt;br /&gt;
* The sender makes a transaction with more coins in the &#039;&#039;In&#039;&#039; portion than the &#039;&#039;Out&#039;&#039; portion so that there are “leftovers” not assigned to any address.&lt;br /&gt;
* Whoever ends up publishing the [[block]] which contains this transaction will take these (and any other) leftover coins. They are included with their normal generated coins and is an extra bonus for creating the block.&lt;br /&gt;
* If a mining node receives a transaction that should include a transaction fee but doesn&#039;t, they may refuse to include it in their blocks. It might be included in a later block if someone is willing to accept it. Generators can&#039;t force a certain fee on transactions -- they can only accept or reject the transaction&#039;s “fee offer”.&lt;br /&gt;
[[File:lfm_fee.png|thumb|This balance is made entirely of 0.01 BTC cents. Since sending them requires a lot of data, a very large fee is required.]]&lt;br /&gt;
&lt;br /&gt;
Different bitcoin clients and different versions have different rules for determining which transactions to accept and how large a fee to send.&lt;br /&gt;
&lt;br /&gt;
Current default rules for the original Bitcoin client (Bitcoin 0.3.23):&lt;br /&gt;
* minimum TX fee for new transactions reduced to 0.0005 BTC.&lt;br /&gt;
&lt;br /&gt;
Original Bitcoin client version 0.3.20:&lt;br /&gt;
* 0.01 BTC fee if sending any transaction less than 0.01 BTC. This is to help prevent DoS attacks against the network. Remember: fees are not network-enforced, so it&#039;s still &#039;&#039;possible&#039;&#039; to send these small transactions without the fee -- you just have to generate the blocks that contain them yourself (after modifying Bitcoin).&lt;br /&gt;
* 0.01 BTC fee per kilobyte of transaction, but:&lt;br /&gt;
** If the blocksize (size of all transactions currently waiting to be included in a block) is less than 27 kB, transactions are free.&lt;br /&gt;
** If the blocksize is more than 250 kB, transactions get increasingly more expensive as the blocksize approaches the limit of 500 kB. Sending a transaction when the blocksize is 400 kB will cost 5 times the normal amount; sending when it&#039;s 499 kB will cost 500x, etc.&lt;br /&gt;
* Transactions within each fee tier are prioritized based on several factors. Most importantly, a transaction has more priority if the coins it is using have a lot of confirmations. Someone spamming the network will almost certainly be re-using the same coins, which will lower the priority of their transactions. Priority is also increased for transactions with more BTC, and reduced for transactions with more data.&lt;br /&gt;
* If the blocksize is over 4kB, free transactions in the above rules are only allowed if the transaction&#039;s priority is above a certain level.&lt;br /&gt;
&lt;br /&gt;
Note that if you want to send a transaction with less than the default rules, or if you are a miner and want to include them in your blocks, you may need to peer with the [[Free transaction relay policy|Free transaction relay network]].&lt;br /&gt;
&lt;br /&gt;
An advantage for bitcoin users to include a transaction fee is that the likelihood of getting a transaction included into the next block is going to be higher than if a transaction fee is not included.  This is a trade off of time vs. money put forward on the transaction fees, as you can be patient with a low or non-existent fee included in a transaction, or you can make sure that the transaction is processed immediately by including a higher fee than is typical.&lt;br /&gt;
&lt;br /&gt;
The rules are far from set in stone, and the network can support many different rules simultaneously. If there are mining nodes that never require a transaction fee and your client is modified to never send any transaction fee, then your transactions will eventually be picked up by one of those free nodes when they generate a block, though it will probably take a very long time. In the far future, different rules about transaction fees among mining nodes will probably create a clear choice between fees and transaction speed. For example, you might choose to spend 2% for a guaranteed spot in the next block or 0.01% for the transaction to be sent in a few hours.&lt;br /&gt;
&lt;br /&gt;
If you notice that your sent transactions take a very long time to confirm, this is possibly because no fee was included. Using a more recent release of the client will help lessen the chance of sending a transaction without an adequate fee.&lt;br /&gt;
[[File:feesend.png|thumb|Sending a transaction when the sender doesn&#039;t have enough money to actually pay the fee]]&lt;br /&gt;
&lt;br /&gt;
==Technical info==&lt;br /&gt;
&lt;br /&gt;
Transaction priority is calculated as a value-weighted sum of input age, divided by transaction size in bytes:&lt;br /&gt;
 priority = sum(input_value_in_base_units * input_age)/size_in_bytes&lt;br /&gt;
Transactions need to have a priority above 57,600,000 to avoid the enforced limit (as of client version 0.3.21).  This threshold is written in the code as COIN * 144 / 250, suggesting that the threshold represents a one day old, 1 btc coin (144 is the expected number of blocks per day) and a transaction size of 250 bytes.&lt;br /&gt;
&lt;br /&gt;
So, for example, a transaction that has 2 inputs, one of 5 btc with 10 confirmations, and one of 2 btc with 3 confirmations, and has a size of 500bytes, will have a priority of&lt;br /&gt;
 (500000000 * 10 + 200000000 * 3) / 500 = 11,800,000&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Free transaction relay policy]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;br /&gt;
[[Category:Mining]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Pooled_mining&amp;diff=21193</id>
		<title>Pooled mining</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Pooled_mining&amp;diff=21193"/>
		<updated>2011-12-23T20:08:49Z</updated>

		<summary type="html">&lt;p&gt;Brec: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Pooled mining&#039;&#039;&#039; is a [[Mining|mining]] approach where multiple generating clients contribute to the generation of a block, and then split the block reward according the contributed processing power. Pooled mining effectively reduces the granularity of the block generation reward, spreading it out more smoothly over time.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
With increasing generation difficulty, mining with lower-performance devices can take a very long time before block generation, on average. For example, with a mining speed of 1000 Khps, at a difficulty of 14484 (which was in effect at the end of December, 2010), the average time to generate a block is almost 2 years. &lt;br /&gt;
&lt;br /&gt;
To provide a more smooth incentive to lower-performance miners, several pooled miners, using different approaches, have been created. With a mining pool, a lot of different people contribute to generating a block, and the reward is then split among them according to their processing contribution. This way, instead of waiting for years to generate 50btc in a block, a smaller miner may get a fraction of a bitcoin on a more regular basis.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;share&#039;&#039;&#039; is awarded by the mining pool to the clients who present a valid [[proof of work]] of the same type as the proof of work that is used for creating [[block|blocks]], but of lesser difficulty, so that it requires less time on average to generate.&lt;br /&gt;
&lt;br /&gt;
==Pooled mining approaches==&lt;br /&gt;
&lt;br /&gt;
The problem with pooled mining is that steps must be taken to prevent cheating by the clients and the server. Currently there are several different approaches used.&lt;br /&gt;
&lt;br /&gt;
===The slush approach===&lt;br /&gt;
&lt;br /&gt;
[[Bitcoin Pooled Mining]] (BPM), sometimes referred to as &amp;quot;slush&#039;s pool&amp;quot;, follows a score-based method.  Older shares (from beginning of the round) have lower weight than more recent shares, which reduces the motivation to cheat by switching between pools within a round.&lt;br /&gt;
&lt;br /&gt;
===The puddinpop approach===&lt;br /&gt;
&lt;br /&gt;
(As of February, 2011, there are no puddinpop pools running.)&lt;br /&gt;
&lt;br /&gt;
Another approach is the &#039;metahash&#039; technique, used by puddinpop&#039;s [[remote miner]]. Clients generate hashes, and also submit &#039;metahashes&#039;, which are hashes of a large chunk of generated hashes. The server checks that the metahashes are correct (in a round-robin fashion, picking up a metahash from a client that hasn&#039;t been checked on the longest), thus preventing clients from simply claiming that they have done work without actually doing it. The withholding of good blocks by the clients is prevented by the server&#039;s possession of the private key, just as in the previous approach. Rewards are distributed based on the number of metahashes submitted by the clients.&lt;br /&gt;
&lt;br /&gt;
The generated blocks contain multiple keys in the generation transaction, giving fractional bitcoin amounts to each key in proportion to their hashing contribution for that block.&lt;br /&gt;
&lt;br /&gt;
===The Pay-per-Share approach===&lt;br /&gt;
&lt;br /&gt;
The Pay-per-Share (PPS) approach, first described by [[BitPenny]], is to offer an instant flat payout for each share that is solved.  The payout is offered from the pool&#039;s existing balance and can therefore be withdrawn immediately, without waiting for a block to be solved or confirmed.  The possibility of cheating the miners by the pool operator and by timing attacks is thus completely eliminated. &lt;br /&gt;
&lt;br /&gt;
This method results in the least possible variance for miners while transferring all risk to the pool operator.  The resulting possibility of loss for the server is offset by setting a payout lower than the full expected value.&lt;br /&gt;
&lt;br /&gt;
===Luke-Jr&#039;s approach (&amp;quot;[[Eligius]]&amp;quot;)===&lt;br /&gt;
[[User:Luke-Jr|Luke]] came up with a third approach borrowing strengths from the earlier two.&lt;br /&gt;
Like slush&#039;s approach, miners submit proofs-of-work to earn shares.&lt;br /&gt;
Like puddinpop&#039;s approach, the pool pays out immediately via block generation.&lt;br /&gt;
When distributing block rewards, it is divided equally among all shares since the last valid block.&lt;br /&gt;
Unlike any preexisting pool approach, this means that the shares contributed toward orphaned blocks are recycled into the next block&#039;s shares.&lt;br /&gt;
In order to spare participating miners from transaction fees, rewards are only paid out if a miner has earned at least 1 BTC. If the amount owed is less, it will be added to the earnings of a later block (which may then total over 1 BTC).&lt;br /&gt;
If a miner does not submit a share for over a week, the pool sends any balance remaining, regardless of its size.&lt;br /&gt;
&lt;br /&gt;
===The Triplemining approach===&lt;br /&gt;
The [[Triplemining]] approach is to bring together a medium-sized pool with no fees and clever redistribution of 1% of every found block to allow your share to grow more rapidly than on any other bitcoin mining pool. &lt;br /&gt;
&lt;br /&gt;
For every found block, Triplemining redistributes 1% of the profits to all minipool owners (people with 1 or more friends mining with them). The redistribution is connected to the shares found by the members of the minipool. So if the hash rate of the minipool members equals or is bigger than yours, the part in the redistribution will be equally bigger.&lt;br /&gt;
&lt;br /&gt;
===P2Pool approach===&lt;br /&gt;
&lt;br /&gt;
[[P2Pool]] mining nodes work on a chain of shares similar to Bitcoin’s blockchain.  There is no central point of failure and thus P2Pool becomes DoS resistant.&lt;br /&gt;
&lt;br /&gt;
P2Pool works different from existing mining pool technologies — each node works on a block that includes payouts to the previous shares’ owners and the node itself.  99% of the block reward (the 50BTC reward plus any included transaction fees) is distributed evenly to miners based on work done recently.  An additional 0.5% is awarded to the node which solves the block.&lt;br /&gt;
&lt;br /&gt;
===Comparison===&lt;br /&gt;
&lt;br /&gt;
The cooperative mining approach (slush and Luke-Jr) uses a lot less resources on the pool server, since rather than continuously checking metahashes, all that has to be checked is the validity of submitted shares. The number of shares sent can be adjusted by adjusting the artificial difficulty level.&lt;br /&gt;
&lt;br /&gt;
Further, the cooperative mining approach allows the clients to use existing miners without any modification, while the puddinpop approach requires the custom pool miner, which are as of now not as efficient on GPU mining as the existing GPU miners.&lt;br /&gt;
[[File:Smallgeneration.png|thumb|Puddinpop miners receive coins directly.]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the puddinpop and Luke-Jr approaches of distributing the earnings by way of including precise sub-cent amounts in the generation transaction for the participants, results in the presence of sub-cent bitcoin amounts in your wallet, which are liable to disappear (as unnecessary fees) later due to a bug in old (before 0.3.21) bitcoin nodes. (E.g., if you have a transaction with 0.052 in your wallet, and you later send .05 to someone, your .002 will disappear.).&lt;br /&gt;
&lt;br /&gt;
Puddinpop and Luke-Jr miners receive coins directly, which eliminates the delay in receiving earnings that is required on slush-based mining servers. However, using some [[eWallet]] services like MyBitcoin for generated coin will cause those coins to be lost.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Miners|Miners]]&lt;br /&gt;
* [[Comparison of mining pools]]&lt;br /&gt;
* [[:Category:Pool Operators|Pool Operators]]&lt;br /&gt;
* [[Why a GPU mines faster than a CPU]]&lt;br /&gt;
* [[Why pooled mining]]&lt;br /&gt;
* [[Mining pool reward FAQ]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [http://btcserv.net BTCSERV.net - Bitcoin Pool]&lt;br /&gt;
* [http://21bitcoin.com/pool/ 21bitcoin mining pool, Chinese Interface]&lt;br /&gt;
* [http://mining.bitcoin.cz slush&#039;s mining pool]&lt;br /&gt;
* [http://www.bitcash.cz bitcash.cz - czech mining pool]&lt;br /&gt;
* [http://www.bitcoin.org/smf/index.php?topic=1458.0 puddinpop&#039;s mining pool thread]&lt;br /&gt;
* [http://blockexplorer.com/block/00000000000233334b157d901714baf59e5b9236227b2878844e52244da4195e example puddinpop block]&lt;br /&gt;
* [http://bitclockers.com bitclockers mining pool]&lt;br /&gt;
* [http://forum.bitcoin.org/index.php?topic=18313 P2Pool forum]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mining]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Pooled_mining&amp;diff=21192</id>
		<title>Pooled mining</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Pooled_mining&amp;diff=21192"/>
		<updated>2011-12-23T20:04:21Z</updated>

		<summary type="html">&lt;p&gt;Brec: a share proof-of-work is not of less *complexity*, but less *difficulty* (less expected computation) as compared with block generation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Pooled mining&#039;&#039;&#039; is a [[Mining|mining]] approach where multiple generating clients contribute to the generation of a block, and then split the block reward according the contributed processing power. Pooled mining effectively reduces the granularity of the block generation reward, spreading it out more smoothly over time.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
With increasing generation difficulty, mining with lower-performance devices can take a very long time before block generation, on average. For example, with a mining speed of 1000 Khps, at a difficulty of 14484 (which was in effect at the end of December, 2010), the average time to generate a block is almost 2 years. &lt;br /&gt;
&lt;br /&gt;
To provide a more smooth incentive to lower-performance miners, several pooled miners, using different approaches, have been created. With a mining pool, a lot of different people contribute to generating a block, and the reward is then split among them according to their processing contribution. This way, instead of waiting for years to generate 50btc in a block, a smaller miner may get a fraction of a bitcoin on a more regular basis.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;share&#039;&#039;&#039; is awarded by the mining pool to the clients who present a valid [[proof of work]] of the same type as the proof of work that is used for creating [[block|blocks]], but of lesser difficulty, so that it requires less time on average to generate.&lt;br /&gt;
&lt;br /&gt;
==Pooled mining approaches==&lt;br /&gt;
&lt;br /&gt;
The problem with pooled mining is that steps must be taken to prevent cheating by the clients and the server. Currently there are several different approaches used.&lt;br /&gt;
&lt;br /&gt;
===The slush approach===&lt;br /&gt;
&lt;br /&gt;
[[Bitcoin Pooled Mining]] (BPM), sometimes referred to as &amp;quot;slush&#039;s pool&amp;quot;, follows a score-based method.  Older shares (from beginning of the round) has lower weight than newer shares, which demotivate cheater from switching between pools inside one round.&lt;br /&gt;
&lt;br /&gt;
===The puddinpop approach===&lt;br /&gt;
&lt;br /&gt;
(As of February, 2011, there are no puddinpop pools running.)&lt;br /&gt;
&lt;br /&gt;
Another approach is the &#039;metahash&#039; technique, used by puddinpop&#039;s [[remote miner]]. Clients generate hashes, and also submit &#039;metahashes&#039;, which are hashes of a large chunk of generated hashes. The server checks that the metahashes are correct (in a round-robin fashion, picking up a metahash from a client that hasn&#039;t been checked on the longest), thus preventing clients from simply claiming that they have done work without actually doing the work. The withholding of good blocks by the clients is prevented via the server being in possession of the private key, just as in the previous approach. Rewards are distributed based on the number of metahashes submitted by the clients.&lt;br /&gt;
&lt;br /&gt;
The generated blocks contain multiple keys in the generation transaction, giving fractional bitcoin amounts to each key, in proportion to their hashing contribution for that block.&lt;br /&gt;
&lt;br /&gt;
===The Pay-per-Share approach===&lt;br /&gt;
&lt;br /&gt;
The Pay-per-Share (PPS) approach, first described by [[BitPenny]], is to offer an instant flat payout for each share that is solved.  The payout is offered from the pool&#039;s existing balance and can therefore be withdrawn immediately, without waiting for a block to be solved or confirmed.  The possibility of cheating the miners by the pool operator and by timing attacks is thus completely eliminated. &lt;br /&gt;
&lt;br /&gt;
This method results in the least possible variance for miners while transferring all risk to the pool operator.  The resulting possibility of loss for the server is offset by setting the payout lower than the full expected value.&lt;br /&gt;
&lt;br /&gt;
===Luke-Jr&#039;s approach (&amp;quot;[[Eligius]]&amp;quot;)===&lt;br /&gt;
[[User:Luke-Jr|Luke]] came up with a third approach borrowing strengths from the earlier two.&lt;br /&gt;
Like slush&#039;s approach, miners submit proofs-of-work to earn shares.&lt;br /&gt;
Like puddinpop&#039;s approach, the pool pays out immediately via block generation.&lt;br /&gt;
When distributing block rewards, it is divided equally among all shares since the last valid block.&lt;br /&gt;
Unlike any preexisting pool approach, this means that the shares contributed toward orphaned blocks are recycled into the next block&#039;s shares.&lt;br /&gt;
In order to spare participating miners from transaction fees, rewards are only paid out if a miner has earned at least 1 BTC. If the amount owed is less, it will be added to the earnings of a later block (which may then total over 1 BTC).&lt;br /&gt;
If a miner does not submit a share for over a week, the pool sends any balance remaining, regardless of its size.&lt;br /&gt;
&lt;br /&gt;
===The Triplemining approach===&lt;br /&gt;
The [[Triplemining]] approach is to bring together a medium-sized pool with no fees and clever redistribution of 1% of every found block to allow your share to grow more rapidly than on any other bitcoin mining pool. &lt;br /&gt;
&lt;br /&gt;
For every found block, Triplemining redistributes 1% of the profits to all minipool owners (people with 1 or more friends mining with them). The redistribution is connected to the shares found by the members of the minipool. So if the hash rate of the minipool members equals or is bigger than yours, the part in the redistribution will be equally bigger.&lt;br /&gt;
&lt;br /&gt;
===P2Pool approach===&lt;br /&gt;
&lt;br /&gt;
[[P2Pool]] mining nodes work on a chain of shares similar to Bitcoin’s blockchain.  There is no central point of failure and thus P2Pool becomes DoS resistant.&lt;br /&gt;
&lt;br /&gt;
P2Pool works different from existing mining pool technologies — each node works on a block that includes payouts to the previous shares’ owners and the node itself.  99% of the block reward (the 50BTC reward plus any included transaction fees) is distributed evenly to miners based on work done recently.  An additional 0.5% is awarded to the node which solves the block.&lt;br /&gt;
&lt;br /&gt;
===Comparison===&lt;br /&gt;
&lt;br /&gt;
The cooperative mining approach (slush and Luke-Jr) uses a lot less resources on the pool server, since rather than continuously checking metahashes, all that has to be checked is the validity of submitted shares. The number of shares sent can be adjusted by adjusting the artificial difficulty level.&lt;br /&gt;
&lt;br /&gt;
Further, the cooperative mining approach allows the clients to use existing miners without any modification, while the puddinpop approach requires the custom pool miner, which are as of now not as efficient on GPU mining as the existing GPU miners.&lt;br /&gt;
[[File:Smallgeneration.png|thumb|Puddinpop miners receive coins directly.]]&lt;br /&gt;
&lt;br /&gt;
Additionally, the puddinpop and Luke-Jr approaches of distributing the earnings by way of including precise sub-cent amounts in the generation transaction for the participants, results in the presence of sub-cent bitcoin amounts in your wallet, which are liable to disappear (as unnecessary fees) later due to a bug in old (before 0.3.21) bitcoin nodes. (E.g., if you have a transaction with 0.052 in your wallet, and you later send .05 to someone, your .002 will disappear.).&lt;br /&gt;
&lt;br /&gt;
Puddinpop and Luke-Jr miners receive coins directly, which eliminates the delay in receiving earnings that is required on slush-based mining servers. However, using some [[eWallet]] services like MyBitcoin for generated coin will cause those coins to be lost.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Miners|Miners]]&lt;br /&gt;
* [[Comparison of mining pools]]&lt;br /&gt;
* [[:Category:Pool Operators|Pool Operators]]&lt;br /&gt;
* [[Why a GPU mines faster than a CPU]]&lt;br /&gt;
* [[Why pooled mining]]&lt;br /&gt;
* [[Mining pool reward FAQ]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [http://btcserv.net BTCSERV.net - Bitcoin Pool]&lt;br /&gt;
* [http://21bitcoin.com/pool/ 21bitcoin mining pool, Chinese Interface]&lt;br /&gt;
* [http://mining.bitcoin.cz slush&#039;s mining pool]&lt;br /&gt;
* [http://www.bitcash.cz bitcash.cz - czech mining pool]&lt;br /&gt;
* [http://www.bitcoin.org/smf/index.php?topic=1458.0 puddinpop&#039;s mining pool thread]&lt;br /&gt;
* [http://blockexplorer.com/block/00000000000233334b157d901714baf59e5b9236227b2878844e52244da4195e example puddinpop block]&lt;br /&gt;
* [http://bitclockers.com bitclockers mining pool]&lt;br /&gt;
* [http://forum.bitcoin.org/index.php?topic=18313 P2Pool forum]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mining]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Satoshi_Client_Initialization_and_Startup&amp;diff=20712</id>
		<title>Satoshi Client Initialization and Startup</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Satoshi_Client_Initialization_and_Startup&amp;diff=20712"/>
		<updated>2011-12-12T04:16:28Z</updated>

		<summary type="html">&lt;p&gt;Brec: fix typo: already in user -&amp;gt; already in use&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Startup Process==&lt;br /&gt;
&lt;br /&gt;
The client uses a fixed number of threads that are created on startup. All of the reading and writing on active network sockets are handled by one thread.&lt;br /&gt;
&lt;br /&gt;
The main() entry point to the program is in init.cpp. Do not go looking in main.cpp for main() - you will not find it.&lt;br /&gt;
&lt;br /&gt;
The first thing main() does is call AppInit, which calls AppInit2 which performs a bunch of initialization busy work mostly related to how the application handles errors. At some point AppInit2 calls ParseParameters, and then some argument handling code processes some basic arguments.&lt;br /&gt;
&lt;br /&gt;
Now it checks to see if an existing GUI window is already present and if so, brings it to the foreground.&lt;br /&gt;
&lt;br /&gt;
Next it creates a lock file in the bitcoin directory and if bitcoin is already running, displays a message and exits.&lt;br /&gt;
&lt;br /&gt;
Next it attemps to listen on the bitcoin port, and if the port is already in use or other error, displays a message and exits.&lt;br /&gt;
&lt;br /&gt;
Next it loads IP addresses from a database, then it loads the block index, and then it loads the wallet.&lt;br /&gt;
&lt;br /&gt;
Next it gets the top block number from the wallet, or zero if -rescan is used. Then It scans the block chain from the block number above.&lt;br /&gt;
&lt;br /&gt;
Side Note:  printf has been redefined in util.h. So printf is really OutputDebugStringF which directs to a file if appropriate (see util.h and util.cpp). Also &amp;quot;loop&amp;quot; is defined in util.h as for (  ; ;  ).&lt;br /&gt;
&lt;br /&gt;
Then it does a bit more initialization and parameter processing and then it finally opens the GUI main window.&lt;br /&gt;
&lt;br /&gt;
Next it creates two threads:&lt;br /&gt;
&lt;br /&gt;
# StartNode()&lt;br /&gt;
# And if acting as server: ThreadRPCServer()&lt;br /&gt;
&lt;br /&gt;
This is the only place where these threads are created.&lt;br /&gt;
&lt;br /&gt;
StartNode() is in net.cpp and ThreadRPCServer() is in rpc.cpp.&lt;br /&gt;
&lt;br /&gt;
Last, if not compiled for the GUI it sleeps for 5 seonds in an infinite loop.&lt;br /&gt;
&lt;br /&gt;
== fClient Mode ==&lt;br /&gt;
&lt;br /&gt;
It is worth noting that there is code in the client to allow it to operate in a mode where it only downloads block headers. The implementation is intended to be used as a lightweight client mode which can operate without verifying and storing all blocks and transactions. This is controlled by the fClient variable in the code which is currently hard coded to false.  This is currently not considered to be finished code. This mode is known as fClient mode and the phrase Simplified Payment Verification (or SPV) mode has also been used to describe a lightweight client approach.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread StartNode() in net.cpp==&lt;br /&gt;
&lt;br /&gt;
StartNode is sort of a master networking thread.&lt;br /&gt;
&lt;br /&gt;
First it creates a CNode for the localhost 127.0.0.1 internal addresss to&lt;br /&gt;
handle communication.&lt;br /&gt;
&lt;br /&gt;
Next, it gets the local IP address. On windows, its a lookup using the&lt;br /&gt;
local host name. On Linux, it is the first IP address it finds on an&lt;br /&gt;
interface that is up and is not the loopback interface.&lt;br /&gt;
&lt;br /&gt;
Next it creates a thread (ThreadGetMyExternalIP) to confirm the local IP&lt;br /&gt;
address using 3rd party verification. If using a proxy, it does not&lt;br /&gt;
bother, because it will not take incoming connections.&lt;br /&gt;
&lt;br /&gt;
Next, if Universal Plug and Play is used, then a thread (ThreadMapPort)&lt;br /&gt;
to deal with port mapping is created.&lt;br /&gt;
&lt;br /&gt;
Next it creates a thread (ThreadIRCSeed) to exchange IP addresses.&lt;br /&gt;
&lt;br /&gt;
Next it creates a thread (ThreadSocketHandler) to &amp;quot;Send and receive from&lt;br /&gt;
sockets, accept connections&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Next it creates a thread (ThreadOpenConnections) to initiate outbound&lt;br /&gt;
connections.&lt;br /&gt;
&lt;br /&gt;
Next it creates a thread (ThreadMessageHandler) to process messages.&lt;br /&gt;
&lt;br /&gt;
Finally, if you have specified so, it will start a bitcoin mining thread.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread IRCSeed in net.cpp==&lt;br /&gt;
&lt;br /&gt;
Connects to 92.243.23.21 port 6667, JOINs the channel, and then&lt;br /&gt;
reads lines one at a time looking for other users.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread ThreadSocketHandler in net.cpp==&lt;br /&gt;
&lt;br /&gt;
Goes into an endless loop servicing sockets that need servicing.&lt;br /&gt;
Handles disconnected nodes.&lt;br /&gt;
Prepares &amp;quot;select&amp;quot; descriptor list and then calls select, waiting for&lt;br /&gt;
I/O on all the relevant sockets with a 50ms timeout.&lt;br /&gt;
Process new incoming connection on listening socket. Create a CNode for them.&lt;br /&gt;
Handle receiving and sending.&lt;br /&gt;
Set sockets that have not done anything to disconnected state.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread ThreadOpenConnecions in net.cpp==&lt;br /&gt;
&lt;br /&gt;
Figures out nodes from parameters, seeds, irc, etc, and then goes into a&lt;br /&gt;
loop, connecting to each one by one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread ThreadMessageHandler in net.cpp==&lt;br /&gt;
&lt;br /&gt;
This thread goes through all the nodes and calls ProcessMessages(pnode) in&lt;br /&gt;
main.cpp which looks for valid messages on the node receive&lt;br /&gt;
queue (pFrom-&amp;gt;vRecv) and if it finds one, it calls &lt;br /&gt;
ProcessMessage(CNode* pfrom, string strCommand, CDataStream&amp;amp; vRecv), which&lt;br /&gt;
is also in main.cpp.&lt;br /&gt;
&lt;br /&gt;
Then the thread calls SendMessages for each node (which is in main.cpp)&lt;br /&gt;
which handles creating and sending any messages appropriate for that node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Thread ThreadRPCServer in rpc.cpp==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This thread will be rather complicated in that it implements an&lt;br /&gt;
HTTP(S)+JSONRPC server using boost classes that are probably going&lt;br /&gt;
to be unfamiliar to most developers.&lt;br /&gt;
&lt;br /&gt;
You will see lines like this:&lt;br /&gt;
    acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));&lt;br /&gt;
&lt;br /&gt;
and this:&lt;br /&gt;
    boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest));&lt;br /&gt;
    if (!api_caller.timed_join(boost::posix_time::seconds(GetArg(&amp;quot;-rpctimeout&amp;quot;, 30))))&lt;br /&gt;
&lt;br /&gt;
It appears the code above is creating a thread in order to apply 30&lt;br /&gt;
second timeout to reading an HTTPrequest.  When HTTP requests are&lt;br /&gt;
read, they are parsed, and then a routine corresponding to the&lt;br /&gt;
request command name is called to handle the request. This happens&lt;br /&gt;
in a loop until shutdown.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Technical]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Block_chain&amp;diff=20711</id>
		<title>Block chain</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Block_chain&amp;diff=20711"/>
		<updated>2011-12-12T04:13:06Z</updated>

		<summary type="html">&lt;p&gt;Brec: Avoid run-on sentence&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:blockchain.png|thumb|Blocks in the main chain (black) are the longest series of blocks that go from the genesis block (green) to the current block. Orphan blocks (purple) are blocks that are not in the longest chain.]]&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;block chain&#039;&#039;&#039; is a transaction database shared by all [[Node|nodes]] participating in a [[crypto-currency]] such as Bitcoin.  A full copy of a currency&#039;s block chain contains every [[transaction]] ever executed in the currency.  With this information, one can find out how much value belonged to each [[address]] at any point in history.&lt;br /&gt;
&lt;br /&gt;
Every [[block]] contains a [[hash]] of the previous block. This has the effect of creating a chain of blocks from the [[genesis block]] to the current block. Each block is guaranteed to come after the previous block chronologically because the previous block&#039;s hash would otherwise not be known. Each block is also computationally impractical to modify once it has been in the chain for a while because every block after it would also have to be regenerated. These properties are what make double-spending of bitcoins very difficult. The block chain is the main innovation of Bitcoin.&lt;br /&gt;
&lt;br /&gt;
Honest generators only build onto a block (by referencing it in blocks they create) if it is the latest block in the longest valid chain. &amp;quot;Length&amp;quot; is calculated as total combined difficulty of that chain, not number of blocks, though this distinction is only important in the context of a few potential attacks. A chain is valid if all of the blocks and transactions within it are valid, and only if it starts with the genesis block.&lt;br /&gt;
&lt;br /&gt;
For any block on the chain, there is only one path to the genesis block. Coming from the genesis block, however, there can be forks. One-block forks are created from time to time when two blocks are created just a few seconds apart. When that happens, generating nodes build onto whichever one of the blocks they received first. Whichever block ends up being included in the next block becomes part of the main chain because that chain is longer. More serious forks have occurred after fixing bugs that required backward-incompatible changes.&lt;br /&gt;
&lt;br /&gt;
Blocks in shorter chains (or invalid chains) are called &amp;quot;orphan blocks&amp;quot;, and while they are stored, they are not used for anything. When a block becomes an orphan block, all of its valid transactions are re-added to the pool of queued transactions and will be included in another block. The 50 BTC reward for the orphan block will be lost, which is why a network-enforced 100-block maturation time for generations exists.&lt;br /&gt;
&lt;br /&gt;
Because a block can only reference one previous block, it is impossible for two forked chains to merge.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to use the block chain algorithm for non-financial purposes: see [[Alternative Chains]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20153</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20153"/>
		<updated>2011-11-29T05:21:40Z</updated>

		<summary type="html">&lt;p&gt;Brec: /* Incoming Data */&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;
===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;
  }&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>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20152</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20152"/>
		<updated>2011-11-29T05:17:55Z</updated>

		<summary type="html">&lt;p&gt;Brec: &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;
===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>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20151</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20151"/>
		<updated>2011-11-29T05:15:38Z</updated>

		<summary type="html">&lt;p&gt;Brec: &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 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&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;
===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>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20150</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20150"/>
		<updated>2011-11-29T05:14:55Z</updated>

		<summary type="html">&lt;p&gt;Brec: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides various methods to access information 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&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;
===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>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20149</id>
		<title>MtGox/API</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=MtGox/API&amp;diff=20149"/>
		<updated>2011-11-29T05:14:10Z</updated>

		<summary type="html">&lt;p&gt;Brec: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The [[MtGox]] API provides various methods to access different information 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&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;
===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>Brec</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Help:Introduction&amp;diff=19985</id>
		<title>Help:Introduction</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Help:Introduction&amp;diff=19985"/>
		<updated>2011-11-26T17:56:16Z</updated>

		<summary type="html">&lt;p&gt;Brec: fixed homonymic misspelling: fourth -&amp;gt; forth&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The purpose of this page is to provide a general overview of the Bitcoin system and economy.&lt;br /&gt;
&lt;br /&gt;
==Basic Concepts==&lt;br /&gt;
&lt;br /&gt;
===Currency===&lt;br /&gt;
&lt;br /&gt;
Alice is far away from Bob and wants to buy his [http://www.grasshillalpacas.com/alpacaproductsforbitcoinoffer.html Alpaca socks]. In return, she wants to send him a dollar. A dollar bill is a piece of paper which is very easy to create (by those who can), but which is accepted by people in exchange for valuable products and services in the real world, such as the socks Alice wants to buy. One simple thing Alice can do is put a dollar bill in an envelope, mail it to Bob, and then wait for Bob to send the socks to her.&lt;br /&gt;
&lt;br /&gt;
===Banks===&lt;br /&gt;
&lt;br /&gt;
Another thing Alice can do is to &amp;quot;wire&amp;quot; the money to Bob. She can do that by first giving her dollar bills to an institution called a bank, the job of which is to safe-keep Alice&#039;s dollar bills and, in return, to give Alice a written promise (called a &amp;quot;bank statement&amp;quot;) that, whenever she wishes, she can come to the bank to take back the same number of dollar bills that she deposited. Since the money is still Alice&#039;s, she is entitled to do with it whatever she pleases, and the bank (like most banks), for a small fee, will do Alice the service of &amp;quot;giving&amp;quot; the dollar bills to Bob instead of her. This could be done by sending a person to Bob&#039;s door, with Alice&#039;s dollar bills in hand (or, better, fresh new dollar bills, if Alice&#039;s dollar bills are in bad condition), but usually it is done by Alice&#039;s bank by giving the dollar bills to Bob&#039;s bank and informing them that the money is for Bob, who will then see the amount in his next statement, or, if he is in a hurry, the next time he contacts his bank asking about how much money they have for him.&lt;br /&gt;
&lt;br /&gt;
Since banks have many customers, and bank employees require money for doing the job of talking to people and signing documents, banks in recent times have been using machines such as ATMs and web servers, that do the job of interacting with customers instead of paid bank employees. The job of these machines is to learn what each customer wants to do with his/her money and, to the extent that it&#039;s possible, act on what the customer wants (for example, ATMs can hand cash). In the end, there is very little human involvement in this process, most of the time. The people can always know how much money out of the money that the bank is safe-keeping is theirs, and they are confident that the numbers they see in their bank statements and on their computer screens stand for the number of dollar bills that they can get from the bank at any time they wish. They can be so sure of that, that they can accept those numbers in the same way they accept paper dollars (this is similar to the way people started accepting paper dollars as they accepted gold or silver).&lt;br /&gt;
&lt;br /&gt;
However, the fact that machines are used does not change the structure of this system, which is, as it was, based on a central authority (the bank) which is responsible for keeping records about how much money belongs to whom. Everybody has to rely on this central authority to be honest (i.e. to say the truth about how much money they are safe-keeping in total, or at least to make the paper money available upon demand from the owners). Also, every person has to identify him/herself to this authority, by giving his/her real name, in order to be allowed to get their paper bills back or to send money to another person.&lt;br /&gt;
&lt;br /&gt;
Bitcoin is a system of owning and voluntarily transferring amounts of so-called bitcoins, in a manner similar to an on-line banking interface, but anonymously and without reliance on a central authority to maintain account balances. These bitcoins are valuable because they are useful and because they are limited in supply.&lt;br /&gt;
&lt;br /&gt;
==Bitcoin Basics==&lt;br /&gt;
&lt;br /&gt;
===Creation of coins===&lt;br /&gt;
The creation of coins must be limited for the currency to have any value. &lt;br /&gt;
&lt;br /&gt;
New coins are slowly &amp;quot;mined&amp;quot; into existence by following a mutually agreed-upon set of rules. A user &amp;quot;mining&amp;quot; bitcoins is running a program that searches tirelessly for a solution to a very difficult math problem whose difficulty is precisely known. The difficulty is automatically adjusted regularly so that the number of solutions found globally, by everyone, is constant: an average of 6 per hour. When a solution is found, the user may tell everyone of the existence of this new found solution, along with other information, packaged together in what is called a &amp;quot;block&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Blocks contain 50 bitcoins at present. This amount is an incentive for people to perform the computation work required for block generation. Roughly every 4 years, the number of bitcoins that can be &amp;quot;mined&amp;quot; in a block reduces by 50%. Any blocks that are created by a malicious user that do not follow this rule (or any other rules) will be rejected by everyone else. The result is that no more than 21 million bitcoins will ever exist. &lt;br /&gt;
&lt;br /&gt;
Because the &amp;quot;mining&amp;quot; incentive to put forth the computational power to create blocks will eventually diminish, miners will some day pay for their hardware and electricity costs by collecting [[Transaction_fee|transaction fees]]. The sender of money may voluntarily pay a small transaction fee which will be kept by whoever finds the next block. Paying this fee will encourage the miner to include the transaction in a block more quickly.&lt;br /&gt;
&lt;br /&gt;
===Transferring a coin===&lt;br /&gt;
To guarantee that an eavesdropper, Eve, cannot access other people&#039;s bitcoins by creating transactions in their names we use a [[Wikipedia:Public-key_cryptography|public key system]] to make digital signatures. In this system, each person, such as Alice and Bob, has a pair of public and private keys which he/she stores in a safe [[Wallet|wallet]]. Only the user with his secret private key can sign a document, such as the transaction to give some of his bitcoins to somebody else, but any one can validate the signature using the user’s public key.&lt;br /&gt;
&lt;br /&gt;
Suppose Alice wants to send a bitcoin to Bob.&lt;br /&gt;
* Bob sends his public key to Alice.&lt;br /&gt;
* Alice adds Bob’s public key along with the amount she wants to transfer to a message: a &#039;transaction&#039; message.&lt;br /&gt;
* Alice signs the transaction with her secret private key.&lt;br /&gt;
* Alice broadcasts the transaction out over the bitcoin network for all to see.&lt;br /&gt;
&lt;br /&gt;
(Only the first step is actually completed by a human. The rest is done by the bitcoin client software.)&lt;br /&gt;
&lt;br /&gt;
As a result, anyone who knows the public keys of both Alice and Bob can now see that Alice agreed to transfer the amount to Bob, because nobody other than Alice has Alice&#039;s private key. Alice would be foolish to give her private key to other people, as this would allow them to sign transactions in her name, removing funds from her control.&lt;br /&gt;
&lt;br /&gt;
Later on, when Bob wishes to transfer the same bitcoin to Charley, he will do the same thing:&lt;br /&gt;
* Charlie sends Bob his public key.&lt;br /&gt;
* Bob adds Charlie&#039;s public key along with the amount he wants to transfer to a message: a &#039;transaction&#039; message.&lt;br /&gt;
* Bob signs the transaction with his private key.&lt;br /&gt;
* Bob broadcasts the transaction out over the bitcoin network for all to see. &lt;br /&gt;
&lt;br /&gt;
Only Bob can do this because only Bob has the private key that corresponds to the public key Alice included in the previous transaction. &lt;br /&gt;
&lt;br /&gt;
Eve cannot change who the coins belong to by replacing Bob’s public key with her public key, because Alice signed the transfer to Bob using her private key, declaring that the coins which belonged to her now belong to Bob, and Alice&#039;s private key is kept secret from Eve. So if Charley accepts that the original coin was in the hands of Alice he will also accept the fact that this coin was later passed to Bob and now Bob is passing this same coin to him.&lt;br /&gt;
&lt;br /&gt;
===Preventing double-spending===&lt;br /&gt;
The process described above does not prevent Alice from using a coin in more than one transaction. The following process does. This is the primary innovation behind Bitcoin.&lt;br /&gt;
&lt;br /&gt;
* Details about the [[Transactions|transaction]] are [[Network|sent and forwarded]] to all or as many other computers as possible.&lt;br /&gt;
* A constantly growing chain of [[Blocks|blocks]] that contains a record of all transactions is collectively maintained by all computers (each has a full copy).&lt;br /&gt;
* To be accepted in the chain, transaction blocks must be valid and must include [[proof of work]] (one block generated by the network every 10 minutes).&lt;br /&gt;
* Blocks are chained in a way so that, if any one is modified, all following blocks will have to be recomputed.&lt;br /&gt;
* When multiple valid continuations to this chain appear, only the longest such branch is accepted and it is then extended further.&lt;br /&gt;
&lt;br /&gt;
When Bob sees that his transaction has been included in a block, which has been made part of the single longest and fastest-growing block chain (extended with significant computational effort), he can be confident that the transaction by Alice has been accepted by the computers in the network and is permanently recorded, preventing Alice from creating a second transaction with the same coin. In order for Alice to thwart this system and double-spend her coins, she would need to muster more computing power than all other bitcoin users combined.&lt;br /&gt;
&lt;br /&gt;
===Anonymity===&lt;br /&gt;
There are no bitcoin &amp;quot;accounts&amp;quot; to set up, no e-mail addresses and no user-names and passwords to give, just for owning bitcoins. Each balance is simply associated with a randomly generated public-private key pair and the money &amp;quot;belongs&amp;quot; to whoever has the private key and can sign transactions with it. Moreover, those keys do not have to be registered anywhere in advance, as they are only actually used if and when there is a transaction involving them. Transacting parties do not need to know each other&#039;s identity in the same way that a store owner does not know Bob&#039;s name is Bob when Bob goes and buys groceries with cash.&lt;br /&gt;
&lt;br /&gt;
A [[Address|Bitcoin address]] mathematically corresponds to a public key and looks like this:&lt;br /&gt;
&lt;br /&gt;
:15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC&lt;br /&gt;
&lt;br /&gt;
Each person can have many such addresses, each with its own balance, which makes it very difficult to know which person owns what amount. In order to protect his [[Anonymity|privacy]], Bob can even generate a new public-private key pair for each individual transaction. The Bitcoin software encourages this behavior by default. Continuing the example from above, when Charlie receives the bitcoin from Bob, Charlie will not be able to identify who owned the coin before Bob (not without asking Bob).&lt;br /&gt;
&lt;br /&gt;
You have completed reading our Bitcoin introduction!&lt;br /&gt;
&lt;br /&gt;
==Where to see and explore==&lt;br /&gt;
You can directly explore the system in action by visiting the [http://blockexplorer.com/ Bitcoin Block Explorer].&lt;br /&gt;
The site shows you the latest blocks in the block chain. The [[Block_chain|block chain]] contains the agreed history of all transactions that took place in the system.&lt;br /&gt;
Note how many blocks were generated in the last hour which on average will be 6. Also notice the number of transactions and the total amount transferred in the last hour (last time I checked it was about 64 and 15K).&lt;br /&gt;
This should give you an indication of how active the system is.&lt;br /&gt;
&lt;br /&gt;
Next, drill into one of these blocks.&lt;br /&gt;
Start by noticing that the block&#039;s [[hash|hash]] begins with a run of zeros. This what made making it so difficult; a hash that begins with many zeros is much more difficult to find than a hash with few or no zeros. The computer that generated this block had to try many &#039;&#039;Nonce&#039;&#039; values (also listed on the block&#039;s page) until it found one that generated this run of zeros.&lt;br /&gt;
Next notice the line titled &#039;&#039;Previous block&#039;&#039;, each block contains the hash of the block that came before it, this is what forms the chain of blocks.&lt;br /&gt;
Now notice all the transactions the block contains. The first transaction is the income earned by the computer that generated this block. It includes a fixed amount of coins created out of thin air and possibly fee collected from other transactions in the same block.&lt;br /&gt;
&lt;br /&gt;
Drill into any of the transactions and you will see how it is made from one or more amounts coming in and out.&lt;br /&gt;
The fact that there can be more than one incoming and outgoing amounts, allow the system to join and break amounts in any possible way allowing for any fractional amount needed. Each incoming amount is a transaction from the past (which you can also drill to) coming from an address of someone and each outgoing amount is addressed to someone and will be part of a future transaction (which you can also drill too if it also had already taken place.)&lt;br /&gt;
&lt;br /&gt;
Finally you can drill into any of the  [[Address|addresses]] and see what public information is available.&lt;br /&gt;
&lt;br /&gt;
To get an impression of the amount of activity on the Bitcoin network, you might like to visit the monitoring websites [[Bitcoin Monitor]] and [[Bitcoin Watch]]. The first shows a real-time visualization of events on the Bitcoin network and the second lists general statistics on the amount and size of recent transactions.&lt;br /&gt;
&lt;br /&gt;
===How many people use Bitcoin?===&lt;br /&gt;
&lt;br /&gt;
This is quite a difficult question to answer accurately. The best estimation is to count how many bitcoin clients connected to the network in the last 24 hours. We can do this as the client transmits its address to the other members of the network periodically. The estimate as of Sept 2011 is about 60,000 users. To get a more current estimate see [http://bitcoinstatus.rowit.co.uk/ Bitcoin Network Status Charts]&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [http://www.youtube.com/watch?v=Um63OQz3bjo What is Bitcoin?] video introduction&lt;br /&gt;
* Installing Bitcoin [[getting started]] &lt;br /&gt;
* [[How bitcoin works]]&lt;br /&gt;
* [[Using Bitcoin]]&lt;br /&gt;
* A gentle introduction to Bitcoin - [[BitcoinMe]]&lt;br /&gt;
* Another introduction, &#039;&#039;The Rebooting Of Money&#039;&#039; podcast is found at [[Bitcoin Money]]&lt;br /&gt;
* A beginner&#039;s step-by-step guide to using Bitcoin, use of alternative wallets, and generally keeping your money and computer secure - [http://BitcoinIntro.com BitcoinIntro.com]&lt;br /&gt;
&lt;br /&gt;
[[zh-cn:简介]]&lt;br /&gt;
&lt;br /&gt;
[[de:Einführung]]&lt;/div&gt;</summary>
		<author><name>Brec</name></author>
	</entry>
</feed>