MtGox/API: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
MagicalTux (talk | contribs)
about websocket API
MagicalTux (talk | contribs)
No edit summary
 
(149 intermediate revisions by 20 users not shown)
Line 1: Line 1:
The [[MtGox]] API provides various methods to access different informations from the market, place orders, and more.
The [[MtGox]] API provides methods to access information from the market, place orders, and more.


Two APIs are available at this point: the HTTP api (available by posting to mtgox.com/code/*) and the websocket API.
Two APIs are currently available:  


== Legacy API ==
* [[MtGox/API/HTTP|HTTP API]]
This API is available in <nowiki>https://mtgox.com/code/*</nowiki>, and provides various informations. It also supports making an order, a withdraw, a deposit, etc.
* [[MtGox/API/Pubnub|Streaming Pubnub API]]
* [[MtGox/API/Streaming|Streaming websocket API]]


=== Authentication ===
__TOC__
Authentication is performed by posting a username and a password in variables "name" and "pass". Some methods do not require authentication.


=== Methods ===
==Number Formats==


==== data/getTrades.php ====
In the "old API", currency- and amount-values (price, volume,...) were given as '''float'''. These values are likely being deprecated and replaced by fields of the same name with "_int" as suffix. These are '''fixed-decimal''', so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.
This allows retrieving all trades which happened in the last 24 hours. The returned data is cached and may not reflect latest activity.


Parameters:
In order to convert the '''int''' to a '''decimal''' you can...
* 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.


== Websocket API ==
{| class="wikitable"
See: http://forum.bitcoin.org/index.php?topic=5855.0 (will be ported here soon)
|-
! kind of field !! ...divide by !! ...multiply by
|-
| BTC (volume, amount) || 1E8 (100,000,000) || 0.00000001
|-
| USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, NZD, PLN, RUB, SGD, THB, NOK, CZK (price) || 1E5 (100,000) || 0.00001
|-
| JPY, SEK (price) || 1E3 (1,000) || 0.001
|}
 
Implementation advice: it's probably best to use '''int''' or '''Decimal''' (if your language/db offers such a type) in your clients. Using '''float''' will likely lead to nasty rounding problems.
 
== Currency Symbols ==
List of the currency symbols available with the API:
 
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB, NOK, CZK
 
==Date and time==
 
Most dates you will find in mtgox API are UNIX time
 
See http://en.wikipedia.org/wiki/Unix_time
 
Most programming languages should have tools for managing those timestamps
 
==See Also==
 
* [http://bitcointalk.org/index.php?topic=164404.0 MtGox API version 2: Unofficial Documentation]

Latest revision as of 04:19, 15 November 2013

The MtGox API provides methods to access information from the market, place orders, and more.

Two APIs are currently available:

Number Formats

In the "old API", currency- and amount-values (price, volume,...) were given as float. These values are likely being deprecated and replaced by fields of the same name with "_int" as suffix. These are fixed-decimal, so you have to move the decimal point yourself (divide). The exponent differs based on the kind of the value.

In order to convert the int to a decimal you can...

kind of field ...divide by ...multiply by
BTC (volume, amount) 1E8 (100,000,000) 0.00000001
USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, NZD, PLN, RUB, SGD, THB, NOK, CZK (price) 1E5 (100,000) 0.00001
JPY, SEK (price) 1E3 (1,000) 0.001

Implementation advice: it's probably best to use int or Decimal (if your language/db offers such a type) in your clients. Using float will likely lead to nasty rounding problems.

Currency Symbols

List of the currency symbols available with the API:

USD, AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, JPY, NZD, PLN, RUB, SEK, SGD, THB, NOK, CZK

Date and time

Most dates you will find in mtgox API are UNIX time

See http://en.wikipedia.org/wiki/Unix_time

Most programming languages should have tools for managing those timestamps

See Also