MtGox/API/HTTP/v2

From BitcoinWiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

API Version 2:[edit]

The V2 API URL is:

https://data.mtgox.com/api/2/

Documentation[edit]

Unofficial documentation (So far the best we have) is provided at : https://bitbucket.org/nitrous/mtgox-api/overview (The bitcointalk forum link is: https://bitcointalk.org/index.php?topic=164404.0 )

Official docs are on: https://github.com/MtGox/mtgox-doc

Differences between v1 and v2:[edit]
  • The URL is now something along the lines of BTCUSD/money/order/add instead of BTCUSD/private/order/add in api1. All current known methods are found in the money category.
  • The requested path must now be included when you compute your hashed signature (Rest-Sign) for added security.<br><br> In version 1, Rest-Sign is created through base64-encoding the 256-digest HMAC hashing of your post data (which of course must include your nonce) with your API secret, previously base64 decoded. Now in version 2, you must simply add before your post data the relative path you are requesting (anything after the /api/2/ base, ie: BTCUSD/money/ticker), concatenated with a NUL character (ASCII code 0). So the signature is now made starting from your relative path + NUL character + post data (which must include your nonce!).
  • fast ticker
http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast

and

http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast?pretty

Explanation of Methods[edit]

BTCUSD/money/order/quote <br> <@MagicalTux> it estimate the result of running an order at a given price based on market depth<br> BTCUSD/money/ticker_fast<br> Solves the problem of ticker lag. (supposedly)<br>


Code Examples:[edit]

Java:[edit]

https://github.com/adv0r/mtgox-api-v2-java Java lib for API V2, under development

C# :[edit]

https://bitbucket.org/pipe2grep/cryptocoinxchange C# lib for V2 API and socketIO

Python v 2.7.3[edit]

https://bitbucket.org/karlb/gox2 - A minimalistic API wrapper <br> http://pastebin.com/aXQfULyq - Remove any proprietary unlock_api_key stuff. You'll need json_ascii also. Works on API 0/1/2. Link to git-repo: genbtc's trader.python <br>

Perl[edit]

https://en.bitcoin.it/wiki/MtGox/API/HTTP#PHP The Perl example on the main page is compatible with v2

PHP[edit]

https://github.com/pathaksa/MtGox-PHP-API-V2

Source[edit]

http://bitcoin.it/

See Also on BitcoinWiki[edit]