https://en.bitcoin.it/w/api.php?action=feedcontributions&user=Nederhoed&feedformat=atomBitcoin Wiki - User contributions [en]2024-03-29T07:30:37ZUser contributionsMediaWiki 1.30.0https://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v0&diff=33700MtGox/API/HTTP/v02012-12-12T21:11:29Z<p>Nederhoed: /* 0/withdraw.php */</p>
<hr />
<div>Version 0 of the HTTP API is available at https://mtgox.com/api/0.<br />
<br />
== HTTP API version 0 methods ==<br />
<br />
=== 0/data/getTrades.php ===<br />
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.<br />
<br />
Parameters:<br />
* since: Passing a tid in "since" 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.<br />
<br />
* data is returned in standard json format like :<br />
<source lang="php"><br />
[<br />
{"date":1279408157,<br />
"price":"0.04951",<br />
"amount":"20",<br />
"price_int":"4951",<br />
"amount_int":"2000000000",<br />
"tid":"1",<br />
"price_currency":"USD",<br />
"item":"BTC",<br />
"trade_type":""<br />
"primary":"Y"<br />
},<br />
{"date":1279424586,"price":"0.05941","amount":"50.01","price_int":"5941","amount_int":"5001000000","tid":"2","price_currency":"USD","item":"BTC","trade_type":""}]<br />
</source><br />
<br />
=== 0/getDepth.php ===<br />
Get the current Market depth<br />
<br />
https://mtgox.com/api/0/data/getDepth.php?Currency=PLN<br />
<br />
https://mtgox.com/api/0/data/getDepth.php?Currency=AUD<br />
<br />
https://mtgox.com/api/0/data/getDepth.php?Currency=USD<br />
<br />
<source lang="php"><br />
{"asks":[[11.37998,22.89],[11.38,42.44592124],[11.3844,165],[11.599,1000]],"bids":[[10.7078,0.3],[10.70964,0.02024837],[10.70978,0.55822],[11.2903,2.8]]}<br />
</source><br />
<br />
=== 0/getFunds.php ===<br />
Get your current balance<br />
<br />
https://mtgox.com/api/0/getFunds.php<br />
<br />
getfunds is now deprecated since multi currency, please use info.php<br />
<br />
<source lang="php"><br />
{<br />
["usds"]=> "18.74737"<br />
["btcs"]=> "0.01733"<br />
}<br />
</source><br />
<br />
=== 0/buyBTC.php ===<br />
Place an order to Buy BTC<br />
<br />
https://mtgox.com/api/0/buyBTC.php<br />
<br />
POST data: amount=#&price=#&Currency=PLN<br />
<br />
returns a list of your open orders<br />
<br />
you can omit the price to do a market order<br />
<br />
=== 0/sellBTC.php ===<br />
Place an order to Sell BTC<br />
<br />
https://mtgox.com/api/0/sellBTC.php<br />
<br />
POST data: &amount=#&price=#&Currency=PLN <br />
<br />
returns a list of your open orders<br />
<br />
you can omit the price to do a market order<br />
<br />
=== 0/getOrders.php ===<br />
Fetch a list of your open Orders<br />
<br />
https://mtgox.com/api/0/getOrders.php<br />
<br />
oid: Order ID<br />
<br />
type: 1 for sell order or 2 for buy order<br />
<br />
status: 1 for active, 2 for not enough funds<br />
<br />
=== 0/cancelOrder.php ===<br />
Cancel an order<br />
<br />
https://mtgox.com/api/0/cancelOrder.php<br />
<br />
POST data: oid=#&type=#<br />
<br />
oid: Order ID<br />
<br />
type: 1 for sell order or 2 for buy order<br />
<br />
=== 0/redeemCode.php ===<br />
Used to redeem a mtgox coupon code<br />
<br />
https://mtgox.com/api/0/redeemCode.php<br />
<br />
* call with a post parameter "code" containing the code to redeem<br />
<br />
* it will return an array with amount (float amount value of code), currency (3 letters, BTC or USD), reference (the transaction id), and status<br />
<br />
=== 0/redeemBtcPrivkey.php ===<br />
<br />
used to redeem a private key via the API<br />
<br />
https://mtgox.com/api/0/redeemBtcPrivkey.php<br />
<br />
* parameters : <br />
"key":code<br />
"keytype":"auto"<br />
"description":description<br />
<br />
* returns the btc adress and the total number of btcs in this private key<br />
<br />
=== 0/withdraw.php ===<br />
withdraw / Send BTC<br />
<br />
https://mtgox.com/api/0/withdraw.php<br />
<br />
POST data: group1=BTC&btca=bitcoin_address_to_send_to&amount=#<br />
<br />
* pass btca parameter to withdraw to a btc adress<br />
* pass group1 for a coupon : BTC2CODE or USD2CODE<br />
* pass group1=DWUSD&dwaccount=XXX-XXX-XXXX (no btca=xxxxxxx) for a dwolla withdraw<br />
* pass green=1 to use the new greenaddress feature ( see [[GreenAddress]] )<br />
* pass no_instant=1 to use the bitcoin blockchain, even if the receiving address (btca) is on MtGox<br />
<br />
* return code and status if successful<br />
;Example response:<br />
{u'status': u'Funds are on their way (bitcoin transaction: 2426f19cda3332b25d02daf2479bc558b243a0631584d75dd2bb8ee45f50a118)',<br />
<br/> u'reference': u'58a9e537-e64a-4e66-bc45-31c1bdc3a91b'}<br />
<br />
To make a withdraw in another Currency , use group1=USD2CODE and add a Currency parameter ( example Currency=EUR to get a mtgox EUR coupon )<br />
<br />
=== 0/btcAddress.php ===<br />
get a bitcoin deposit adress for your account <br />
<br />
https://mtgox.com/api/0/btcAddress.php<br />
<br />
* pass POST data "description" to add a description that will appear in your history when this BTC address receive a deposit<br />
<br />
*pass POST data "ipn" to add an url that mtgox will ping whenever this new address receive funds<br />
description ( see above ) is also required for ipn to work<br />
<br />
* returns a bitcoin deposit address<br />
<br />
=== 0/history_[CUR].csv ===<br />
<br />
Allows downloading your activity history for a given currency (BTC or USD for now).<br />
<br />
https://mtgox.com/api/0/history_BTC.csv<br />
<br />
https://mtgox.com/api/0/history_USD.csv<br />
<br />
encoding is utf-8<br />
<br />
=== 0/info.php ===<br />
<br />
https://mtgox.com/api/0/info.php<br />
<br />
returns info about your account, funds, fees, API privileges, withdraw limits . . . <br />
<br />
<source lang="php"><br />
{<br />
["Login"]=> "some_user"<br />
["Index"]=> "111111"<br />
["Rights"]=> {<br />
[0]=> "get_info"<br />
[1]=> "trade"<br />
}<br />
["Language"]=> "en_US"<br />
["Created"]=> "2012-03-12 17:58:53"<br />
["Last_Login"]=> "2012-07-10 09:19:56"<br />
["Wallets"]=><br />
{<br />
["BTC"]=><br />
{<br />
["Balance"]=><br />
{<br />
["value"]=> "0.01733000"<br />
["value_int"]=> "1733000"<br />
["display"]=> "0.01733000| BTC"<br />
["display_short"]=> "0.02| BTC"<br />
["currency"]=> "BTC"<br />
}<br />
["Operations"]=> ''<br />
["Daily_Withdraw_Limit"]=><br />
{<br />
["value"]=> "200.00000000"<br />
["value_int"]=> "20000000000"<br />
["display"]=> "200.00000000| BTC"<br />
["display_short"]=> "200.00| BTC"<br />
["currency"]=> "BTC"<br />
}<br />
["Monthly_Withdraw_Limit"]=> ''<br />
["Max_Withdraw"]=><br />
{<br />
["value"]=> "200.00000000"<br />
["value_int"]=> "20000000000"<br />
["display"]=> "200.00000000| BTC"<br />
["display_short"]=> "200.00| BTC"<br />
["currency"]=> "BTC"<br />
}<br />
}<br />
["EUR"]=><br />
{<br />
...<br />
}<br />
}<br />
["Trade_Fee"]=> float(0.6)<br />
}<br />
</source><br />
<br />
=== 0/ticker ===<br />
<br />
http://mtgox.com/api/0/data/ticker.php<br />
<br />
returns the current ticker :<br />
<br />
<source lang="php"><br />
{"ticker":<br />
{<br />
"high":5.70653,<br />
"low":5.4145,<br />
"avg":5.561388723,<br />
"vwap":5.610932845,<br />
"vol":55698,<br />
"last":5.56915,<br />
"buy":5.51326,<br />
"sell":5.5672<br />
}<br />
}<br />
</source><br />
<br />
the time frame for high, low, vol, avg, vwap . . . is sliding 24 hours<br />
<br />
what is vwap ? <br />
<br />
please see http://en.wikipedia.org/wiki/VWAP<br />
<br />
=== 0/bitcoin_tx ===<br />
<br />
https://mtgox.com/api/0/bitcoin_tx.php<br />
<br />
will show the list of all unconfirmed pending txs tracked by mtgox<br />
<br />
=== pending transactions ===<br />
<br />
https://mtgox.com/api/0/bitcoin_tx.php<br />
<br />
gives a list of the transaction numbers for transactions broadcasted by mtgox to the bitcoin network, but not yet included in a block<br />
<br />
== Examples & Tools ==<br />
<br />
=== Shell-type CLI ===<br />
<br />
python : http://www.goxsh.info/<br />
<br />
=== Perl module ===<br />
<br />
http://pastebin.com/vEpgw5nW<br />
<br />
=== Other ===<br />
<br />
https : http://stackoverflow.com/questions/7046370/https-request-with-boost-asio-and-openssl<br />
<br />
https://github.com/sje397/mtgox-plasmoid<br />
<br />
module perl : http://search.cpan.org/~mndrix/Finance-MtGox-0.02/<br />
<br />
=== PHP Dashboard ===<br />
<br />
https://github.com/Lexiks/MyBitBoard<br />
<br />
=== PHP ticker and pricing tools ===<br />
<br />
https://github.com/neofutur/bitcoin_simple_php_tools<br />
<br />
=== Bash trade history ===<br />
<br />
bash : https://bitcointalk.org/index.php?topic=39402.0<br />
<br />
=== PHP Ticker & BTCGuild mining estimator ===<br />
<br />
http://pastebin.com/pd0ZR4WY</div>Nederhoedhttps://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v1&diff=31793MtGox/API/HTTP/v12012-10-14T19:07:50Z<p>Nederhoed: /* Withdraw bitcoins */</p>
<hr />
<div>'''Note: All API methods require a valid User-Agent header.'''<br />
<br />
== HTTP API version 1 methods ==<br />
<br />
=== public information ===<br />
<br />
==== Multi Currency Ticker ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/ticker<br />
https://mtgox.com/api/1/BTCEUR/ticker<br />
<br />
returns the current ticker for the selected currency :<br />
<br />
<source lang="php"><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"high": {"value":"5.70653","value_int":"570653","display":"$5.70653","currency":"USD"},<br />
"low": {"value":"5.4145","value_int":"541450","display":"$5.41450","currency":"USD"},<br />
"avg": {"value":"5.561119626","value_int":"556112","display":"$5.56112","currency":"USD"},<br />
"vwap": {"value":"5.610480461","value_int":"561048","display":"$5.61048","currency":"USD"},<br />
"vol":<br />
{<br />
"value":"55829.58960346",<br />
"value_int":"5582958960346",<br />
"display":"55,829.58960346\u00a0BTC",<br />
"currency":"BTC"<br />
},<br />
"last_all":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_local":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_orig":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"buy":{"value":"5.53587","value_int":"553587","display":"$5.53587","currency":"USD"},<br />
"sell":{"value":"5.56031","value_int":"556031","display":"$5.56031","currency":"USD"}<br />
}<br />
</source><br />
<br />
'''note about prices:'''<br />
<br />
* last_local include only the last trade in the selected currency<br />
* last_all is the last trade in ANY currency, converted to your currency<br />
* last_orig include data of the original last trade ( currency,price in currency . . . ),<br />
* last is always the same as last_all<br />
<br />
==== Multi Currency depth ====<br />
<br />
https://mtgox.com/api/1/BTCPLN/depth?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/depth?raw<br />
<br />
==== Multi currency trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCPLN/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/trades?raw<br />
<br />
to get only the trades since a given trade id, you can add the parameter since=<trade_id><br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?since=0<br />
<br />
https://mtgox.com/api/1/BTCEUR/trades?since=1316312781670700<br />
<br />
For multi currency,also returns the primary value,"Y" or "N", the primary currency is always the buyers currency<br />
<br />
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y<br />
<br />
Each trade is described by a JSON structure like the following: <br />
<source lang="php"><br />
{<br />
"date":1316312781,<br />
"price":"3.5599",<br />
"amount":"3.6900096",<br />
"price_int":"355990",<br />
"amount_int":"369000960",<br />
"tid":"1316312781670700",<br />
"price_currency":"EUR",<br />
"item":"BTC",<br />
"trade_type":"bid",<br />
"primary":"Y",<br />
"properties":"limit,mixed_currency"<br />
}<br />
</source><br />
<br />
The meaning of each field is as follows:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value<br />
|-<br />
| amount || the traded amount in item (BTC), float, deprecated<br />
|-<br />
| amount_int || the traded amount * 1E8<br />
|-<br />
| date || unix timestamp of trade<br />
|-<br />
| item || What was this trade about<br />
|-<br />
| price || price per unit, float, deprecated<br />
|-<br />
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)<br />
|-<br />
| price_currency || currency in which trade was completed<br />
|-<br />
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)<br />
|-<br />
| trade_type || Did this trade result from the execution of a bid or a ask?<br />
|-<br />
|}<br />
<br />
<br />
==== Cancelled Trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/cancelledtrades<br />
<br />
returns a list of all the cancelled trades this last month, list of trade ids in json format .<br />
<br />
==== Full Depth ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/fulldepth<br />
<br />
returns full depth<br />
<br />
WARNING : since this is a big download, there is a rate limit on how often you can get it, limit your requests to 5 / hour or you could be dropped / banned.<br />
<br />
==== transaction information ====<br />
https://mtgox.com/api/1/generic/bitcoin/tx_details?hash=4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0<br />
<br />
will return :<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"hash":"4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0",<br />
"blocks":["000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7"],<br />
"version":"1",<br />
"size":"1158",<br />
"in":<br />
[{<br />
"n":"0",<br />
"prev_out_hash":"4578576f49418e69da6d7a1166168bb80a94682f21cca518b6c2451bc64bf858",<br />
"prev_out_n":"1",<br />
"coinbase":null,<br />
"scriptsig":"304402201d7eaf891bcda16ea2979694c02e590fea8fc43dc092ee60e5fb2dd756bcb19502205c5be31b772029700d0a43d499932e9c321af1cfbc8745fba6dbbe48fa79bbb501 043a264aac55e23f83b29ac7e7a914584d2aa6c2eb08ea05405f5efc38473183ca4fc075f8144bb78698df1a5be6f4057f1bccc9e1217a5658946bcc4d4f6972c3",<br />
"addr":"46f740cb9c737111ec91ec235f6877055be7175e"<br />
},<br />
{<br />
"n":"1",<br />
"prev_out_hash":"4feea511029896ff4c31132346a79594fcd0c4e60aab2fa4f527e1395d375488",<br />
"prev_out_n":"0",<br />
"coinbase":null,<br />
"scriptsig":"3046022100f3bc0445f629e4e896ced23013d89ba6e6488a6ec21c47df608aaf6d6d212fbb022100d321c4c7f5f33900b8c0efba8ff58a3541e621588f402e167f51968b6ee0bbf201 042157f97a8a78caf6315dbd6d9267b9edd9c1c37cdb211f2bc03703a28eeebaf274efdcff4ef3e3ef4a6b7ccb5d8c17acba941d1a5669c3299f22a0e78e702fdb","addr":"7b0a72820f6e92ccc384dbdecb5584d855ce9416"},<br />
<br />
{<br />
"n":"2","prev_out_hash":"9adadb88c3075afdce1216b35d27fd5cac9736ce3977778999f9a85105d2ea8f","prev_out_n":"0","coinbase":null,"scriptsig":"3046022100d63237cca9bf2200c6aa255834e06f9dc5e4e20f1ea7e6678119bb0e4a5a109f022100db37ec795336509fb3a16d1acebfe08523d95e177284149614a6d3384286b27c01 04b16b41dab16cfbf59f1713559795440b98b384dc01656ebaceeec8f6d1463802cb474062b2b8c1de53ab1fe65be0f6213dd61519044e9c1f50291b915fc7fc6e","addr":"2ed7c49f080e9898737276ad802e2067a1d06ab7"},<br />
{<br />
"n":"3","prev_out_hash":"0e2ed4e4db87ddc9cb54ab3cdcae59762293815d3093c238e42d33248b39e19d","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100ab501414e7643cc1a78645f544cbcf6411e71e0c21953cd51f7f9933a50538a002201b4c9bac60aa19d659d0686d45bf06c4928c4446269692d88722f57624cdaf1401 048e1e4862c6fee7293f6c7be43a72a375e68395398e4d5da3db06199a35fc46cf51b87f3c6b87caeb81181d630706e23b5679ae8b96ca36701282ae5b49dd99c9","addr":"c74d2e95aeb037297c7b6a232d78c715fa1ab826"},<br />
{<br />
"n":"4","prev_out_hash":"93c912462daa2a52e108e3424596d56fe2a136d6707a65b6423dee229e317ea1","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100fe782441b8788ed9297c8fea735701ae0a77081fc748ceee8cde945107f64967022014d51d5bc8d8138b97a657eda6d03ba998810e3e941988da90b82f6d24d8471e01 045f53cf2dbdb3213084efa69ac1dfcd8d97be8073a8b8104feb000513aa048b653f400d23314fc090456078f46a0fc9daabdee57f1ef14c2111b9ddc35255189a","addr":"958bba83ac42ebf055c1724b25bfe5c698abbb51"},<br />
{<br />
"n":"5","prev_out_hash":"44a1b493ef6176cced4c02fb97a227b98e5bea0616d9cdd6005bcd6905d667f3","prev_out_n":"1","coinbase":null,"scriptsig":"30440220132484ad901567d2c52c0b4f3be5263d1d8ed6e76be1398d2bb7c2a1aec5f748022033b907afa05eb075dee9993b8a05c9e40c69e53d65a06cc8a975ff4c4407141e01 04bd5d7feb1884efdccbe8feb8fa9ff57d56272ac5f667bc59cb07a232fbbd9cbabdf54b6bb6ca4c77e0de22cb0f896fa6183e53381861641049f0edee2d64cfe5","addr":"3784c102bbfd34cc7fb6e12c51b5c6177592f267"}],<br />
"out":[{"n":"0",<br />
"value":<br />
{"value":"0.01000712","value_int":"1000712","display":"0.01000712\u00a0BTC","display_short":"0.01\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 6427f36ed6e5a0cb526a0b0bef1335992326e9a9 OP_EQUALVERIFY OP_CHECKSIG","addr":"6427f36ed6e5a0cb526a0b0bef1335992326e9a9","claimed":"N"},{"n":"1","value":{"value":"3.31674208","value_int":"331674208","display":"3.31674208\u00a0BTC","display_short":"3.32\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 1f27d1fc284143729944ab89823111d2bb63dc46 OP_EQUALVERIFY OP_CHECKSIG","addr":"1f27d1fc284143729944ab89823111d2bb63dc46","claimed":"N"}]<br />
}<br />
}<br />
</code><br />
<br />
<br />
<br />
==== block information ====<br />
block information can be accessed by depth ( the block number ) :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?depth=188111<br />
<br />
or by hash :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?hash=000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7<br />
<br />
both will return ( for block 188111 ) <br />
<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"info": <br />
{<br />
"hash":"000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7",<br />
"parent":"00000000000005adbcc9846f9f3542f9349b19a3c8a8f8149a830e8d748b0c92",<br />
"depth":"188111",<br />
"mrkl_root":"772b7dcc99c98a9d77e40e2ea300ba492254dea5439599f666c77bd5be1f3b4b",<br />
"stamp":"2012-07-08 12:03:12",<br />
"size":"76898",<br />
"status":"confirmed"<br />
},<br />
"txs":["020d258be19e6b399301acca1857ceb13adf643edbc660942d7eacc3290bdf55","0575fb1c09f86de21bdb00bb1423053e5ee667158ad50aa0043e82bdb3d21a1e","07830422f821fcd63e316411c883486161f15154ba27b4fffbd934fe02423020","07a6cdf84e5b5aec5f3ec968a36a469e2923237254c31adf8cc895f4d47dbd0c","0af35c993e0094010a73d48bded49ea1c7f5d26a1d80fb1ddd2fada39f725656","0b5a4340a8daa28832c4ea7baa463b896fe954bca50bcfaa2671947725c103bb","0c5adc9fb24a3daa80fe0e2ed6c6b35ee0cb70e3aa6da42276e04fd2132ee4a3","0d28cea45a0a90ac105777d1d53318d23be489416aded7bcc1c92ed2f7426358","0f05493623804d9ad4501521c893fb186cbb03e41962bbd42a10bf6c89f60026","0f627402384a9c88ec878b6d7e3866f88d8c91295c7a3f595a50f32af3a962e9","100f488d2822b1e50ef6b7a885fc576a610b2aa5d36c660c6b000555f5edb182","12d1cdcd17cfbccfd5184543c9edc5a18c3add089c76afa33c0da72001fcd2ea","144516c54e56e3c9a049995fd402dd4749eb7bf4276c247c598f67ea126c1ef0","158be63da6a97dcb7ac2286ae148ba0bbee62d4eb3be9423e0de84337c67cef1","175a4c4708a6237bdde8cc355487c1b85f61915d1336fb9ec1216946ed949efe","180a9901550e68c552fab07b23788bf424636ef899a73313c9dde8e00757acd9","186d0632a342d20e97a612e2ef6c60b74af278678e2221a5c043bb8bac683f73","19cf092b8657d0da33ef97c628469bfa0e87f564327629311881e8ef4cbe203c","21a79eeaab53234b1017689fcf13894154d3a9083d10feeec9096b2bd5135649","222e59465dae7866897b9a750cddb3924e775637944d3ec6dd1cd0f81bd9f36b","23e28db3cb8dc658d010eb7b3ed9f4ac0ae3be4049bad0d557c2a7446954d185","2426cb2d1fd6958c1830f98aa54bd9ee86fd3325cb13b1e9aeeb2901f481b38f","2528e80141db0f5a09f6d8ded3ba06427476256a70442a7df51fe3c2686bef64","256e754aa2829469cf575b121eb4abb7f6a1f0aeee6f221bfd14a5e0b0ca9baf","25fd783b5cdcb1e1769092a007103556bc3d5d419b5d5ba9ef6e7400a5e0caa7","268fa8738fe708161071624d3143475a7a26f7ccf8dd031c91861a3dd59d3eee","2801207fb1b50f1d60324b7a790da36c244875de7b0329fe1be53439e74d9553","2826f91a4664031f5ed7239bddc11fe746b63e1c5d70bbe043ffb62e966a2c01","28d4fcec098886db460d300d9a62be49c31ddbd1cdaa203a5fbdf8021eba22b6","2ada3f324802d7ad3dfa7d5ff24e888c3919cb8e7ba1050f59cc814ccc6c7f41","2cdce29d3ef98062d36e63d150e203737f1374f43e8a1b36eea08286450e5e24","2ce5579a4c205761779668232c685eb0c0974f0328daa073bafec2119afba906","2d1928299d04653351d2358885e51a981f227d9ac8eaae34437b63eff8f4b28c","2e5686a497efdda63de8c5aa23fd349f3004a31ccebc6b3954de06669b3dfe9c","2ecc8f682cb7e65802072bf311cdb9f87e25cf34ab3f0f475c16169040b3c654","335ab9791c80ab80ccbf55e6829ad3c67a6b48426769b9bd7b3d866233ad912b","34bf38fb8bb1e74d1570e4e357bf2c9af3956917bf3f49ee3a5a9bd9e89e174c","351835329ddecfd75c74fd82b207a6f1481394321b3c3613e71dad74654a59ee","38f67149f684713e8271b2f709c125c365cc0ae97c740d0e4a07822f71f3b640","39ddb42041f0ba3c7d87c2d5e74a633a1907f188b57569b2641c77fed674fe0a","3bdb7e7e5d8b7b4dc37fb961272819eeee0da9854657318503be4397567497c4","42d2e9a1a1650d58c21ebcb14eef6da5b248b43c96e1bca816baee4c73978650","42dba17d47c259559dc9a5a110457196ccae97447f2b9e6056fd96e471e09715","43a262b3cc7b2899b166ddf06d37fd4600b2348342514d8646a76c454b4772d0","4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0","44adb50a8c3096a079c5fef9dfaae479b2f2804e09106097d480a8c1b0672da1","44b4dce02cbd628e8f88bf7ca36f650db866b16c5a79b3cb6f6b24bcffb1c089","489ef413e51bcbd23a4134c366f2537d99ea81913af43627dcab4ccfd611d1df","49d2a512f63481a42ad30a1b3845fc2929296945519c0998dad4fa361064765a","4d5372c14355d789decb0e100fb05e86f6b854d0187815b60a1b37de41ca245a","4db9e6cc810918143fba3dfe8cc3030847b8297775dee7540ca03fbb0c8788c0","531bfa06d7164dc5cb971e3fe90aefd61c188a5d292350a2cfc12cd8bac760f6","553341c3683a9ccabe10fbb65334a694bab2469fa444570e51d81b7d416414f8","5592b28d4a6f652fce290e1502a6204ad501ec5759438c59209f29bd9e80f972","573b1dee0b00b1936d8e8b4f1f45e47c246d7be09b0573281bdbb0b71035841e","5767fe6251014d97a2f14e1226ae08b11065f78b7f52a390bda3eb87cf63e9d5","588c8e0d458ee5516468d4f0f68711757bd4e291e6456be8e3fde1fa9c6e72c9","59f3d51b41f346c08fb73be2a540ebc2aeffb2220da5c2e5d927b74a5249c907","59fb156e2e6b901524a7b7fe906db455f014deb361096db937db5be952490b36","5c2c78de645d59a57500e0a3ba19d91ff8dc902a6d75c16512d013449a74957c","5da0e429c410ce6220f7206e6ee41f0fc8216000908b3d8eeb651345fb5e7435","5eebfbda3754fc240d1b87806cf57c0f6805eee3cbf8b0c29f8da96017ddbc1f","5f6d93830779e69b1a9e44ceb81fe42ddbc1b453014548b44b348d5e979f98cc","601f57984bead5aa7767885e2d01e9d24582c1c7a2f7e907b70b76bf773726d3","60ae2132f0864e3700db8b6a30ee7e4d7e7479798c5ce14df23a7935016b2eac","67177915a8a163c49f0cfe7f12a065e24046d8b32ee4b6b5071954c12f9f8173","67398f5c224a83debf5455b5caa6976249d35344a3b4f39700cda11569494203","68d1bfff53204d0eeadb35540ddcb43ad2c7aaa9ff647052ab4f2d66f3094e8d","6962015317f58edbed7b8725f344a25fb7d8dfca743715558d916cf1a8b32b24","6ab7e2e0c7749ea166968629f584c2be8687667fdf6861d53368c944e10eda3a","6b11cbd800814e5d86afcd3daf56fed4e8f987007ff4ab835a05e6de470f35ff","6ba15ceea3a22c3a8b3539c1124a4d641409a680db07af35e35d73da877e8da4","6c41c14638745ca2b820153386fd95948d8bf048750328cd397d05241ebec08c","6f3e68f9b4d007249b4585b0760e2b892a7f6b8fd2ef568e93856da20d96ebe4","702a98c7b9a4cccce628ea40ec94f9663c9f3163190c18c0d5011fae44f50a7c","7084504bf52356da59c8ca8e96c6cb4d2d85f10ae4c02fa74b50e26c6b8467a0","737e38e017b1a9308ea2264c8c4e9bba612ffba3fb44de505f3e479ea1d572a4","75b3d2188033c8e2a9f5aed17cd80c71d5599f9af23ed36a9561bdc3a15fec04","76b16f3014b25107d0b88172c2913980948c9bc8c68132ea424c54c00e7858d5","77141d625b4521eeab882b79e217cfe19cf8e74a757729152bf60ee5a70071fc","7b309dc1e54d784f3772631dc4b01f5dc414904d21f77905c9f6d70bf8423d67","7b4a63bc061f7e95461631e58aaf96314591ae0fb0feef90ecc31003824eb66b","7b7a0136f2fc529018f0568a21bcb73996375ed9eb2c627846b28f5b09095a0d","7d00ff77f0f12ab7799ed571bcb438df230135e26796cc4b984908103beae847","801314902f70f8939fef64267687d2bb95c333a62464ee5db76b88aed8b9d360","80757f7f5a5ecd47e64cd5299442038b7922d15d5c303d2a950deac204b7807e","836bea75b79376c547544b06298cd3fb3f5974641b3ceb77eaba687e19e2cec4","86d5cf06b40acdf96215db8a767df3e1fd2c8e4641007e8ee5c6f8bd9b47f3ea","8a4f4d6acdf5d875e2ae14cc17becbb45072c7229a864b3fa1cdc80b45d80597","8ab04f7f610a17d08613fca7d79dde9fb5817904e1055bd6b8eb574e9531ff5b","8b1dd8aa0b6272770d2491d35944fb9b3d3169c72e8275ef2411b801fed1785a","8c7695f70007d17fbdcbcbeb921837b2c5ef3469c27ca65ef3e75e0634e06357","8ccf0173e0006b65019d4b2634f824c69883f8bb6ab3670eff36183df45d437a","8cedf02ad54c94948e69c69dacf8b5f94d6a20b156f112b79b635610b9abccfd","8e0e0aa6ae3df684489ef41c6c65e5c9fb9d72d2aa455b2453a6495ab45aa29b","9059fb2f4ddb94bfe924c3c009e1e1cd8da53513c9ec1a1aa7e20c2376274dd5","911766a8e660a973180d306aa95fe2b9037f37db28cf166e59aaf986ec72608e","95bd4211a0fdb9c028c1b7f694b72ab8222ead20d0f83edd7288ef19105208f8","971e6feb86d955f9aa194e25c596499b5ab5683c68766877b14eacaa86ed6836","993fcab01aa5882308af5b870c0a191884ff4ecdb8cee964ad58e96781763d65","9af2c6bb2897847bf8ebb71ee600c810354bdf8aa78ad8aab864ba89be3aae0a","9b4d84991e2dd181570dd4f5d18e533c57252ec8ddb6642c990386e8cd57cbd7","a05b2c1547f8513ded94425763b6f34cf3019e7f649163d31fd8fec770950fd4","a36f43271195cf031b2a0e3df297a206088a11c3f03cc4ec255721c017825140","a3825df57a7f4d6e3f204d35d1b58f24d0a89dece8c8e8cf277fbad2283eaf0e","a3a6ccc3af9becf7135b58798e5190251c8499171681b3c2c1110dd0cb1ca0f2","a3dbbdbe58586d5917828a058b37e471e15d6a42688397e93888d6ce58025a55","a48a185b6d50ae91a94b571bb43f173102a172cd886649bbe1563c875ca2142a","a4b7d03a4af6e2225902e026adb2e265e07a10a8a062a49aad2f544fd7c900f8","a6de57825868deebdb57a405c7f9085f21a249ea9d36bf1c18e9c709280523dc","a7a9eb9c044a5fc5e27bc9ba533b794543e154c2081266988e2ca07e37380787","a92d2d46d0d65e3ea05b68ab16b32bed760fa2955c9f6b9f91687e429724524c","a9c2cff9357c003de5e6498e0af52ad8f24778fd18ca274fd135a7dbb4464a8a","aa1d22c31d4dc4114888bccbd7110a1f777887ed8dd2dfa006eaaeeac58d2a44","aa313832f108aecbfae05acab011d40ff1d1ec540cd2025851dcc10d92bcd0c3","abbcfbdc79d0536344295d6e0cd6d7ae788a385836c33c7ef7f98f6064ad2ee1","ac3a732c65504a9f4e728cbaf80d4d58f74a3834138a224657eebd03982c1898","ac6eb25fa5be2a1d1418879791cadf43b1a268cb3aa2e505977cb29e4b7035dd","adec207d59a23cfc8afc63b0e45bfdefde9b7ffe74515872f0837025530ab6eb","ae1584bf163b05c014d0d99715f481655949c7762d800997562fc93f3da731b8","b1403965758e40e9d2eb31950f97dc599368edeb98541ede8df2b512ef2fd3bf","b3c086e90eda12260b5bfe8eff16a051882dfd921c02140194c0e0ee9a849466","b4062fe2f07abe03e2e9b88b571c7f2d9c058c78fb157d3d04fa39feda380a02","b416514b63420449c6c56781adafff18f6f28733aeb2fb4bb0c1abeadbd6db6e","b7bfbbc5fad15123960443cb0c118162a62a4b92732a8365eeb77e8df25eca46","b871fea4a33e5e51ff648ca74d16a34f179d3467805cad84238c729282e8acf7","b878eaf74341fbc65c609785b93b38d90f841f2d50bb39496e1f4b1b34b2255d","b9a80691e7d9423ad546a96363a017a4a0725dc854de082d6927da6cd6aa19c2","ba7ef3d90be2bc57c785f55457971ff0812a4d9b9df18ab980229ce648cee31d","ba8669e2e19c21a0045d994c56e811b2d1d51451ab248e76df456427d0d20569","bc260c6b49fe06a331202a2b703cb051aa352d17a8373496dd5ef67ab404a145","bd260517b438daa35921cca54b8c2dcd48b8ca338f7166d91ecd3a3eb14c9d7f","be375723b763ea3e88f9539eebd1f73f8af0b463b7bb88781dc3f589ab36e9ad","c0c4c3b3cd1b400b81316dd67001b92a512569dadd0ed6f783e87e601c8ea54e","c156c12f1256b4a2a6c0558b7094e263876586e4a72333da2997fb97cbb8d15d","c2a5f97fa1daf09015fa78a57b2aed1d33b9c18ffb84bb7f3d0e8d643532b772","c54d091b9d006ed79405b62defa7910a7ab9db6463f46ab1c50064df152aa887","c5a7a5ed8e2b4e72ca8c72025e91e14388ee23c7822c16bd3fe3b11c206ffb84","c5b5f35b88138f27b6aa2395f423d15dbf642258971102de77359ff79eb8d4cb","ca52540a211bac9449b45662ac2a6a00899bf55b5867017ab73b1973ef3a8f6c","cc6f6ad1f5a023bb52f7638f883d4bf20dab6bd3a0b1b9a3c8526fc99aee81d2","cef0df2d68b4f38fd9ce501839e3d4d2a40317d845037baa2b7ffb3ed45918c1","cfd0806446352b03d89be45f1014c0a48728286c5b12fc89d32a3cb31896765d","d03fe289cf120bdb3ae70711da1c8972f650fb8e5c4f91dabf17639a2c7ecb06","d1089a3f2e4f0d043eec44395a5522f107fc649ca561f76013d412c85710c306","d1a68d6cf85c32a15011cd13b374ab8aad619b1b437ffd262c446cc079babedc","d4201c9a33e19e2ba351ec288ec5a43f4b3f2cb133d6a7977f72c529d3e03408","d5991156ebb5beeac70ac0cfc1706990be5752b41bafbe31228053fe18dc3e67","d86adacb713cc4ecf06828aeb2b8e1bb0311144986978c59240ce996214ab69f","dab5fe0369dca967e09653cb0475e09636091ba0a6ee95289de49fe97e505f3d","db0ee162bc04083d6caed8a88a7be44b02d15b2686a2d6dd06a10d024cefb40d","dc453efc8162dbff08e04fdda7a5dcbd986ee0fbee547764ff7ae89afe68806b","dc5e2a39f8e1ce90f88c3f50076ed03188fc60e87b103a0d48e66fe462b7777f","df826a504bad73ab69fcd740f72e6e00488e69db8ec31a55ffb3ed43b0845cba","e05d71cfe0b356b0dddee437f9da2610f85c5dffedc3ab058172ab71624a7d14","e10fb8c50f8e378b43f4f80b41e62b78dc968496196ae8399fa7d203e213a3cd","e5b9be11e940019582c6ac0875f54e7bc92fd15149cecf4e1bf67d4357010cce","e7a64e4c08350ee2f0ecc3af4c2df7388da044de4f7955a941ff965a925b54b8","e84b2c1129b574a485dfa7d8843cf569b3679f234b681f6f8fa0d88d5489b224","e8df3c1953e9c32ae77bbf01dcec48e1052271e0eb6d556da9deda1c50426231","ec46f3be50d9f2f6472669b8c8e38addd54c00bc206c81e873f340c0a11d71f2","eca4fdc50f34ccf5e0b459b0a077ec9033cf25c58e29b3406f24eab6445a6221","edc7488d9f86de7d094c1d02119680b91a15a28cf7a8b09cf9cf194193ae81bc","ee4b82dc8f11c5459a42090c1aafaf645f2c1d247edec1d9b0fae46f4efaa02f","f03f924d1767b748f8fc15bcef798076e746a7917f5fc7b89e2ed022c95faa82","f104ccccf3bc11107b27900670f36de7fdda3a0a7d086d2dc69b4903aa2cbcd5","f18d25a1fabd8f3a62edb164c759b650c13c320f2edc7cab44c01ae88809b285","f2a1ff85c3ac02574d1f55b067c841ea4b0283ed9543f11752fa41723b315ed9","f46a661429090548bfe775c5df5197b0cf6ae5d38a215986b79de385b52d4223","f5d19ba9a4a11db479fd80aea1674eb896f515fd43f34c456b09f49500ecd4b7","f629a172edcac21d929169f2bb1dcf148110151b769bae15e4fc09bd72898fd2","f6d1ca49cea130563f72f266612eb901c9290b3bf36fd4218d5881c5c9d7d35f","f79f17ff115716f428034aa9181d63e67649404559448193fb6c96f35cad3e00","ff0e08dd175e3badf556ea843a972edea4c80f461cfdabbfdb69167ba3845055"]<br />
}<br />
}<br />
</code><br />
<br />
==== address information ====<br />
https://mtgox.com/api/1/generic/bitcoin/addr_details?hash=1f27d1fc284143729944ab89823111d2bb63dc46<br />
<br />
<br />
==== Order lag ====<br />
<br />
https://mtgox.com/api/1/generic/order/lag<br />
<br />
The "lag" value is the age in microseconds of the oldest order pending execution<br />
If it's too large it means the engine is busy, and the depth is probably not reliable<br />
<br />
==== Currency information ====<br />
<br />
https://mtgox.com/api/1/generic/currency<br />
<br />
pass parameter ?currency=<currency_symbol><br />
<br />
returns information about a currency ( number of decimals . . . )<br />
<br />
=== Private API ===<br />
<br />
==== Private info ====<br />
<br />
https://mtgox.com/api/1/generic/private/info<br />
<br />
returns information about your account, funds, fees, API privileges, withdraw limits . . .<br />
<br />
==== get a bitcoin deposit address ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/address<br />
<br />
get a bitcoin address linked to your account.<br />
the returned address can be used to deposit bitcoins in your mtgox account<br />
<br />
<source lang="javascript"><br />
result: <br />
{<br />
"return": <br />
{"addr": "18dGNs5Bd6pPMuSchLHQtb1k996YpUHs3j"},<br />
"result": "success"<br />
}<br />
}<br />
</source><br />
<br />
optional parameters : <br />
<br />
description : a description for the address , a new description will generate a new address<br />
<br />
ipn : an URL that will be pinged when this new address receives a transaction, the ping is a POST request with txid, blockid, description . . . as parameters<br />
<br />
==== redeem a private key ====<br />
<br />
https://mtgox.com/api/1/generic/private/bitcoin/addpriv<br />
<br />
allows you to add a private key to your account<br />
<br />
* parameters : <br />
"key":code<br />
"keytype":"auto"<br />
"description":description<br />
<br />
* returns the btc adress and the total number of btcs in this private key<br />
<br />
==== redeem a wallet.dat ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/wallet_add<br />
<br />
allows you to add a wallet.dat file to your account<br />
<br />
* parameters : <br />
"wallet": the file content of a wallet.dat file ( base64 encoded )<br />
"description": optional parameter to add a description linked to this wallet in the account history<br />
<br />
* returns : "amount" ( total number of btcs in this wallet ) + count ( number of bitcoin addresses in this wallet )<br />
<br />
==== Withdraw bitcoins ====<br />
https://mtgox.com/api/1/generic/bitcoin/send_simple<br />
<br />
Send bitcoins from your account to a bitcoin address.<br />
<br />
;Warning:<br />
: MtGox sent me notices to stop using the ''withdraw_btc'' method from API v0 and suggested the ''send_simple'' method.<br />
: Unfortunately, I keep getting the error on the bitcoin address. Once this is resolved, I will complete the spec of this call.<br />
<br />
Parameters:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value !! Example<br />
|-<br />
| group1 || || "BTC"<br />
|-<br />
| btca || Bitcoin address || <code>18ytF1DH13LYEmBGREr47bNXNe6oH9ygzj</code><br />
|-<br />
| amount || amount of bitcoins as float || 1.23<br />
|-<br />
|}<br />
<br />
=====Success=====<br />
No success yet.<br />
<br />
=====Error=====<br />
<code>{<br />
"error": "Invalid bitcoin address, please confirm your input"<br />
}</code><br />
<br />
==== idKey ====<br />
<br />
https://mtgox.com/api/1/generic/private/idkey<br />
<br />
Returns the idKey used to subscribe to a user's private updates channel in the websocket API. The key is valid for 24 hours.<br />
<br />
<br />
==== Your trade history ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/trades<br />
https://mtgox.com/api/1/BTCEUR/private/trades<br />
<br />
Returns all of your trades in this currency (BTCUSD, BTCEUR . . . ) . Does not include fees.<br />
<br />
==== Your wallet history ====<br />
<br />
https://mtgox.com/api/1/generic/private/wallet/history<br />
<br />
'''README!''' if the above call does not work please use: https://mtgox.com/api/1/generic/wallet/history<br />
<br />
parameters : currency, type, date_start, date_end, trade_id, page<br />
<br />
only the currency parameter is mandatory<br />
<br />
returns a json array with your wallet history<br />
<br />
==== Submit an order ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/order/add<br />
<br />
parameters: <br />
* type (bid|ask) (easier to remember: '''b'''id == '''b'''uy, ask == sell)<br />
* amount_int <amount as int><br />
* price_int <price as int> (can be omitted to place market order)<br />
<br />
submits an order and returns the OID and info about success or error<br />
<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
{<br />
"return": "4c2e69f5-8b35-4171-95a3-9e4088c1586c",<br />
"result": "success"<br />
}</source><br />
<br />
==== Your open orders ====<br />
<br />
https://mtgox.com/api/1/generic/private/orders<br />
<br />
Returns information about your current open orders. Valid order statuses are: pending, executing, post-pending, open, stop, and invalid.<br />
<br />
The order can have 2 amounts, the valid amount and the invalid ( unfunded ) amount.<br />
valid amount and invalid amount will be updated when funds are added or when other orders are removed<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
(<br />
[oid] => 66a115f2-9919-487a-9eba-99a0141c9590<br />
[currency] => USD<br />
[item] => BTC<br />
[type] => ask<br />
[amount] => Array<br />
(<br />
[value] => 1.00000000<br />
[value_int] => 100000000<br />
[display] => 1.00000000 BTC<br />
[display_short] => 1.00 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[valid_amount] => Array<br />
(<br />
[value] => 0.99470000<br />
[value_int] => 99470000<br />
[display] => 0.99470000 BTC<br />
[display_short] => 0.99 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[price] => Array<br />
(<br />
[value] => 10.99489<br />
[value_int] => 1099489<br />
[display] => $10.99489<br />
[display_short] => $10.99<br />
[currency] => USD<br />
)<br />
<br />
[status] => open<br />
[date] => 1344208333<br />
[priority] => 1344208333021535<br />
[actions] => Array<br />
(<br />
)<br />
<br />
[invalid_amount] => Array<br />
(<br />
[value] => 0.00530000<br />
[value_int] => 530000<br />
[display] => 0.00530000 BTC<br />
[display_short] => 0.01 BTC<br />
[currency] => BTC<br />
)<br />
<br />
)<br />
</source><br />
<br />
==== Order result ====<br />
<br />
https://mtgox.com/api/1/generic/private/order/result<br />
<br />
parameters : type ( bid or ask ) and order (the order id)<br />
<br />
returns a json array like this : <br />
<br />
<source lang="javascript"><br />
order_id: '1234234-e9ef-4b75-aa1c-90cd109d24ea',<br />
trades:<br />
[ { trade_id: '1336611143363429',<br />
primary: 'N',<br />
currency: 'USD',<br />
type: 'ask',<br />
properties: 'market,mixed_currency',<br />
item: 'BTC',<br />
amount: [Object],<br />
price: [Object],<br />
date: '2012-05-10 00:52:23' } ],<br />
total_amount:<br />
{ value: '0.01000000',<br />
value_int: '1000000',<br />
display: '0.01000000 BTC',<br />
display_short: '0.01 BTC',<br />
currency: 'BTC' } }</source><br />
<br />
=== Application API ===<br />
<br />
==== HOTP key ====<br />
<br />
https://mtgox.com/api/1/generic/hotp_gen<br />
<br />
used to generate a new HOTP key ( useful for developers )<br />
<br />
==== App activation ====<br />
<br />
https://mtgox.com/api/1/generic/api/activate<br />
<br />
parameters:<br />
* '''key''' - Activation key<br />
* '''name''' - Device name<br />
* '''app''' - App ID<br />
<br />
used in mobile apps to obtain an API key/secret pair. Contact MagicalTux on freenode to obtain an app ID. Activation key comes from the user's account, Settings > Access > Application Access.<br />
<br />
=== Merchant System ===<br />
<br />
==== Order Creation ====<br />
<br />
https://mtgox.com/api/1/generic/private/merchant/order/create<br />
<br />
===== Required Parameters: =====<br />
* '''currency''': ''<currency>''<br />
* '''amount''': ''<amount as float>''<br />
or<br />
* '''amount_int''': ''<amount as int>''<br />
* '''return_success''': ''<string>'' Where to redirect the user on payment success<br />
* '''return_failure''': ''<string>'' Where to redirect the user on cancellation<br />
<br />
===== Optional Parameters: =====<br />
* '''description''': ''<string>'' A small description that will appear on the payment page (defaults to "Payment to <user_login>")<br />
* '''ipn''': ''<string>'' URL that will be called by our services once the payment is complete (more below)<br />
* '''data''': ''<string>'' Custom data returned by the IPN<br />
* '''email''': ''int'' Set to 1 to receive an email for each successful payment<br />
* '''autosell''': ''int'' Set to 1 to automatically sell received bitcoins at market price<br />
* '''multipay''': ''int'' Set to 1 to allow multiple payments on the same transaction ID<br />
* '''instant_only''': ''int'' Set to 1 to only allow MtGox users to pay on this transaction<br />
<br />
===== Returns =====<br />
* '''transaction''': ''<uuid>'' A unique transaction ID<br />
* '''payment_url''': ''<string>'' URL on which to redirect the user<br />
<br />
<br />
==== IPN ====<br />
The IPN (Instant payment notification) is a mechanism that POST data about a successful payment an a custom URL located on your website right after the payment as been validated. It is signed with your API key.<br />
Your website is supposed then to either acknowledge the IPN by returning "[OK]" as is. Anything else will be counted as an error and the system will try sending the IPN back every 30 minutes until it succeed.<br />
<br />
===== Content =====<br />
<br />
The IPN POST data will always contain the following:<br />
* '''id''': ''<uuid>'' The transaction ID generated by the initial call<br />
* '''payment_id''': ''<uuid>'' The payment ID<br />
* '''status''': ''<enum>'' Either '''paid''', '''partial''', '''cancelled''' or '''closed''' (4th one shouldn't happen)<br />
<br />
If the status is '''partial''', the user choose to pay without a MtGox account and bitcoins where detected on the network, we then send you an IPN telling you the amount of bitcoins pending and valid, pending bitcoins have less than 6 confirmations so it is up to you to accept or not the transaction based on that value. Your merchant account will be credited only after the 6 confirmations on our end.<br />
<br />
Additional content of the '''partial''' IPN:<br />
* '''amount_pending''': ''<amount as int>'' The amount still pending confirmations<br />
* '''amount_valid''': ''<amount as int>'' The amount of bitcoins for which we had 6 confirmations<br />
* '''amount_total''': ''<amount as int>'' The total amount, pending and valid, on the payment address<br />
<br />
If the status is '''paid''':<br />
* '''amount''': ''<amount as int>'' The amount paid by the user<br />
* '''currency''': ''<currency>'' The currency used to pay (should always be BTC for now)<br />
* '''method''': ''<enum>'' The payment method, for now MTGOXBTC<br />
* '''date''': ''<date>'' The payment date<br />
<br />
If data was provided in the initial call:<br />
* '''data''': ''<string>'' The data provided when creating the transaction<br />
<br />
===== Signature =====<br />
<br />
IPNs are now signed with the user secret like the original query to prevent fraudulents IPNs<br />
Two headers are added to the request:<br />
* '''HTTP_REST_KEY''': ''<uuid>'' The ReST key used for the query<br />
* '''HTTP_REST_SIGN''': ''<string>'' The IPN signature<br />
<br />
'''HTTP_REST_SIGN''' is a base64 encoded sha512 HMAC of the post data using your ReST secret as a key.<br />
<br />
See below for examples:<br />
<br />
====== PHP ======<br />
<source lang="php"><br />
<?php<br />
<br />
function mtgox_is_valid_ipn() {<br />
$secret = '';<br />
$raw_post_data = file_get_contents("php://input");<br />
$good_sign = hash_hmac('sha512', $raw_post_data, base64_decode($secret), true);<br />
$sign = base64_decode($_SERVER['HTTP_REST_SIGN']);<br />
return ($sign == $good_sign);<br />
}<br />
</source><br />
<br />
==== Dynamic Button ====<br />
<br />
While you can create buttons through the MtGox website, those are generated with the normal API. To display a button with your API transaction, first add the following markup to your page:<br />
<br />
<source lang="html5"><br />
<span class="mtgox" data-id="<txid>" data-amount="<amount>" data-currency="<currency>"><br />
<a href="https://payment.mtgox.com/<txid>"><br />
<img src="https://payment.mtgox.com/img/mtgox-checkout.png" border="0" /><br />
</a><br />
</span><br />
<!-- You only need the following tag once on the page, after all the buttons (for example on the last line before closing the <body> tag) --><br />
<![if !IE]><script type="text/javascript" src="https://payment.mtgox.com/js/button.min.js"></script><![endif]><br />
</source><br />
<br />
Make sure to change '''<txid>''', '''<amount>''' and '''<currency>''' to whatever value apply to that transaction.<br />
<br />
== Examples ==<br />
<br />
=== Goxcli ===<br />
best example of all, using nearly all the API methods, works as an intereactive shell and as a shell API so you can build your own app on top of it : <br />
<br />
python : https://github.com/Trasp/GoxCLI<br />
<br />
=== bitcoin_dealer (trading script) ===<br />
<br />
python (django) : https://github.com/rokj/bitcoin_dealer<br />
<br />
=== magento mtgox ===<br />
<br />
magento ( php ) module : https://github.com/MtGox/magento<br />
<br />
=== XChange ===<br />
<br />
XChange (Java) API : https://github.com/timmolter/XChange<br />
<br />
==See Also==<br />
<br />
* [[MtGox/API/Streaming]]</div>Nederhoedhttps://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v1&diff=31792MtGox/API/HTTP/v12012-10-14T18:33:48Z<p>Nederhoed: /* send_simple */</p>
<hr />
<div>'''Note: All API methods require a valid User-Agent header.'''<br />
<br />
== HTTP API version 1 methods ==<br />
<br />
=== public information ===<br />
<br />
==== Multi Currency Ticker ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/ticker<br />
https://mtgox.com/api/1/BTCEUR/ticker<br />
<br />
returns the current ticker for the selected currency :<br />
<br />
<source lang="php"><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"high": {"value":"5.70653","value_int":"570653","display":"$5.70653","currency":"USD"},<br />
"low": {"value":"5.4145","value_int":"541450","display":"$5.41450","currency":"USD"},<br />
"avg": {"value":"5.561119626","value_int":"556112","display":"$5.56112","currency":"USD"},<br />
"vwap": {"value":"5.610480461","value_int":"561048","display":"$5.61048","currency":"USD"},<br />
"vol":<br />
{<br />
"value":"55829.58960346",<br />
"value_int":"5582958960346",<br />
"display":"55,829.58960346\u00a0BTC",<br />
"currency":"BTC"<br />
},<br />
"last_all":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_local":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_orig":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"buy":{"value":"5.53587","value_int":"553587","display":"$5.53587","currency":"USD"},<br />
"sell":{"value":"5.56031","value_int":"556031","display":"$5.56031","currency":"USD"}<br />
}<br />
</source><br />
<br />
'''note about prices:'''<br />
<br />
* last_local include only the last trade in the selected currency<br />
* last_all is the last trade in ANY currency, converted to your currency<br />
* last_orig include data of the original last trade ( currency,price in currency . . . ),<br />
* last is always the same as last_all<br />
<br />
==== Multi Currency depth ====<br />
<br />
https://mtgox.com/api/1/BTCPLN/depth?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/depth?raw<br />
<br />
==== Multi currency trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCPLN/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/trades?raw<br />
<br />
to get only the trades since a given trade id, you can add the parameter since=<trade_id><br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?since=0<br />
<br />
https://mtgox.com/api/1/BTCEUR/trades?since=1316312781670700<br />
<br />
For multi currency,also returns the primary value,"Y" or "N", the primary currency is always the buyers currency<br />
<br />
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y<br />
<br />
Each trade is described by a JSON structure like the following: <br />
<source lang="php"><br />
{<br />
"date":1316312781,<br />
"price":"3.5599",<br />
"amount":"3.6900096",<br />
"price_int":"355990",<br />
"amount_int":"369000960",<br />
"tid":"1316312781670700",<br />
"price_currency":"EUR",<br />
"item":"BTC",<br />
"trade_type":"bid",<br />
"primary":"Y",<br />
"properties":"limit,mixed_currency"<br />
}<br />
</source><br />
<br />
The meaning of each field is as follows:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value<br />
|-<br />
| amount || the traded amount in item (BTC), float, deprecated<br />
|-<br />
| amount_int || the traded amount * 1E8<br />
|-<br />
| date || unix timestamp of trade<br />
|-<br />
| item || What was this trade about<br />
|-<br />
| price || price per unit, float, deprecated<br />
|-<br />
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)<br />
|-<br />
| price_currency || currency in which trade was completed<br />
|-<br />
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)<br />
|-<br />
| trade_type || Did this trade result from the execution of a bid or a ask?<br />
|-<br />
|}<br />
<br />
<br />
==== Cancelled Trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/cancelledtrades<br />
<br />
returns a list of all the cancelled trades this last month, list of trade ids in json format .<br />
<br />
==== Full Depth ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/fulldepth<br />
<br />
returns full depth<br />
<br />
WARNING : since this is a big download, there is a rate limit on how often you can get it, limit your requests to 5 / hour or you could be dropped / banned.<br />
<br />
==== transaction information ====<br />
https://mtgox.com/api/1/generic/bitcoin/tx_details?hash=4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0<br />
<br />
will return :<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"hash":"4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0",<br />
"blocks":["000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7"],<br />
"version":"1",<br />
"size":"1158",<br />
"in":<br />
[{<br />
"n":"0",<br />
"prev_out_hash":"4578576f49418e69da6d7a1166168bb80a94682f21cca518b6c2451bc64bf858",<br />
"prev_out_n":"1",<br />
"coinbase":null,<br />
"scriptsig":"304402201d7eaf891bcda16ea2979694c02e590fea8fc43dc092ee60e5fb2dd756bcb19502205c5be31b772029700d0a43d499932e9c321af1cfbc8745fba6dbbe48fa79bbb501 043a264aac55e23f83b29ac7e7a914584d2aa6c2eb08ea05405f5efc38473183ca4fc075f8144bb78698df1a5be6f4057f1bccc9e1217a5658946bcc4d4f6972c3",<br />
"addr":"46f740cb9c737111ec91ec235f6877055be7175e"<br />
},<br />
{<br />
"n":"1",<br />
"prev_out_hash":"4feea511029896ff4c31132346a79594fcd0c4e60aab2fa4f527e1395d375488",<br />
"prev_out_n":"0",<br />
"coinbase":null,<br />
"scriptsig":"3046022100f3bc0445f629e4e896ced23013d89ba6e6488a6ec21c47df608aaf6d6d212fbb022100d321c4c7f5f33900b8c0efba8ff58a3541e621588f402e167f51968b6ee0bbf201 042157f97a8a78caf6315dbd6d9267b9edd9c1c37cdb211f2bc03703a28eeebaf274efdcff4ef3e3ef4a6b7ccb5d8c17acba941d1a5669c3299f22a0e78e702fdb","addr":"7b0a72820f6e92ccc384dbdecb5584d855ce9416"},<br />
<br />
{<br />
"n":"2","prev_out_hash":"9adadb88c3075afdce1216b35d27fd5cac9736ce3977778999f9a85105d2ea8f","prev_out_n":"0","coinbase":null,"scriptsig":"3046022100d63237cca9bf2200c6aa255834e06f9dc5e4e20f1ea7e6678119bb0e4a5a109f022100db37ec795336509fb3a16d1acebfe08523d95e177284149614a6d3384286b27c01 04b16b41dab16cfbf59f1713559795440b98b384dc01656ebaceeec8f6d1463802cb474062b2b8c1de53ab1fe65be0f6213dd61519044e9c1f50291b915fc7fc6e","addr":"2ed7c49f080e9898737276ad802e2067a1d06ab7"},<br />
{<br />
"n":"3","prev_out_hash":"0e2ed4e4db87ddc9cb54ab3cdcae59762293815d3093c238e42d33248b39e19d","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100ab501414e7643cc1a78645f544cbcf6411e71e0c21953cd51f7f9933a50538a002201b4c9bac60aa19d659d0686d45bf06c4928c4446269692d88722f57624cdaf1401 048e1e4862c6fee7293f6c7be43a72a375e68395398e4d5da3db06199a35fc46cf51b87f3c6b87caeb81181d630706e23b5679ae8b96ca36701282ae5b49dd99c9","addr":"c74d2e95aeb037297c7b6a232d78c715fa1ab826"},<br />
{<br />
"n":"4","prev_out_hash":"93c912462daa2a52e108e3424596d56fe2a136d6707a65b6423dee229e317ea1","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100fe782441b8788ed9297c8fea735701ae0a77081fc748ceee8cde945107f64967022014d51d5bc8d8138b97a657eda6d03ba998810e3e941988da90b82f6d24d8471e01 045f53cf2dbdb3213084efa69ac1dfcd8d97be8073a8b8104feb000513aa048b653f400d23314fc090456078f46a0fc9daabdee57f1ef14c2111b9ddc35255189a","addr":"958bba83ac42ebf055c1724b25bfe5c698abbb51"},<br />
{<br />
"n":"5","prev_out_hash":"44a1b493ef6176cced4c02fb97a227b98e5bea0616d9cdd6005bcd6905d667f3","prev_out_n":"1","coinbase":null,"scriptsig":"30440220132484ad901567d2c52c0b4f3be5263d1d8ed6e76be1398d2bb7c2a1aec5f748022033b907afa05eb075dee9993b8a05c9e40c69e53d65a06cc8a975ff4c4407141e01 04bd5d7feb1884efdccbe8feb8fa9ff57d56272ac5f667bc59cb07a232fbbd9cbabdf54b6bb6ca4c77e0de22cb0f896fa6183e53381861641049f0edee2d64cfe5","addr":"3784c102bbfd34cc7fb6e12c51b5c6177592f267"}],<br />
"out":[{"n":"0",<br />
"value":<br />
{"value":"0.01000712","value_int":"1000712","display":"0.01000712\u00a0BTC","display_short":"0.01\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 6427f36ed6e5a0cb526a0b0bef1335992326e9a9 OP_EQUALVERIFY OP_CHECKSIG","addr":"6427f36ed6e5a0cb526a0b0bef1335992326e9a9","claimed":"N"},{"n":"1","value":{"value":"3.31674208","value_int":"331674208","display":"3.31674208\u00a0BTC","display_short":"3.32\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 1f27d1fc284143729944ab89823111d2bb63dc46 OP_EQUALVERIFY OP_CHECKSIG","addr":"1f27d1fc284143729944ab89823111d2bb63dc46","claimed":"N"}]<br />
}<br />
}<br />
</code><br />
<br />
<br />
<br />
==== block information ====<br />
block information can be accessed by depth ( the block number ) :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?depth=188111<br />
<br />
or by hash :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?hash=000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7<br />
<br />
both will return ( for block 188111 ) <br />
<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"info": <br />
{<br />
"hash":"000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7",<br />
"parent":"00000000000005adbcc9846f9f3542f9349b19a3c8a8f8149a830e8d748b0c92",<br />
"depth":"188111",<br />
"mrkl_root":"772b7dcc99c98a9d77e40e2ea300ba492254dea5439599f666c77bd5be1f3b4b",<br />
"stamp":"2012-07-08 12:03:12",<br />
"size":"76898",<br />
"status":"confirmed"<br />
},<br />
"txs":["020d258be19e6b399301acca1857ceb13adf643edbc660942d7eacc3290bdf55","0575fb1c09f86de21bdb00bb1423053e5ee667158ad50aa0043e82bdb3d21a1e","07830422f821fcd63e316411c883486161f15154ba27b4fffbd934fe02423020","07a6cdf84e5b5aec5f3ec968a36a469e2923237254c31adf8cc895f4d47dbd0c","0af35c993e0094010a73d48bded49ea1c7f5d26a1d80fb1ddd2fada39f725656","0b5a4340a8daa28832c4ea7baa463b896fe954bca50bcfaa2671947725c103bb","0c5adc9fb24a3daa80fe0e2ed6c6b35ee0cb70e3aa6da42276e04fd2132ee4a3","0d28cea45a0a90ac105777d1d53318d23be489416aded7bcc1c92ed2f7426358","0f05493623804d9ad4501521c893fb186cbb03e41962bbd42a10bf6c89f60026","0f627402384a9c88ec878b6d7e3866f88d8c91295c7a3f595a50f32af3a962e9","100f488d2822b1e50ef6b7a885fc576a610b2aa5d36c660c6b000555f5edb182","12d1cdcd17cfbccfd5184543c9edc5a18c3add089c76afa33c0da72001fcd2ea","144516c54e56e3c9a049995fd402dd4749eb7bf4276c247c598f67ea126c1ef0","158be63da6a97dcb7ac2286ae148ba0bbee62d4eb3be9423e0de84337c67cef1","175a4c4708a6237bdde8cc355487c1b85f61915d1336fb9ec1216946ed949efe","180a9901550e68c552fab07b23788bf424636ef899a73313c9dde8e00757acd9","186d0632a342d20e97a612e2ef6c60b74af278678e2221a5c043bb8bac683f73","19cf092b8657d0da33ef97c628469bfa0e87f564327629311881e8ef4cbe203c","21a79eeaab53234b1017689fcf13894154d3a9083d10feeec9096b2bd5135649","222e59465dae7866897b9a750cddb3924e775637944d3ec6dd1cd0f81bd9f36b","23e28db3cb8dc658d010eb7b3ed9f4ac0ae3be4049bad0d557c2a7446954d185","2426cb2d1fd6958c1830f98aa54bd9ee86fd3325cb13b1e9aeeb2901f481b38f","2528e80141db0f5a09f6d8ded3ba06427476256a70442a7df51fe3c2686bef64","256e754aa2829469cf575b121eb4abb7f6a1f0aeee6f221bfd14a5e0b0ca9baf","25fd783b5cdcb1e1769092a007103556bc3d5d419b5d5ba9ef6e7400a5e0caa7","268fa8738fe708161071624d3143475a7a26f7ccf8dd031c91861a3dd59d3eee","2801207fb1b50f1d60324b7a790da36c244875de7b0329fe1be53439e74d9553","2826f91a4664031f5ed7239bddc11fe746b63e1c5d70bbe043ffb62e966a2c01","28d4fcec098886db460d300d9a62be49c31ddbd1cdaa203a5fbdf8021eba22b6","2ada3f324802d7ad3dfa7d5ff24e888c3919cb8e7ba1050f59cc814ccc6c7f41","2cdce29d3ef98062d36e63d150e203737f1374f43e8a1b36eea08286450e5e24","2ce5579a4c205761779668232c685eb0c0974f0328daa073bafec2119afba906","2d1928299d04653351d2358885e51a981f227d9ac8eaae34437b63eff8f4b28c","2e5686a497efdda63de8c5aa23fd349f3004a31ccebc6b3954de06669b3dfe9c","2ecc8f682cb7e65802072bf311cdb9f87e25cf34ab3f0f475c16169040b3c654","335ab9791c80ab80ccbf55e6829ad3c67a6b48426769b9bd7b3d866233ad912b","34bf38fb8bb1e74d1570e4e357bf2c9af3956917bf3f49ee3a5a9bd9e89e174c","351835329ddecfd75c74fd82b207a6f1481394321b3c3613e71dad74654a59ee","38f67149f684713e8271b2f709c125c365cc0ae97c740d0e4a07822f71f3b640","39ddb42041f0ba3c7d87c2d5e74a633a1907f188b57569b2641c77fed674fe0a","3bdb7e7e5d8b7b4dc37fb961272819eeee0da9854657318503be4397567497c4","42d2e9a1a1650d58c21ebcb14eef6da5b248b43c96e1bca816baee4c73978650","42dba17d47c259559dc9a5a110457196ccae97447f2b9e6056fd96e471e09715","43a262b3cc7b2899b166ddf06d37fd4600b2348342514d8646a76c454b4772d0","4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0","44adb50a8c3096a079c5fef9dfaae479b2f2804e09106097d480a8c1b0672da1","44b4dce02cbd628e8f88bf7ca36f650db866b16c5a79b3cb6f6b24bcffb1c089","489ef413e51bcbd23a4134c366f2537d99ea81913af43627dcab4ccfd611d1df","49d2a512f63481a42ad30a1b3845fc2929296945519c0998dad4fa361064765a","4d5372c14355d789decb0e100fb05e86f6b854d0187815b60a1b37de41ca245a","4db9e6cc810918143fba3dfe8cc3030847b8297775dee7540ca03fbb0c8788c0","531bfa06d7164dc5cb971e3fe90aefd61c188a5d292350a2cfc12cd8bac760f6","553341c3683a9ccabe10fbb65334a694bab2469fa444570e51d81b7d416414f8","5592b28d4a6f652fce290e1502a6204ad501ec5759438c59209f29bd9e80f972","573b1dee0b00b1936d8e8b4f1f45e47c246d7be09b0573281bdbb0b71035841e","5767fe6251014d97a2f14e1226ae08b11065f78b7f52a390bda3eb87cf63e9d5","588c8e0d458ee5516468d4f0f68711757bd4e291e6456be8e3fde1fa9c6e72c9","59f3d51b41f346c08fb73be2a540ebc2aeffb2220da5c2e5d927b74a5249c907","59fb156e2e6b901524a7b7fe906db455f014deb361096db937db5be952490b36","5c2c78de645d59a57500e0a3ba19d91ff8dc902a6d75c16512d013449a74957c","5da0e429c410ce6220f7206e6ee41f0fc8216000908b3d8eeb651345fb5e7435","5eebfbda3754fc240d1b87806cf57c0f6805eee3cbf8b0c29f8da96017ddbc1f","5f6d93830779e69b1a9e44ceb81fe42ddbc1b453014548b44b348d5e979f98cc","601f57984bead5aa7767885e2d01e9d24582c1c7a2f7e907b70b76bf773726d3","60ae2132f0864e3700db8b6a30ee7e4d7e7479798c5ce14df23a7935016b2eac","67177915a8a163c49f0cfe7f12a065e24046d8b32ee4b6b5071954c12f9f8173","67398f5c224a83debf5455b5caa6976249d35344a3b4f39700cda11569494203","68d1bfff53204d0eeadb35540ddcb43ad2c7aaa9ff647052ab4f2d66f3094e8d","6962015317f58edbed7b8725f344a25fb7d8dfca743715558d916cf1a8b32b24","6ab7e2e0c7749ea166968629f584c2be8687667fdf6861d53368c944e10eda3a","6b11cbd800814e5d86afcd3daf56fed4e8f987007ff4ab835a05e6de470f35ff","6ba15ceea3a22c3a8b3539c1124a4d641409a680db07af35e35d73da877e8da4","6c41c14638745ca2b820153386fd95948d8bf048750328cd397d05241ebec08c","6f3e68f9b4d007249b4585b0760e2b892a7f6b8fd2ef568e93856da20d96ebe4","702a98c7b9a4cccce628ea40ec94f9663c9f3163190c18c0d5011fae44f50a7c","7084504bf52356da59c8ca8e96c6cb4d2d85f10ae4c02fa74b50e26c6b8467a0","737e38e017b1a9308ea2264c8c4e9bba612ffba3fb44de505f3e479ea1d572a4","75b3d2188033c8e2a9f5aed17cd80c71d5599f9af23ed36a9561bdc3a15fec04","76b16f3014b25107d0b88172c2913980948c9bc8c68132ea424c54c00e7858d5","77141d625b4521eeab882b79e217cfe19cf8e74a757729152bf60ee5a70071fc","7b309dc1e54d784f3772631dc4b01f5dc414904d21f77905c9f6d70bf8423d67","7b4a63bc061f7e95461631e58aaf96314591ae0fb0feef90ecc31003824eb66b","7b7a0136f2fc529018f0568a21bcb73996375ed9eb2c627846b28f5b09095a0d","7d00ff77f0f12ab7799ed571bcb438df230135e26796cc4b984908103beae847","801314902f70f8939fef64267687d2bb95c333a62464ee5db76b88aed8b9d360","80757f7f5a5ecd47e64cd5299442038b7922d15d5c303d2a950deac204b7807e","836bea75b79376c547544b06298cd3fb3f5974641b3ceb77eaba687e19e2cec4","86d5cf06b40acdf96215db8a767df3e1fd2c8e4641007e8ee5c6f8bd9b47f3ea","8a4f4d6acdf5d875e2ae14cc17becbb45072c7229a864b3fa1cdc80b45d80597","8ab04f7f610a17d08613fca7d79dde9fb5817904e1055bd6b8eb574e9531ff5b","8b1dd8aa0b6272770d2491d35944fb9b3d3169c72e8275ef2411b801fed1785a","8c7695f70007d17fbdcbcbeb921837b2c5ef3469c27ca65ef3e75e0634e06357","8ccf0173e0006b65019d4b2634f824c69883f8bb6ab3670eff36183df45d437a","8cedf02ad54c94948e69c69dacf8b5f94d6a20b156f112b79b635610b9abccfd","8e0e0aa6ae3df684489ef41c6c65e5c9fb9d72d2aa455b2453a6495ab45aa29b","9059fb2f4ddb94bfe924c3c009e1e1cd8da53513c9ec1a1aa7e20c2376274dd5","911766a8e660a973180d306aa95fe2b9037f37db28cf166e59aaf986ec72608e","95bd4211a0fdb9c028c1b7f694b72ab8222ead20d0f83edd7288ef19105208f8","971e6feb86d955f9aa194e25c596499b5ab5683c68766877b14eacaa86ed6836","993fcab01aa5882308af5b870c0a191884ff4ecdb8cee964ad58e96781763d65","9af2c6bb2897847bf8ebb71ee600c810354bdf8aa78ad8aab864ba89be3aae0a","9b4d84991e2dd181570dd4f5d18e533c57252ec8ddb6642c990386e8cd57cbd7","a05b2c1547f8513ded94425763b6f34cf3019e7f649163d31fd8fec770950fd4","a36f43271195cf031b2a0e3df297a206088a11c3f03cc4ec255721c017825140","a3825df57a7f4d6e3f204d35d1b58f24d0a89dece8c8e8cf277fbad2283eaf0e","a3a6ccc3af9becf7135b58798e5190251c8499171681b3c2c1110dd0cb1ca0f2","a3dbbdbe58586d5917828a058b37e471e15d6a42688397e93888d6ce58025a55","a48a185b6d50ae91a94b571bb43f173102a172cd886649bbe1563c875ca2142a","a4b7d03a4af6e2225902e026adb2e265e07a10a8a062a49aad2f544fd7c900f8","a6de57825868deebdb57a405c7f9085f21a249ea9d36bf1c18e9c709280523dc","a7a9eb9c044a5fc5e27bc9ba533b794543e154c2081266988e2ca07e37380787","a92d2d46d0d65e3ea05b68ab16b32bed760fa2955c9f6b9f91687e429724524c","a9c2cff9357c003de5e6498e0af52ad8f24778fd18ca274fd135a7dbb4464a8a","aa1d22c31d4dc4114888bccbd7110a1f777887ed8dd2dfa006eaaeeac58d2a44","aa313832f108aecbfae05acab011d40ff1d1ec540cd2025851dcc10d92bcd0c3","abbcfbdc79d0536344295d6e0cd6d7ae788a385836c33c7ef7f98f6064ad2ee1","ac3a732c65504a9f4e728cbaf80d4d58f74a3834138a224657eebd03982c1898","ac6eb25fa5be2a1d1418879791cadf43b1a268cb3aa2e505977cb29e4b7035dd","adec207d59a23cfc8afc63b0e45bfdefde9b7ffe74515872f0837025530ab6eb","ae1584bf163b05c014d0d99715f481655949c7762d800997562fc93f3da731b8","b1403965758e40e9d2eb31950f97dc599368edeb98541ede8df2b512ef2fd3bf","b3c086e90eda12260b5bfe8eff16a051882dfd921c02140194c0e0ee9a849466","b4062fe2f07abe03e2e9b88b571c7f2d9c058c78fb157d3d04fa39feda380a02","b416514b63420449c6c56781adafff18f6f28733aeb2fb4bb0c1abeadbd6db6e","b7bfbbc5fad15123960443cb0c118162a62a4b92732a8365eeb77e8df25eca46","b871fea4a33e5e51ff648ca74d16a34f179d3467805cad84238c729282e8acf7","b878eaf74341fbc65c609785b93b38d90f841f2d50bb39496e1f4b1b34b2255d","b9a80691e7d9423ad546a96363a017a4a0725dc854de082d6927da6cd6aa19c2","ba7ef3d90be2bc57c785f55457971ff0812a4d9b9df18ab980229ce648cee31d","ba8669e2e19c21a0045d994c56e811b2d1d51451ab248e76df456427d0d20569","bc260c6b49fe06a331202a2b703cb051aa352d17a8373496dd5ef67ab404a145","bd260517b438daa35921cca54b8c2dcd48b8ca338f7166d91ecd3a3eb14c9d7f","be375723b763ea3e88f9539eebd1f73f8af0b463b7bb88781dc3f589ab36e9ad","c0c4c3b3cd1b400b81316dd67001b92a512569dadd0ed6f783e87e601c8ea54e","c156c12f1256b4a2a6c0558b7094e263876586e4a72333da2997fb97cbb8d15d","c2a5f97fa1daf09015fa78a57b2aed1d33b9c18ffb84bb7f3d0e8d643532b772","c54d091b9d006ed79405b62defa7910a7ab9db6463f46ab1c50064df152aa887","c5a7a5ed8e2b4e72ca8c72025e91e14388ee23c7822c16bd3fe3b11c206ffb84","c5b5f35b88138f27b6aa2395f423d15dbf642258971102de77359ff79eb8d4cb","ca52540a211bac9449b45662ac2a6a00899bf55b5867017ab73b1973ef3a8f6c","cc6f6ad1f5a023bb52f7638f883d4bf20dab6bd3a0b1b9a3c8526fc99aee81d2","cef0df2d68b4f38fd9ce501839e3d4d2a40317d845037baa2b7ffb3ed45918c1","cfd0806446352b03d89be45f1014c0a48728286c5b12fc89d32a3cb31896765d","d03fe289cf120bdb3ae70711da1c8972f650fb8e5c4f91dabf17639a2c7ecb06","d1089a3f2e4f0d043eec44395a5522f107fc649ca561f76013d412c85710c306","d1a68d6cf85c32a15011cd13b374ab8aad619b1b437ffd262c446cc079babedc","d4201c9a33e19e2ba351ec288ec5a43f4b3f2cb133d6a7977f72c529d3e03408","d5991156ebb5beeac70ac0cfc1706990be5752b41bafbe31228053fe18dc3e67","d86adacb713cc4ecf06828aeb2b8e1bb0311144986978c59240ce996214ab69f","dab5fe0369dca967e09653cb0475e09636091ba0a6ee95289de49fe97e505f3d","db0ee162bc04083d6caed8a88a7be44b02d15b2686a2d6dd06a10d024cefb40d","dc453efc8162dbff08e04fdda7a5dcbd986ee0fbee547764ff7ae89afe68806b","dc5e2a39f8e1ce90f88c3f50076ed03188fc60e87b103a0d48e66fe462b7777f","df826a504bad73ab69fcd740f72e6e00488e69db8ec31a55ffb3ed43b0845cba","e05d71cfe0b356b0dddee437f9da2610f85c5dffedc3ab058172ab71624a7d14","e10fb8c50f8e378b43f4f80b41e62b78dc968496196ae8399fa7d203e213a3cd","e5b9be11e940019582c6ac0875f54e7bc92fd15149cecf4e1bf67d4357010cce","e7a64e4c08350ee2f0ecc3af4c2df7388da044de4f7955a941ff965a925b54b8","e84b2c1129b574a485dfa7d8843cf569b3679f234b681f6f8fa0d88d5489b224","e8df3c1953e9c32ae77bbf01dcec48e1052271e0eb6d556da9deda1c50426231","ec46f3be50d9f2f6472669b8c8e38addd54c00bc206c81e873f340c0a11d71f2","eca4fdc50f34ccf5e0b459b0a077ec9033cf25c58e29b3406f24eab6445a6221","edc7488d9f86de7d094c1d02119680b91a15a28cf7a8b09cf9cf194193ae81bc","ee4b82dc8f11c5459a42090c1aafaf645f2c1d247edec1d9b0fae46f4efaa02f","f03f924d1767b748f8fc15bcef798076e746a7917f5fc7b89e2ed022c95faa82","f104ccccf3bc11107b27900670f36de7fdda3a0a7d086d2dc69b4903aa2cbcd5","f18d25a1fabd8f3a62edb164c759b650c13c320f2edc7cab44c01ae88809b285","f2a1ff85c3ac02574d1f55b067c841ea4b0283ed9543f11752fa41723b315ed9","f46a661429090548bfe775c5df5197b0cf6ae5d38a215986b79de385b52d4223","f5d19ba9a4a11db479fd80aea1674eb896f515fd43f34c456b09f49500ecd4b7","f629a172edcac21d929169f2bb1dcf148110151b769bae15e4fc09bd72898fd2","f6d1ca49cea130563f72f266612eb901c9290b3bf36fd4218d5881c5c9d7d35f","f79f17ff115716f428034aa9181d63e67649404559448193fb6c96f35cad3e00","ff0e08dd175e3badf556ea843a972edea4c80f461cfdabbfdb69167ba3845055"]<br />
}<br />
}<br />
</code><br />
<br />
==== address information ====<br />
https://mtgox.com/api/1/generic/bitcoin/addr_details?hash=1f27d1fc284143729944ab89823111d2bb63dc46<br />
<br />
<br />
==== Order lag ====<br />
<br />
https://mtgox.com/api/1/generic/order/lag<br />
<br />
The "lag" value is the age in microseconds of the oldest order pending execution<br />
If it's too large it means the engine is busy, and the depth is probably not reliable<br />
<br />
==== Currency information ====<br />
<br />
https://mtgox.com/api/1/generic/currency<br />
<br />
pass parameter ?currency=<currency_symbol><br />
<br />
returns information about a currency ( number of decimals . . . )<br />
<br />
=== Private API ===<br />
<br />
==== Private info ====<br />
<br />
https://mtgox.com/api/1/generic/private/info<br />
<br />
returns information about your account, funds, fees, API privileges, withdraw limits . . .<br />
<br />
==== get a bitcoin deposit address ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/address<br />
<br />
get a bitcoin address linked to your account.<br />
the returned address can be used to deposit bitcoins in your mtgox account<br />
<br />
<source lang="javascript"><br />
result: <br />
{<br />
"return": <br />
{"addr": "18dGNs5Bd6pPMuSchLHQtb1k996YpUHs3j"},<br />
"result": "success"<br />
}<br />
}<br />
</source><br />
<br />
optional parameters : <br />
<br />
description : a description for the address , a new description will generate a new address<br />
<br />
ipn : an URL that will be pinged when this new address receives a transaction, the ping is a POST request with txid, blockid, description . . . as parameters<br />
<br />
==== redeem a private key ====<br />
<br />
https://mtgox.com/api/1/generic/private/bitcoin/addpriv<br />
<br />
allows you to add a private key to your account<br />
<br />
* parameters : <br />
"key":code<br />
"keytype":"auto"<br />
"description":description<br />
<br />
* returns the btc adress and the total number of btcs in this private key<br />
<br />
==== redeem a wallet.dat ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/wallet_add<br />
<br />
allows you to add a wallet.dat file to your account<br />
<br />
* parameters : <br />
"wallet": the file content of a wallet.dat file ( base64 encoded )<br />
"description": optional parameter to add a description linked to this wallet in the account history<br />
<br />
* returns : "amount" ( total number of btcs in this wallet ) + count ( number of bitcoin addresses in this wallet )<br />
<br />
==== Withdraw bitcoins ====<br />
https://mtgox.com/api/1/generic/bitcoin/send_simple<br />
<br />
Withdraw bitcoins from your account to a given bitcoin address.<br />
<br />
Parameters:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value !! Example<br />
|-<br />
| group1 || || ''"BTC"''<br />
|-<br />
| btca || Bitcoin address || <code>18ytF1DH13LYEmBGREr47bNXNe6oH9ygzj</code><br />
|-<br />
| amount_int || the traded amount * 1E8 || 123000000<br />
|-<br />
| amount || amount of bitcoins as float, '''''deprecated'''''|| 1.23<br />
|-<br />
|}<br />
<br />
==== idKey ====<br />
<br />
https://mtgox.com/api/1/generic/private/idkey<br />
<br />
Returns the idKey used to subscribe to a user's private updates channel in the websocket API. The key is valid for 24 hours.<br />
<br />
<br />
==== Your trade history ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/trades<br />
https://mtgox.com/api/1/BTCEUR/private/trades<br />
<br />
Returns all of your trades in this currency (BTCUSD, BTCEUR . . . ) . Does not include fees.<br />
<br />
==== Your wallet history ====<br />
<br />
https://mtgox.com/api/1/generic/private/wallet/history<br />
<br />
'''README!''' if the above call does not work please use: https://mtgox.com/api/1/generic/wallet/history<br />
<br />
parameters : currency, type, date_start, date_end, trade_id, page<br />
<br />
only the currency parameter is mandatory<br />
<br />
returns a json array with your wallet history<br />
<br />
==== Submit an order ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/order/add<br />
<br />
parameters: <br />
* type (bid|ask) (easier to remember: '''b'''id == '''b'''uy, ask == sell)<br />
* amount_int <amount as int><br />
* price_int <price as int> (can be omitted to place market order)<br />
<br />
submits an order and returns the OID and info about success or error<br />
<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
{<br />
"return": "4c2e69f5-8b35-4171-95a3-9e4088c1586c",<br />
"result": "success"<br />
}</source><br />
<br />
==== Your open orders ====<br />
<br />
https://mtgox.com/api/1/generic/private/orders<br />
<br />
Returns information about your current open orders. Valid order statuses are: pending, executing, post-pending, open, stop, and invalid.<br />
<br />
The order can have 2 amounts, the valid amount and the invalid ( unfunded ) amount.<br />
valid amount and invalid amount will be updated when funds are added or when other orders are removed<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
(<br />
[oid] => 66a115f2-9919-487a-9eba-99a0141c9590<br />
[currency] => USD<br />
[item] => BTC<br />
[type] => ask<br />
[amount] => Array<br />
(<br />
[value] => 1.00000000<br />
[value_int] => 100000000<br />
[display] => 1.00000000 BTC<br />
[display_short] => 1.00 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[valid_amount] => Array<br />
(<br />
[value] => 0.99470000<br />
[value_int] => 99470000<br />
[display] => 0.99470000 BTC<br />
[display_short] => 0.99 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[price] => Array<br />
(<br />
[value] => 10.99489<br />
[value_int] => 1099489<br />
[display] => $10.99489<br />
[display_short] => $10.99<br />
[currency] => USD<br />
)<br />
<br />
[status] => open<br />
[date] => 1344208333<br />
[priority] => 1344208333021535<br />
[actions] => Array<br />
(<br />
)<br />
<br />
[invalid_amount] => Array<br />
(<br />
[value] => 0.00530000<br />
[value_int] => 530000<br />
[display] => 0.00530000 BTC<br />
[display_short] => 0.01 BTC<br />
[currency] => BTC<br />
)<br />
<br />
)<br />
</source><br />
<br />
==== Order result ====<br />
<br />
https://mtgox.com/api/1/generic/private/order/result<br />
<br />
parameters : type ( bid or ask ) and order (the order id)<br />
<br />
returns a json array like this : <br />
<br />
<source lang="javascript"><br />
order_id: '1234234-e9ef-4b75-aa1c-90cd109d24ea',<br />
trades:<br />
[ { trade_id: '1336611143363429',<br />
primary: 'N',<br />
currency: 'USD',<br />
type: 'ask',<br />
properties: 'market,mixed_currency',<br />
item: 'BTC',<br />
amount: [Object],<br />
price: [Object],<br />
date: '2012-05-10 00:52:23' } ],<br />
total_amount:<br />
{ value: '0.01000000',<br />
value_int: '1000000',<br />
display: '0.01000000 BTC',<br />
display_short: '0.01 BTC',<br />
currency: 'BTC' } }</source><br />
<br />
=== Application API ===<br />
<br />
==== HOTP key ====<br />
<br />
https://mtgox.com/api/1/generic/hotp_gen<br />
<br />
used to generate a new HOTP key ( useful for developers )<br />
<br />
==== App activation ====<br />
<br />
https://mtgox.com/api/1/generic/api/activate<br />
<br />
parameters:<br />
* '''key''' - Activation key<br />
* '''name''' - Device name<br />
* '''app''' - App ID<br />
<br />
used in mobile apps to obtain an API key/secret pair. Contact MagicalTux on freenode to obtain an app ID. Activation key comes from the user's account, Settings > Access > Application Access.<br />
<br />
=== Merchant System ===<br />
<br />
==== Order Creation ====<br />
<br />
https://mtgox.com/api/1/generic/private/merchant/order/create<br />
<br />
===== Required Parameters: =====<br />
* '''currency''': ''<currency>''<br />
* '''amount''': ''<amount as float>''<br />
or<br />
* '''amount_int''': ''<amount as int>''<br />
* '''return_success''': ''<string>'' Where to redirect the user on payment success<br />
* '''return_failure''': ''<string>'' Where to redirect the user on cancellation<br />
<br />
===== Optional Parameters: =====<br />
* '''description''': ''<string>'' A small description that will appear on the payment page (defaults to "Payment to <user_login>")<br />
* '''ipn''': ''<string>'' URL that will be called by our services once the payment is complete (more below)<br />
* '''data''': ''<string>'' Custom data returned by the IPN<br />
* '''email''': ''int'' Set to 1 to receive an email for each successful payment<br />
* '''autosell''': ''int'' Set to 1 to automatically sell received bitcoins at market price<br />
* '''multipay''': ''int'' Set to 1 to allow multiple payments on the same transaction ID<br />
* '''instant_only''': ''int'' Set to 1 to only allow MtGox users to pay on this transaction<br />
<br />
===== Returns =====<br />
* '''transaction''': ''<uuid>'' A unique transaction ID<br />
* '''payment_url''': ''<string>'' URL on which to redirect the user<br />
<br />
<br />
==== IPN ====<br />
The IPN (Instant payment notification) is a mechanism that POST data about a successful payment an a custom URL located on your website right after the payment as been validated. It is signed with your API key.<br />
Your website is supposed then to either acknowledge the IPN by returning "[OK]" as is. Anything else will be counted as an error and the system will try sending the IPN back every 30 minutes until it succeed.<br />
<br />
===== Content =====<br />
<br />
The IPN POST data will always contain the following:<br />
* '''id''': ''<uuid>'' The transaction ID generated by the initial call<br />
* '''payment_id''': ''<uuid>'' The payment ID<br />
* '''status''': ''<enum>'' Either '''paid''', '''partial''', '''cancelled''' or '''closed''' (4th one shouldn't happen)<br />
<br />
If the status is '''partial''', the user choose to pay without a MtGox account and bitcoins where detected on the network, we then send you an IPN telling you the amount of bitcoins pending and valid, pending bitcoins have less than 6 confirmations so it is up to you to accept or not the transaction based on that value. Your merchant account will be credited only after the 6 confirmations on our end.<br />
<br />
Additional content of the '''partial''' IPN:<br />
* '''amount_pending''': ''<amount as int>'' The amount still pending confirmations<br />
* '''amount_valid''': ''<amount as int>'' The amount of bitcoins for which we had 6 confirmations<br />
* '''amount_total''': ''<amount as int>'' The total amount, pending and valid, on the payment address<br />
<br />
If the status is '''paid''':<br />
* '''amount''': ''<amount as int>'' The amount paid by the user<br />
* '''currency''': ''<currency>'' The currency used to pay (should always be BTC for now)<br />
* '''method''': ''<enum>'' The payment method, for now MTGOXBTC<br />
* '''date''': ''<date>'' The payment date<br />
<br />
If data was provided in the initial call:<br />
* '''data''': ''<string>'' The data provided when creating the transaction<br />
<br />
===== Signature =====<br />
<br />
IPNs are now signed with the user secret like the original query to prevent fraudulents IPNs<br />
Two headers are added to the request:<br />
* '''HTTP_REST_KEY''': ''<uuid>'' The ReST key used for the query<br />
* '''HTTP_REST_SIGN''': ''<string>'' The IPN signature<br />
<br />
'''HTTP_REST_SIGN''' is a base64 encoded sha512 HMAC of the post data using your ReST secret as a key.<br />
<br />
See below for examples:<br />
<br />
====== PHP ======<br />
<source lang="php"><br />
<?php<br />
<br />
function mtgox_is_valid_ipn() {<br />
$secret = '';<br />
$raw_post_data = file_get_contents("php://input");<br />
$good_sign = hash_hmac('sha512', $raw_post_data, base64_decode($secret), true);<br />
$sign = base64_decode($_SERVER['HTTP_REST_SIGN']);<br />
return ($sign == $good_sign);<br />
}<br />
</source><br />
<br />
==== Dynamic Button ====<br />
<br />
While you can create buttons through the MtGox website, those are generated with the normal API. To display a button with your API transaction, first add the following markup to your page:<br />
<br />
<source lang="html5"><br />
<span class="mtgox" data-id="<txid>" data-amount="<amount>" data-currency="<currency>"><br />
<a href="https://payment.mtgox.com/<txid>"><br />
<img src="https://payment.mtgox.com/img/mtgox-checkout.png" border="0" /><br />
</a><br />
</span><br />
<!-- You only need the following tag once on the page, after all the buttons (for example on the last line before closing the <body> tag) --><br />
<![if !IE]><script type="text/javascript" src="https://payment.mtgox.com/js/button.min.js"></script><![endif]><br />
</source><br />
<br />
Make sure to change '''<txid>''', '''<amount>''' and '''<currency>''' to whatever value apply to that transaction.<br />
<br />
== Examples ==<br />
<br />
=== Goxcli ===<br />
best example of all, using nearly all the API methods, works as an intereactive shell and as a shell API so you can build your own app on top of it : <br />
<br />
python : https://github.com/Trasp/GoxCLI<br />
<br />
=== bitcoin_dealer (trading script) ===<br />
<br />
python (django) : https://github.com/rokj/bitcoin_dealer<br />
<br />
=== magento mtgox ===<br />
<br />
magento ( php ) module : https://github.com/MtGox/magento<br />
<br />
=== XChange ===<br />
<br />
XChange (Java) API : https://github.com/timmolter/XChange<br />
<br />
==See Also==<br />
<br />
* [[MtGox/API/Streaming]]</div>Nederhoedhttps://en.bitcoin.it/w/index.php?title=MtGox/API/HTTP/v1&diff=31791MtGox/API/HTTP/v12012-10-14T18:32:20Z<p>Nederhoed: /* redeem a wallet.dat */</p>
<hr />
<div>'''Note: All API methods require a valid User-Agent header.'''<br />
<br />
== HTTP API version 1 methods ==<br />
<br />
=== public information ===<br />
<br />
==== Multi Currency Ticker ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/ticker<br />
https://mtgox.com/api/1/BTCEUR/ticker<br />
<br />
returns the current ticker for the selected currency :<br />
<br />
<source lang="php"><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"high": {"value":"5.70653","value_int":"570653","display":"$5.70653","currency":"USD"},<br />
"low": {"value":"5.4145","value_int":"541450","display":"$5.41450","currency":"USD"},<br />
"avg": {"value":"5.561119626","value_int":"556112","display":"$5.56112","currency":"USD"},<br />
"vwap": {"value":"5.610480461","value_int":"561048","display":"$5.61048","currency":"USD"},<br />
"vol":<br />
{<br />
"value":"55829.58960346",<br />
"value_int":"5582958960346",<br />
"display":"55,829.58960346\u00a0BTC",<br />
"currency":"BTC"<br />
},<br />
"last_all":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_local":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last_orig":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"last":{"value":"5.5594","value_int":"555940","display":"$5.55940","currency":"USD"},<br />
"buy":{"value":"5.53587","value_int":"553587","display":"$5.53587","currency":"USD"},<br />
"sell":{"value":"5.56031","value_int":"556031","display":"$5.56031","currency":"USD"}<br />
}<br />
</source><br />
<br />
'''note about prices:'''<br />
<br />
* last_local include only the last trade in the selected currency<br />
* last_all is the last trade in ANY currency, converted to your currency<br />
* last_orig include data of the original last trade ( currency,price in currency . . . ),<br />
* last is always the same as last_all<br />
<br />
==== Multi Currency depth ====<br />
<br />
https://mtgox.com/api/1/BTCPLN/depth?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/depth?raw<br />
<br />
==== Multi currency trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCPLN/trades?raw<br />
<br />
https://mtgox.com/api/1/BTCAUD/trades?raw<br />
<br />
to get only the trades since a given trade id, you can add the parameter since=<trade_id><br />
<br />
https://mtgox.com/api/1/BTCUSD/trades?since=0<br />
<br />
https://mtgox.com/api/1/BTCEUR/trades?since=1316312781670700<br />
<br />
For multi currency,also returns the primary value,"Y" or "N", the primary currency is always the buyers currency<br />
<br />
A trade can appear in more than one currency, to ignore duplicates, use only the trades having primary =Y<br />
<br />
Each trade is described by a JSON structure like the following: <br />
<source lang="php"><br />
{<br />
"date":1316312781,<br />
"price":"3.5599",<br />
"amount":"3.6900096",<br />
"price_int":"355990",<br />
"amount_int":"369000960",<br />
"tid":"1316312781670700",<br />
"price_currency":"EUR",<br />
"item":"BTC",<br />
"trade_type":"bid",<br />
"primary":"Y",<br />
"properties":"limit,mixed_currency"<br />
}<br />
</source><br />
<br />
The meaning of each field is as follows:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value<br />
|-<br />
| amount || the traded amount in item (BTC), float, deprecated<br />
|-<br />
| amount_int || the traded amount * 1E8<br />
|-<br />
| date || unix timestamp of trade<br />
|-<br />
| item || What was this trade about<br />
|-<br />
| price || price per unit, float, deprecated<br />
|-<br />
| price_int || price in smallest unit as integer (5 decimals of USD, 3 in case of JPY)<br />
|-<br />
| price_currency || currency in which trade was completed<br />
|-<br />
| tid || Trade id (big integer, which is in fact trade timestamp in microseconds)<br />
|-<br />
| trade_type || Did this trade result from the execution of a bid or a ask?<br />
|-<br />
|}<br />
<br />
<br />
==== Cancelled Trades ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/cancelledtrades<br />
<br />
returns a list of all the cancelled trades this last month, list of trade ids in json format .<br />
<br />
==== Full Depth ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/fulldepth<br />
<br />
returns full depth<br />
<br />
WARNING : since this is a big download, there is a rate limit on how often you can get it, limit your requests to 5 / hour or you could be dropped / banned.<br />
<br />
==== transaction information ====<br />
https://mtgox.com/api/1/generic/bitcoin/tx_details?hash=4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0<br />
<br />
will return :<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"hash":"4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0",<br />
"blocks":["000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7"],<br />
"version":"1",<br />
"size":"1158",<br />
"in":<br />
[{<br />
"n":"0",<br />
"prev_out_hash":"4578576f49418e69da6d7a1166168bb80a94682f21cca518b6c2451bc64bf858",<br />
"prev_out_n":"1",<br />
"coinbase":null,<br />
"scriptsig":"304402201d7eaf891bcda16ea2979694c02e590fea8fc43dc092ee60e5fb2dd756bcb19502205c5be31b772029700d0a43d499932e9c321af1cfbc8745fba6dbbe48fa79bbb501 043a264aac55e23f83b29ac7e7a914584d2aa6c2eb08ea05405f5efc38473183ca4fc075f8144bb78698df1a5be6f4057f1bccc9e1217a5658946bcc4d4f6972c3",<br />
"addr":"46f740cb9c737111ec91ec235f6877055be7175e"<br />
},<br />
{<br />
"n":"1",<br />
"prev_out_hash":"4feea511029896ff4c31132346a79594fcd0c4e60aab2fa4f527e1395d375488",<br />
"prev_out_n":"0",<br />
"coinbase":null,<br />
"scriptsig":"3046022100f3bc0445f629e4e896ced23013d89ba6e6488a6ec21c47df608aaf6d6d212fbb022100d321c4c7f5f33900b8c0efba8ff58a3541e621588f402e167f51968b6ee0bbf201 042157f97a8a78caf6315dbd6d9267b9edd9c1c37cdb211f2bc03703a28eeebaf274efdcff4ef3e3ef4a6b7ccb5d8c17acba941d1a5669c3299f22a0e78e702fdb","addr":"7b0a72820f6e92ccc384dbdecb5584d855ce9416"},<br />
<br />
{<br />
"n":"2","prev_out_hash":"9adadb88c3075afdce1216b35d27fd5cac9736ce3977778999f9a85105d2ea8f","prev_out_n":"0","coinbase":null,"scriptsig":"3046022100d63237cca9bf2200c6aa255834e06f9dc5e4e20f1ea7e6678119bb0e4a5a109f022100db37ec795336509fb3a16d1acebfe08523d95e177284149614a6d3384286b27c01 04b16b41dab16cfbf59f1713559795440b98b384dc01656ebaceeec8f6d1463802cb474062b2b8c1de53ab1fe65be0f6213dd61519044e9c1f50291b915fc7fc6e","addr":"2ed7c49f080e9898737276ad802e2067a1d06ab7"},<br />
{<br />
"n":"3","prev_out_hash":"0e2ed4e4db87ddc9cb54ab3cdcae59762293815d3093c238e42d33248b39e19d","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100ab501414e7643cc1a78645f544cbcf6411e71e0c21953cd51f7f9933a50538a002201b4c9bac60aa19d659d0686d45bf06c4928c4446269692d88722f57624cdaf1401 048e1e4862c6fee7293f6c7be43a72a375e68395398e4d5da3db06199a35fc46cf51b87f3c6b87caeb81181d630706e23b5679ae8b96ca36701282ae5b49dd99c9","addr":"c74d2e95aeb037297c7b6a232d78c715fa1ab826"},<br />
{<br />
"n":"4","prev_out_hash":"93c912462daa2a52e108e3424596d56fe2a136d6707a65b6423dee229e317ea1","prev_out_n":"1","coinbase":null,"scriptsig":"3045022100fe782441b8788ed9297c8fea735701ae0a77081fc748ceee8cde945107f64967022014d51d5bc8d8138b97a657eda6d03ba998810e3e941988da90b82f6d24d8471e01 045f53cf2dbdb3213084efa69ac1dfcd8d97be8073a8b8104feb000513aa048b653f400d23314fc090456078f46a0fc9daabdee57f1ef14c2111b9ddc35255189a","addr":"958bba83ac42ebf055c1724b25bfe5c698abbb51"},<br />
{<br />
"n":"5","prev_out_hash":"44a1b493ef6176cced4c02fb97a227b98e5bea0616d9cdd6005bcd6905d667f3","prev_out_n":"1","coinbase":null,"scriptsig":"30440220132484ad901567d2c52c0b4f3be5263d1d8ed6e76be1398d2bb7c2a1aec5f748022033b907afa05eb075dee9993b8a05c9e40c69e53d65a06cc8a975ff4c4407141e01 04bd5d7feb1884efdccbe8feb8fa9ff57d56272ac5f667bc59cb07a232fbbd9cbabdf54b6bb6ca4c77e0de22cb0f896fa6183e53381861641049f0edee2d64cfe5","addr":"3784c102bbfd34cc7fb6e12c51b5c6177592f267"}],<br />
"out":[{"n":"0",<br />
"value":<br />
{"value":"0.01000712","value_int":"1000712","display":"0.01000712\u00a0BTC","display_short":"0.01\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 6427f36ed6e5a0cb526a0b0bef1335992326e9a9 OP_EQUALVERIFY OP_CHECKSIG","addr":"6427f36ed6e5a0cb526a0b0bef1335992326e9a9","claimed":"N"},{"n":"1","value":{"value":"3.31674208","value_int":"331674208","display":"3.31674208\u00a0BTC","display_short":"3.32\u00a0BTC","currency":"BTC"},"script":"OP_DUP OP_HASH160 1f27d1fc284143729944ab89823111d2bb63dc46 OP_EQUALVERIFY OP_CHECKSIG","addr":"1f27d1fc284143729944ab89823111d2bb63dc46","claimed":"N"}]<br />
}<br />
}<br />
</code><br />
<br />
<br />
<br />
==== block information ====<br />
block information can be accessed by depth ( the block number ) :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?depth=188111<br />
<br />
or by hash :<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/block_list_tx?hash=000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7<br />
<br />
both will return ( for block 188111 ) <br />
<br />
<code><br />
{<br />
"result":"success",<br />
"return":<br />
{<br />
"info": <br />
{<br />
"hash":"000000000000076fa606a7b67c131afc87d24d34114be2863cf24ca3d48139e7",<br />
"parent":"00000000000005adbcc9846f9f3542f9349b19a3c8a8f8149a830e8d748b0c92",<br />
"depth":"188111",<br />
"mrkl_root":"772b7dcc99c98a9d77e40e2ea300ba492254dea5439599f666c77bd5be1f3b4b",<br />
"stamp":"2012-07-08 12:03:12",<br />
"size":"76898",<br />
"status":"confirmed"<br />
},<br />
"txs":["020d258be19e6b399301acca1857ceb13adf643edbc660942d7eacc3290bdf55","0575fb1c09f86de21bdb00bb1423053e5ee667158ad50aa0043e82bdb3d21a1e","07830422f821fcd63e316411c883486161f15154ba27b4fffbd934fe02423020","07a6cdf84e5b5aec5f3ec968a36a469e2923237254c31adf8cc895f4d47dbd0c","0af35c993e0094010a73d48bded49ea1c7f5d26a1d80fb1ddd2fada39f725656","0b5a4340a8daa28832c4ea7baa463b896fe954bca50bcfaa2671947725c103bb","0c5adc9fb24a3daa80fe0e2ed6c6b35ee0cb70e3aa6da42276e04fd2132ee4a3","0d28cea45a0a90ac105777d1d53318d23be489416aded7bcc1c92ed2f7426358","0f05493623804d9ad4501521c893fb186cbb03e41962bbd42a10bf6c89f60026","0f627402384a9c88ec878b6d7e3866f88d8c91295c7a3f595a50f32af3a962e9","100f488d2822b1e50ef6b7a885fc576a610b2aa5d36c660c6b000555f5edb182","12d1cdcd17cfbccfd5184543c9edc5a18c3add089c76afa33c0da72001fcd2ea","144516c54e56e3c9a049995fd402dd4749eb7bf4276c247c598f67ea126c1ef0","158be63da6a97dcb7ac2286ae148ba0bbee62d4eb3be9423e0de84337c67cef1","175a4c4708a6237bdde8cc355487c1b85f61915d1336fb9ec1216946ed949efe","180a9901550e68c552fab07b23788bf424636ef899a73313c9dde8e00757acd9","186d0632a342d20e97a612e2ef6c60b74af278678e2221a5c043bb8bac683f73","19cf092b8657d0da33ef97c628469bfa0e87f564327629311881e8ef4cbe203c","21a79eeaab53234b1017689fcf13894154d3a9083d10feeec9096b2bd5135649","222e59465dae7866897b9a750cddb3924e775637944d3ec6dd1cd0f81bd9f36b","23e28db3cb8dc658d010eb7b3ed9f4ac0ae3be4049bad0d557c2a7446954d185","2426cb2d1fd6958c1830f98aa54bd9ee86fd3325cb13b1e9aeeb2901f481b38f","2528e80141db0f5a09f6d8ded3ba06427476256a70442a7df51fe3c2686bef64","256e754aa2829469cf575b121eb4abb7f6a1f0aeee6f221bfd14a5e0b0ca9baf","25fd783b5cdcb1e1769092a007103556bc3d5d419b5d5ba9ef6e7400a5e0caa7","268fa8738fe708161071624d3143475a7a26f7ccf8dd031c91861a3dd59d3eee","2801207fb1b50f1d60324b7a790da36c244875de7b0329fe1be53439e74d9553","2826f91a4664031f5ed7239bddc11fe746b63e1c5d70bbe043ffb62e966a2c01","28d4fcec098886db460d300d9a62be49c31ddbd1cdaa203a5fbdf8021eba22b6","2ada3f324802d7ad3dfa7d5ff24e888c3919cb8e7ba1050f59cc814ccc6c7f41","2cdce29d3ef98062d36e63d150e203737f1374f43e8a1b36eea08286450e5e24","2ce5579a4c205761779668232c685eb0c0974f0328daa073bafec2119afba906","2d1928299d04653351d2358885e51a981f227d9ac8eaae34437b63eff8f4b28c","2e5686a497efdda63de8c5aa23fd349f3004a31ccebc6b3954de06669b3dfe9c","2ecc8f682cb7e65802072bf311cdb9f87e25cf34ab3f0f475c16169040b3c654","335ab9791c80ab80ccbf55e6829ad3c67a6b48426769b9bd7b3d866233ad912b","34bf38fb8bb1e74d1570e4e357bf2c9af3956917bf3f49ee3a5a9bd9e89e174c","351835329ddecfd75c74fd82b207a6f1481394321b3c3613e71dad74654a59ee","38f67149f684713e8271b2f709c125c365cc0ae97c740d0e4a07822f71f3b640","39ddb42041f0ba3c7d87c2d5e74a633a1907f188b57569b2641c77fed674fe0a","3bdb7e7e5d8b7b4dc37fb961272819eeee0da9854657318503be4397567497c4","42d2e9a1a1650d58c21ebcb14eef6da5b248b43c96e1bca816baee4c73978650","42dba17d47c259559dc9a5a110457196ccae97447f2b9e6056fd96e471e09715","43a262b3cc7b2899b166ddf06d37fd4600b2348342514d8646a76c454b4772d0","4462c88079cc51972f1bdcb8a4240ee8757b0bb69df828ade051c95ced540fa0","44adb50a8c3096a079c5fef9dfaae479b2f2804e09106097d480a8c1b0672da1","44b4dce02cbd628e8f88bf7ca36f650db866b16c5a79b3cb6f6b24bcffb1c089","489ef413e51bcbd23a4134c366f2537d99ea81913af43627dcab4ccfd611d1df","49d2a512f63481a42ad30a1b3845fc2929296945519c0998dad4fa361064765a","4d5372c14355d789decb0e100fb05e86f6b854d0187815b60a1b37de41ca245a","4db9e6cc810918143fba3dfe8cc3030847b8297775dee7540ca03fbb0c8788c0","531bfa06d7164dc5cb971e3fe90aefd61c188a5d292350a2cfc12cd8bac760f6","553341c3683a9ccabe10fbb65334a694bab2469fa444570e51d81b7d416414f8","5592b28d4a6f652fce290e1502a6204ad501ec5759438c59209f29bd9e80f972","573b1dee0b00b1936d8e8b4f1f45e47c246d7be09b0573281bdbb0b71035841e","5767fe6251014d97a2f14e1226ae08b11065f78b7f52a390bda3eb87cf63e9d5","588c8e0d458ee5516468d4f0f68711757bd4e291e6456be8e3fde1fa9c6e72c9","59f3d51b41f346c08fb73be2a540ebc2aeffb2220da5c2e5d927b74a5249c907","59fb156e2e6b901524a7b7fe906db455f014deb361096db937db5be952490b36","5c2c78de645d59a57500e0a3ba19d91ff8dc902a6d75c16512d013449a74957c","5da0e429c410ce6220f7206e6ee41f0fc8216000908b3d8eeb651345fb5e7435","5eebfbda3754fc240d1b87806cf57c0f6805eee3cbf8b0c29f8da96017ddbc1f","5f6d93830779e69b1a9e44ceb81fe42ddbc1b453014548b44b348d5e979f98cc","601f57984bead5aa7767885e2d01e9d24582c1c7a2f7e907b70b76bf773726d3","60ae2132f0864e3700db8b6a30ee7e4d7e7479798c5ce14df23a7935016b2eac","67177915a8a163c49f0cfe7f12a065e24046d8b32ee4b6b5071954c12f9f8173","67398f5c224a83debf5455b5caa6976249d35344a3b4f39700cda11569494203","68d1bfff53204d0eeadb35540ddcb43ad2c7aaa9ff647052ab4f2d66f3094e8d","6962015317f58edbed7b8725f344a25fb7d8dfca743715558d916cf1a8b32b24","6ab7e2e0c7749ea166968629f584c2be8687667fdf6861d53368c944e10eda3a","6b11cbd800814e5d86afcd3daf56fed4e8f987007ff4ab835a05e6de470f35ff","6ba15ceea3a22c3a8b3539c1124a4d641409a680db07af35e35d73da877e8da4","6c41c14638745ca2b820153386fd95948d8bf048750328cd397d05241ebec08c","6f3e68f9b4d007249b4585b0760e2b892a7f6b8fd2ef568e93856da20d96ebe4","702a98c7b9a4cccce628ea40ec94f9663c9f3163190c18c0d5011fae44f50a7c","7084504bf52356da59c8ca8e96c6cb4d2d85f10ae4c02fa74b50e26c6b8467a0","737e38e017b1a9308ea2264c8c4e9bba612ffba3fb44de505f3e479ea1d572a4","75b3d2188033c8e2a9f5aed17cd80c71d5599f9af23ed36a9561bdc3a15fec04","76b16f3014b25107d0b88172c2913980948c9bc8c68132ea424c54c00e7858d5","77141d625b4521eeab882b79e217cfe19cf8e74a757729152bf60ee5a70071fc","7b309dc1e54d784f3772631dc4b01f5dc414904d21f77905c9f6d70bf8423d67","7b4a63bc061f7e95461631e58aaf96314591ae0fb0feef90ecc31003824eb66b","7b7a0136f2fc529018f0568a21bcb73996375ed9eb2c627846b28f5b09095a0d","7d00ff77f0f12ab7799ed571bcb438df230135e26796cc4b984908103beae847","801314902f70f8939fef64267687d2bb95c333a62464ee5db76b88aed8b9d360","80757f7f5a5ecd47e64cd5299442038b7922d15d5c303d2a950deac204b7807e","836bea75b79376c547544b06298cd3fb3f5974641b3ceb77eaba687e19e2cec4","86d5cf06b40acdf96215db8a767df3e1fd2c8e4641007e8ee5c6f8bd9b47f3ea","8a4f4d6acdf5d875e2ae14cc17becbb45072c7229a864b3fa1cdc80b45d80597","8ab04f7f610a17d08613fca7d79dde9fb5817904e1055bd6b8eb574e9531ff5b","8b1dd8aa0b6272770d2491d35944fb9b3d3169c72e8275ef2411b801fed1785a","8c7695f70007d17fbdcbcbeb921837b2c5ef3469c27ca65ef3e75e0634e06357","8ccf0173e0006b65019d4b2634f824c69883f8bb6ab3670eff36183df45d437a","8cedf02ad54c94948e69c69dacf8b5f94d6a20b156f112b79b635610b9abccfd","8e0e0aa6ae3df684489ef41c6c65e5c9fb9d72d2aa455b2453a6495ab45aa29b","9059fb2f4ddb94bfe924c3c009e1e1cd8da53513c9ec1a1aa7e20c2376274dd5","911766a8e660a973180d306aa95fe2b9037f37db28cf166e59aaf986ec72608e","95bd4211a0fdb9c028c1b7f694b72ab8222ead20d0f83edd7288ef19105208f8","971e6feb86d955f9aa194e25c596499b5ab5683c68766877b14eacaa86ed6836","993fcab01aa5882308af5b870c0a191884ff4ecdb8cee964ad58e96781763d65","9af2c6bb2897847bf8ebb71ee600c810354bdf8aa78ad8aab864ba89be3aae0a","9b4d84991e2dd181570dd4f5d18e533c57252ec8ddb6642c990386e8cd57cbd7","a05b2c1547f8513ded94425763b6f34cf3019e7f649163d31fd8fec770950fd4","a36f43271195cf031b2a0e3df297a206088a11c3f03cc4ec255721c017825140","a3825df57a7f4d6e3f204d35d1b58f24d0a89dece8c8e8cf277fbad2283eaf0e","a3a6ccc3af9becf7135b58798e5190251c8499171681b3c2c1110dd0cb1ca0f2","a3dbbdbe58586d5917828a058b37e471e15d6a42688397e93888d6ce58025a55","a48a185b6d50ae91a94b571bb43f173102a172cd886649bbe1563c875ca2142a","a4b7d03a4af6e2225902e026adb2e265e07a10a8a062a49aad2f544fd7c900f8","a6de57825868deebdb57a405c7f9085f21a249ea9d36bf1c18e9c709280523dc","a7a9eb9c044a5fc5e27bc9ba533b794543e154c2081266988e2ca07e37380787","a92d2d46d0d65e3ea05b68ab16b32bed760fa2955c9f6b9f91687e429724524c","a9c2cff9357c003de5e6498e0af52ad8f24778fd18ca274fd135a7dbb4464a8a","aa1d22c31d4dc4114888bccbd7110a1f777887ed8dd2dfa006eaaeeac58d2a44","aa313832f108aecbfae05acab011d40ff1d1ec540cd2025851dcc10d92bcd0c3","abbcfbdc79d0536344295d6e0cd6d7ae788a385836c33c7ef7f98f6064ad2ee1","ac3a732c65504a9f4e728cbaf80d4d58f74a3834138a224657eebd03982c1898","ac6eb25fa5be2a1d1418879791cadf43b1a268cb3aa2e505977cb29e4b7035dd","adec207d59a23cfc8afc63b0e45bfdefde9b7ffe74515872f0837025530ab6eb","ae1584bf163b05c014d0d99715f481655949c7762d800997562fc93f3da731b8","b1403965758e40e9d2eb31950f97dc599368edeb98541ede8df2b512ef2fd3bf","b3c086e90eda12260b5bfe8eff16a051882dfd921c02140194c0e0ee9a849466","b4062fe2f07abe03e2e9b88b571c7f2d9c058c78fb157d3d04fa39feda380a02","b416514b63420449c6c56781adafff18f6f28733aeb2fb4bb0c1abeadbd6db6e","b7bfbbc5fad15123960443cb0c118162a62a4b92732a8365eeb77e8df25eca46","b871fea4a33e5e51ff648ca74d16a34f179d3467805cad84238c729282e8acf7","b878eaf74341fbc65c609785b93b38d90f841f2d50bb39496e1f4b1b34b2255d","b9a80691e7d9423ad546a96363a017a4a0725dc854de082d6927da6cd6aa19c2","ba7ef3d90be2bc57c785f55457971ff0812a4d9b9df18ab980229ce648cee31d","ba8669e2e19c21a0045d994c56e811b2d1d51451ab248e76df456427d0d20569","bc260c6b49fe06a331202a2b703cb051aa352d17a8373496dd5ef67ab404a145","bd260517b438daa35921cca54b8c2dcd48b8ca338f7166d91ecd3a3eb14c9d7f","be375723b763ea3e88f9539eebd1f73f8af0b463b7bb88781dc3f589ab36e9ad","c0c4c3b3cd1b400b81316dd67001b92a512569dadd0ed6f783e87e601c8ea54e","c156c12f1256b4a2a6c0558b7094e263876586e4a72333da2997fb97cbb8d15d","c2a5f97fa1daf09015fa78a57b2aed1d33b9c18ffb84bb7f3d0e8d643532b772","c54d091b9d006ed79405b62defa7910a7ab9db6463f46ab1c50064df152aa887","c5a7a5ed8e2b4e72ca8c72025e91e14388ee23c7822c16bd3fe3b11c206ffb84","c5b5f35b88138f27b6aa2395f423d15dbf642258971102de77359ff79eb8d4cb","ca52540a211bac9449b45662ac2a6a00899bf55b5867017ab73b1973ef3a8f6c","cc6f6ad1f5a023bb52f7638f883d4bf20dab6bd3a0b1b9a3c8526fc99aee81d2","cef0df2d68b4f38fd9ce501839e3d4d2a40317d845037baa2b7ffb3ed45918c1","cfd0806446352b03d89be45f1014c0a48728286c5b12fc89d32a3cb31896765d","d03fe289cf120bdb3ae70711da1c8972f650fb8e5c4f91dabf17639a2c7ecb06","d1089a3f2e4f0d043eec44395a5522f107fc649ca561f76013d412c85710c306","d1a68d6cf85c32a15011cd13b374ab8aad619b1b437ffd262c446cc079babedc","d4201c9a33e19e2ba351ec288ec5a43f4b3f2cb133d6a7977f72c529d3e03408","d5991156ebb5beeac70ac0cfc1706990be5752b41bafbe31228053fe18dc3e67","d86adacb713cc4ecf06828aeb2b8e1bb0311144986978c59240ce996214ab69f","dab5fe0369dca967e09653cb0475e09636091ba0a6ee95289de49fe97e505f3d","db0ee162bc04083d6caed8a88a7be44b02d15b2686a2d6dd06a10d024cefb40d","dc453efc8162dbff08e04fdda7a5dcbd986ee0fbee547764ff7ae89afe68806b","dc5e2a39f8e1ce90f88c3f50076ed03188fc60e87b103a0d48e66fe462b7777f","df826a504bad73ab69fcd740f72e6e00488e69db8ec31a55ffb3ed43b0845cba","e05d71cfe0b356b0dddee437f9da2610f85c5dffedc3ab058172ab71624a7d14","e10fb8c50f8e378b43f4f80b41e62b78dc968496196ae8399fa7d203e213a3cd","e5b9be11e940019582c6ac0875f54e7bc92fd15149cecf4e1bf67d4357010cce","e7a64e4c08350ee2f0ecc3af4c2df7388da044de4f7955a941ff965a925b54b8","e84b2c1129b574a485dfa7d8843cf569b3679f234b681f6f8fa0d88d5489b224","e8df3c1953e9c32ae77bbf01dcec48e1052271e0eb6d556da9deda1c50426231","ec46f3be50d9f2f6472669b8c8e38addd54c00bc206c81e873f340c0a11d71f2","eca4fdc50f34ccf5e0b459b0a077ec9033cf25c58e29b3406f24eab6445a6221","edc7488d9f86de7d094c1d02119680b91a15a28cf7a8b09cf9cf194193ae81bc","ee4b82dc8f11c5459a42090c1aafaf645f2c1d247edec1d9b0fae46f4efaa02f","f03f924d1767b748f8fc15bcef798076e746a7917f5fc7b89e2ed022c95faa82","f104ccccf3bc11107b27900670f36de7fdda3a0a7d086d2dc69b4903aa2cbcd5","f18d25a1fabd8f3a62edb164c759b650c13c320f2edc7cab44c01ae88809b285","f2a1ff85c3ac02574d1f55b067c841ea4b0283ed9543f11752fa41723b315ed9","f46a661429090548bfe775c5df5197b0cf6ae5d38a215986b79de385b52d4223","f5d19ba9a4a11db479fd80aea1674eb896f515fd43f34c456b09f49500ecd4b7","f629a172edcac21d929169f2bb1dcf148110151b769bae15e4fc09bd72898fd2","f6d1ca49cea130563f72f266612eb901c9290b3bf36fd4218d5881c5c9d7d35f","f79f17ff115716f428034aa9181d63e67649404559448193fb6c96f35cad3e00","ff0e08dd175e3badf556ea843a972edea4c80f461cfdabbfdb69167ba3845055"]<br />
}<br />
}<br />
</code><br />
<br />
==== address information ====<br />
https://mtgox.com/api/1/generic/bitcoin/addr_details?hash=1f27d1fc284143729944ab89823111d2bb63dc46<br />
<br />
<br />
==== Order lag ====<br />
<br />
https://mtgox.com/api/1/generic/order/lag<br />
<br />
The "lag" value is the age in microseconds of the oldest order pending execution<br />
If it's too large it means the engine is busy, and the depth is probably not reliable<br />
<br />
==== Currency information ====<br />
<br />
https://mtgox.com/api/1/generic/currency<br />
<br />
pass parameter ?currency=<currency_symbol><br />
<br />
returns information about a currency ( number of decimals . . . )<br />
<br />
=== Private API ===<br />
<br />
==== Private info ====<br />
<br />
https://mtgox.com/api/1/generic/private/info<br />
<br />
returns information about your account, funds, fees, API privileges, withdraw limits . . .<br />
<br />
==== get a bitcoin deposit address ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/address<br />
<br />
get a bitcoin address linked to your account.<br />
the returned address can be used to deposit bitcoins in your mtgox account<br />
<br />
<source lang="javascript"><br />
result: <br />
{<br />
"return": <br />
{"addr": "18dGNs5Bd6pPMuSchLHQtb1k996YpUHs3j"},<br />
"result": "success"<br />
}<br />
}<br />
</source><br />
<br />
optional parameters : <br />
<br />
description : a description for the address , a new description will generate a new address<br />
<br />
ipn : an URL that will be pinged when this new address receives a transaction, the ping is a POST request with txid, blockid, description . . . as parameters<br />
<br />
==== redeem a private key ====<br />
<br />
https://mtgox.com/api/1/generic/private/bitcoin/addpriv<br />
<br />
allows you to add a private key to your account<br />
<br />
* parameters : <br />
"key":code<br />
"keytype":"auto"<br />
"description":description<br />
<br />
* returns the btc adress and the total number of btcs in this private key<br />
<br />
==== redeem a wallet.dat ====<br />
<br />
https://mtgox.com/api/1/generic/bitcoin/wallet_add<br />
<br />
allows you to add a wallet.dat file to your account<br />
<br />
* parameters : <br />
"wallet": the file content of a wallet.dat file ( base64 encoded )<br />
"description": optional parameter to add a description linked to this wallet in the account history<br />
<br />
* returns : "amount" ( total number of btcs in this wallet ) + count ( number of bitcoin addresses in this wallet )<br />
<br />
==== send_simple ====<br />
Withdraw bitcoins from your account to a given bitcoin address.<br />
<br />
Parameters:<br />
:{| class="wikitable"<br />
|-<br />
! Name !! Value !! Example<br />
|-<br />
| group1 || || ''"BTC"''<br />
|-<br />
| btca || Bitcoin address || <code>18ytF1DH13LYEmBGREr47bNXNe6oH9ygzj</code><br />
|-<br />
| amount_int || the traded amount * 1E8 || 123000000<br />
|-<br />
| amount || amount of bitcoins as float, '''''deprecated'''''|| 1.23<br />
|-<br />
|}<br />
<br />
==== idKey ====<br />
<br />
https://mtgox.com/api/1/generic/private/idkey<br />
<br />
Returns the idKey used to subscribe to a user's private updates channel in the websocket API. The key is valid for 24 hours.<br />
<br />
<br />
==== Your trade history ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/trades<br />
https://mtgox.com/api/1/BTCEUR/private/trades<br />
<br />
Returns all of your trades in this currency (BTCUSD, BTCEUR . . . ) . Does not include fees.<br />
<br />
==== Your wallet history ====<br />
<br />
https://mtgox.com/api/1/generic/private/wallet/history<br />
<br />
'''README!''' if the above call does not work please use: https://mtgox.com/api/1/generic/wallet/history<br />
<br />
parameters : currency, type, date_start, date_end, trade_id, page<br />
<br />
only the currency parameter is mandatory<br />
<br />
returns a json array with your wallet history<br />
<br />
==== Submit an order ====<br />
<br />
https://mtgox.com/api/1/BTCUSD/private/order/add<br />
<br />
parameters: <br />
* type (bid|ask) (easier to remember: '''b'''id == '''b'''uy, ask == sell)<br />
* amount_int <amount as int><br />
* price_int <price as int> (can be omitted to place market order)<br />
<br />
submits an order and returns the OID and info about success or error<br />
<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
{<br />
"return": "4c2e69f5-8b35-4171-95a3-9e4088c1586c",<br />
"result": "success"<br />
}</source><br />
<br />
==== Your open orders ====<br />
<br />
https://mtgox.com/api/1/generic/private/orders<br />
<br />
Returns information about your current open orders. Valid order statuses are: pending, executing, post-pending, open, stop, and invalid.<br />
<br />
The order can have 2 amounts, the valid amount and the invalid ( unfunded ) amount.<br />
valid amount and invalid amount will be updated when funds are added or when other orders are removed<br />
<br />
<source lang="PHP"><br />
[1] => Array<br />
(<br />
[oid] => 66a115f2-9919-487a-9eba-99a0141c9590<br />
[currency] => USD<br />
[item] => BTC<br />
[type] => ask<br />
[amount] => Array<br />
(<br />
[value] => 1.00000000<br />
[value_int] => 100000000<br />
[display] => 1.00000000 BTC<br />
[display_short] => 1.00 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[valid_amount] => Array<br />
(<br />
[value] => 0.99470000<br />
[value_int] => 99470000<br />
[display] => 0.99470000 BTC<br />
[display_short] => 0.99 BTC<br />
[currency] => BTC<br />
)<br />
<br />
[price] => Array<br />
(<br />
[value] => 10.99489<br />
[value_int] => 1099489<br />
[display] => $10.99489<br />
[display_short] => $10.99<br />
[currency] => USD<br />
)<br />
<br />
[status] => open<br />
[date] => 1344208333<br />
[priority] => 1344208333021535<br />
[actions] => Array<br />
(<br />
)<br />
<br />
[invalid_amount] => Array<br />
(<br />
[value] => 0.00530000<br />
[value_int] => 530000<br />
[display] => 0.00530000 BTC<br />
[display_short] => 0.01 BTC<br />
[currency] => BTC<br />
)<br />
<br />
)<br />
</source><br />
<br />
==== Order result ====<br />
<br />
https://mtgox.com/api/1/generic/private/order/result<br />
<br />
parameters : type ( bid or ask ) and order (the order id)<br />
<br />
returns a json array like this : <br />
<br />
<source lang="javascript"><br />
order_id: '1234234-e9ef-4b75-aa1c-90cd109d24ea',<br />
trades:<br />
[ { trade_id: '1336611143363429',<br />
primary: 'N',<br />
currency: 'USD',<br />
type: 'ask',<br />
properties: 'market,mixed_currency',<br />
item: 'BTC',<br />
amount: [Object],<br />
price: [Object],<br />
date: '2012-05-10 00:52:23' } ],<br />
total_amount:<br />
{ value: '0.01000000',<br />
value_int: '1000000',<br />
display: '0.01000000 BTC',<br />
display_short: '0.01 BTC',<br />
currency: 'BTC' } }</source><br />
<br />
=== Application API ===<br />
<br />
==== HOTP key ====<br />
<br />
https://mtgox.com/api/1/generic/hotp_gen<br />
<br />
used to generate a new HOTP key ( useful for developers )<br />
<br />
==== App activation ====<br />
<br />
https://mtgox.com/api/1/generic/api/activate<br />
<br />
parameters:<br />
* '''key''' - Activation key<br />
* '''name''' - Device name<br />
* '''app''' - App ID<br />
<br />
used in mobile apps to obtain an API key/secret pair. Contact MagicalTux on freenode to obtain an app ID. Activation key comes from the user's account, Settings > Access > Application Access.<br />
<br />
=== Merchant System ===<br />
<br />
==== Order Creation ====<br />
<br />
https://mtgox.com/api/1/generic/private/merchant/order/create<br />
<br />
===== Required Parameters: =====<br />
* '''currency''': ''<currency>''<br />
* '''amount''': ''<amount as float>''<br />
or<br />
* '''amount_int''': ''<amount as int>''<br />
* '''return_success''': ''<string>'' Where to redirect the user on payment success<br />
* '''return_failure''': ''<string>'' Where to redirect the user on cancellation<br />
<br />
===== Optional Parameters: =====<br />
* '''description''': ''<string>'' A small description that will appear on the payment page (defaults to "Payment to <user_login>")<br />
* '''ipn''': ''<string>'' URL that will be called by our services once the payment is complete (more below)<br />
* '''data''': ''<string>'' Custom data returned by the IPN<br />
* '''email''': ''int'' Set to 1 to receive an email for each successful payment<br />
* '''autosell''': ''int'' Set to 1 to automatically sell received bitcoins at market price<br />
* '''multipay''': ''int'' Set to 1 to allow multiple payments on the same transaction ID<br />
* '''instant_only''': ''int'' Set to 1 to only allow MtGox users to pay on this transaction<br />
<br />
===== Returns =====<br />
* '''transaction''': ''<uuid>'' A unique transaction ID<br />
* '''payment_url''': ''<string>'' URL on which to redirect the user<br />
<br />
<br />
==== IPN ====<br />
The IPN (Instant payment notification) is a mechanism that POST data about a successful payment an a custom URL located on your website right after the payment as been validated. It is signed with your API key.<br />
Your website is supposed then to either acknowledge the IPN by returning "[OK]" as is. Anything else will be counted as an error and the system will try sending the IPN back every 30 minutes until it succeed.<br />
<br />
===== Content =====<br />
<br />
The IPN POST data will always contain the following:<br />
* '''id''': ''<uuid>'' The transaction ID generated by the initial call<br />
* '''payment_id''': ''<uuid>'' The payment ID<br />
* '''status''': ''<enum>'' Either '''paid''', '''partial''', '''cancelled''' or '''closed''' (4th one shouldn't happen)<br />
<br />
If the status is '''partial''', the user choose to pay without a MtGox account and bitcoins where detected on the network, we then send you an IPN telling you the amount of bitcoins pending and valid, pending bitcoins have less than 6 confirmations so it is up to you to accept or not the transaction based on that value. Your merchant account will be credited only after the 6 confirmations on our end.<br />
<br />
Additional content of the '''partial''' IPN:<br />
* '''amount_pending''': ''<amount as int>'' The amount still pending confirmations<br />
* '''amount_valid''': ''<amount as int>'' The amount of bitcoins for which we had 6 confirmations<br />
* '''amount_total''': ''<amount as int>'' The total amount, pending and valid, on the payment address<br />
<br />
If the status is '''paid''':<br />
* '''amount''': ''<amount as int>'' The amount paid by the user<br />
* '''currency''': ''<currency>'' The currency used to pay (should always be BTC for now)<br />
* '''method''': ''<enum>'' The payment method, for now MTGOXBTC<br />
* '''date''': ''<date>'' The payment date<br />
<br />
If data was provided in the initial call:<br />
* '''data''': ''<string>'' The data provided when creating the transaction<br />
<br />
===== Signature =====<br />
<br />
IPNs are now signed with the user secret like the original query to prevent fraudulents IPNs<br />
Two headers are added to the request:<br />
* '''HTTP_REST_KEY''': ''<uuid>'' The ReST key used for the query<br />
* '''HTTP_REST_SIGN''': ''<string>'' The IPN signature<br />
<br />
'''HTTP_REST_SIGN''' is a base64 encoded sha512 HMAC of the post data using your ReST secret as a key.<br />
<br />
See below for examples:<br />
<br />
====== PHP ======<br />
<source lang="php"><br />
<?php<br />
<br />
function mtgox_is_valid_ipn() {<br />
$secret = '';<br />
$raw_post_data = file_get_contents("php://input");<br />
$good_sign = hash_hmac('sha512', $raw_post_data, base64_decode($secret), true);<br />
$sign = base64_decode($_SERVER['HTTP_REST_SIGN']);<br />
return ($sign == $good_sign);<br />
}<br />
</source><br />
<br />
==== Dynamic Button ====<br />
<br />
While you can create buttons through the MtGox website, those are generated with the normal API. To display a button with your API transaction, first add the following markup to your page:<br />
<br />
<source lang="html5"><br />
<span class="mtgox" data-id="<txid>" data-amount="<amount>" data-currency="<currency>"><br />
<a href="https://payment.mtgox.com/<txid>"><br />
<img src="https://payment.mtgox.com/img/mtgox-checkout.png" border="0" /><br />
</a><br />
</span><br />
<!-- You only need the following tag once on the page, after all the buttons (for example on the last line before closing the <body> tag) --><br />
<![if !IE]><script type="text/javascript" src="https://payment.mtgox.com/js/button.min.js"></script><![endif]><br />
</source><br />
<br />
Make sure to change '''<txid>''', '''<amount>''' and '''<currency>''' to whatever value apply to that transaction.<br />
<br />
== Examples ==<br />
<br />
=== Goxcli ===<br />
best example of all, using nearly all the API methods, works as an intereactive shell and as a shell API so you can build your own app on top of it : <br />
<br />
python : https://github.com/Trasp/GoxCLI<br />
<br />
=== bitcoin_dealer (trading script) ===<br />
<br />
python (django) : https://github.com/rokj/bitcoin_dealer<br />
<br />
=== magento mtgox ===<br />
<br />
magento ( php ) module : https://github.com/MtGox/magento<br />
<br />
=== XChange ===<br />
<br />
XChange (Java) API : https://github.com/timmolter/XChange<br />
<br />
==See Also==<br />
<br />
* [[MtGox/API/Streaming]]</div>Nederhoed