• BTC : $3678.1
  • LTC : $48.4
  • ETH : $267.73
  • ETC : $64.21
  • QTUM : $41.50

Index


Trading Pairs API

Return all the trading pairs supported by Bter

URL: http://data.bter.com/api2/1/pairs


Market Info API

Returns all markets' fee, minimum order total amount, price decimal places.

URL: http://data.bter.com/api2/1/marketinfo


Market Details API

Returns market details including pair, coin name, coin symbol, last price, trading volume, coin supply, coin market cap, price trend, etc.

URL: http://data.bter.com/api2/1/marketlist


Tickers API

returns the tickers for all the supported trading pairs at once, cached in 10 seconds::

URL: http://data.bter.com/api2/1/tickers


Ticker API

returns the current ticker for the selected currency, cached in 10 seconds:

URL: http://data.bter.com/api2/1/ticker/[CURR_A]_[CURR_B]

Replace [CURR_A] and [CURR_B] with the selected currencies.

Links:

http://data.bter.com/api2/1/ticker/btc_cny
http://data.bter.com/api2/1/ticker/ltc_cny
http://data.bter.com/api2/1/ticker/xrp_cny
http://data.bter.com/api2/1/ticker/xrp_btc
http://data.bter.com/api2/1/ticker/bcc_cny
http://data.bter.com/api2/1/ticker/bcc_btc
http://data.bter.com/api2/1/ticker/qtum_btc
http://data.bter.com/api2/1/ticker/qtum_eth
http://data.bter.com/api2/1/ticker/qtum_cny
http://data.bter.com/api2/1/ticker/zrx_btc
http://data.bter.com/api2/1/ticker/zrx_eth
http://data.bter.com/api2/1/ticker/zrx_cny
http://data.bter.com/api2/1/ticker/dnt_btc
http://data.bter.com/api2/1/ticker/dnt_eth
http://data.bter.com/api2/1/ticker/dnt_cny
http://data.bter.com/api2/1/ticker/llt_eth
http://data.bter.com/api2/1/ticker/llt_cny
http://data.bter.com/api2/1/ticker/dpy_eth
http://data.bter.com/api2/1/ticker/etp_btc
http://data.bter.com/api2/1/ticker/etp_cny
http://data.bter.com/api2/1/ticker/oax_btc
http://data.bter.com/api2/1/ticker/oax_eth
http://data.bter.com/api2/1/ticker/ubc_btc
http://data.bter.com/api2/1/ticker/ubc_eth
http://data.bter.com/api2/1/ticker/lrc_eth
http://data.bter.com/api2/1/ticker/lrc_cny
http://data.bter.com/api2/1/ticker/pst_btc
http://data.bter.com/api2/1/ticker/pst_eth
http://data.bter.com/api2/1/ticker/pst_cny
http://data.bter.com/api2/1/ticker/tnt_eth
http://data.bter.com/api2/1/ticker/tnt_cny
http://data.bter.com/api2/1/ticker/bts_cny
http://data.bter.com/api2/1/ticker/cnc_cny
http://data.bter.com/api2/1/ticker/rep_cny
http://data.bter.com/api2/1/ticker/bat_cny
http://data.bter.com/api2/1/ticker/snt_cny
http://data.bter.com/api2/1/ticker/snt_btc
http://data.bter.com/api2/1/ticker/snt_eth
http://data.bter.com/api2/1/ticker/btm_eth
http://data.bter.com/api2/1/ticker/omg_cny
http://data.bter.com/api2/1/ticker/omg_btc
http://data.bter.com/api2/1/ticker/omg_eth
http://data.bter.com/api2/1/ticker/pay_cny
http://data.bter.com/api2/1/ticker/pay_btc
http://data.bter.com/api2/1/ticker/pay_eth
http://data.bter.com/api2/1/ticker/bat_eth
http://data.bter.com/api2/1/ticker/ico_cny
http://data.bter.com/api2/1/ticker/ico_btc
http://data.bter.com/api2/1/ticker/ico_eth
http://data.bter.com/api2/1/ticker/cvc_cny
http://data.bter.com/api2/1/ticker/cvc_btc
http://data.bter.com/api2/1/ticker/cvc_eth
http://data.bter.com/api2/1/ticker/doc_cny
http://data.bter.com/api2/1/ticker/doc_btc
http://data.bter.com/api2/1/ticker/storj_cny
http://data.bter.com/api2/1/ticker/storj_btc
http://data.bter.com/api2/1/ticker/storj_eth
http://data.bter.com/api2/1/ticker/eos_cny
http://data.bter.com/api2/1/ticker/eos_btc
http://data.bter.com/api2/1/ticker/eos_eth
http://data.bter.com/api2/1/ticker/doge_cny
http://data.bter.com/api2/1/ticker/dash_cny
http://data.bter.com/api2/1/ticker/eth_cny
http://data.bter.com/api2/1/ticker/etc_cny
http://data.bter.com/api2/1/ticker/exc_cny
http://data.bter.com/api2/1/ticker/ftc_cny
http://data.bter.com/api2/1/ticker/ifc_cny
http://data.bter.com/api2/1/ticker/nmc_cny
http://data.bter.com/api2/1/ticker/nxt_cny
http://data.bter.com/api2/1/ticker/ppc_cny
http://data.bter.com/api2/1/ticker/shell_cny
http://data.bter.com/api2/1/ticker/tips_cny
http://data.bter.com/api2/1/ticker/tix_cny
http://data.bter.com/api2/1/ticker/xcp_cny
http://data.bter.com/api2/1/ticker/xmr_cny
http://data.bter.com/api2/1/ticker/xpm_cny
http://data.bter.com/api2/1/ticker/xtc_cny
http://data.bter.com/api2/1/ticker/ltc_btc
http://data.bter.com/api2/1/ticker/bts_btc
http://data.bter.com/api2/1/ticker/cnc_btc
http://data.bter.com/api2/1/ticker/rep_btc
http://data.bter.com/api2/1/ticker/bat_btc
http://data.bter.com/api2/1/ticker/hkg_btc
http://data.bter.com/api2/1/ticker/doge_btc
http://data.bter.com/api2/1/ticker/dash_btc
http://data.bter.com/api2/1/ticker/eth_btc
http://data.bter.com/api2/1/ticker/etc_btc
http://data.bter.com/api2/1/ticker/ftc_btc
http://data.bter.com/api2/1/ticker/nmc_btc
http://data.bter.com/api2/1/ticker/nxt_btc
http://data.bter.com/api2/1/ticker/ppc_btc
http://data.bter.com/api2/1/ticker/xtc_btc
http://data.bter.com/api2/1/ticker/xcn_btc
http://data.bter.com/api2/1/ticker/xcp_btc
http://data.bter.com/api2/1/ticker/xem_btc
http://data.bter.com/api2/1/ticker/xem_cny
http://data.bter.com/api2/1/ticker/xpm_btc
http://data.bter.com/api2/1/ticker/xmr_btc
http://data.bter.com/api2/1/ticker/mg_btc
http://data.bter.com/api2/1/ticker/ifc_ltc
http://data.bter.com/api2/1/ticker/tips_ltc
http://data.bter.com/api2/1/ticker/tix_ltc
http://data.bter.com/api2/1/ticker/etc_eth
http://data.bter.com/api2/1/ticker/zec_btc
http://data.bter.com/api2/1/ticker/zec_cny

Depth API

Return the market depth including ask and bid orders.

URL: http://data.bter.com/api2/1/orderBook/[CURR_A]_[CURR_B]

Replace [CURR_A] and [CURR_B] with the selected currencies.

Links:

http://data.bter.com/api2/1/orderBook/btc_cny
http://data.bter.com/api2/1/orderBook/ltc_cny
http://data.bter.com/api2/1/orderBook/xrp_cny
http://data.bter.com/api2/1/orderBook/xrp_btc
http://data.bter.com/api2/1/orderBook/bcc_cny
http://data.bter.com/api2/1/orderBook/bcc_btc
http://data.bter.com/api2/1/orderBook/qtum_btc
http://data.bter.com/api2/1/orderBook/qtum_eth
http://data.bter.com/api2/1/orderBook/qtum_cny
http://data.bter.com/api2/1/orderBook/zrx_btc
http://data.bter.com/api2/1/orderBook/zrx_eth
http://data.bter.com/api2/1/orderBook/zrx_cny
http://data.bter.com/api2/1/orderBook/dnt_btc
http://data.bter.com/api2/1/orderBook/dnt_eth
http://data.bter.com/api2/1/orderBook/dnt_cny
http://data.bter.com/api2/1/orderBook/llt_eth
http://data.bter.com/api2/1/orderBook/llt_cny
http://data.bter.com/api2/1/orderBook/dpy_eth
http://data.bter.com/api2/1/orderBook/etp_btc
http://data.bter.com/api2/1/orderBook/etp_cny
http://data.bter.com/api2/1/orderBook/oax_btc
http://data.bter.com/api2/1/orderBook/oax_eth
http://data.bter.com/api2/1/orderBook/ubc_btc
http://data.bter.com/api2/1/orderBook/ubc_eth
http://data.bter.com/api2/1/orderBook/lrc_eth
http://data.bter.com/api2/1/orderBook/lrc_cny
http://data.bter.com/api2/1/orderBook/pst_btc
http://data.bter.com/api2/1/orderBook/pst_eth
http://data.bter.com/api2/1/orderBook/pst_cny
http://data.bter.com/api2/1/orderBook/tnt_eth
http://data.bter.com/api2/1/orderBook/tnt_cny
http://data.bter.com/api2/1/orderBook/bts_cny
http://data.bter.com/api2/1/orderBook/cnc_cny
http://data.bter.com/api2/1/orderBook/rep_cny
http://data.bter.com/api2/1/orderBook/bat_cny
http://data.bter.com/api2/1/orderBook/snt_cny
http://data.bter.com/api2/1/orderBook/snt_btc
http://data.bter.com/api2/1/orderBook/snt_eth
http://data.bter.com/api2/1/orderBook/btm_eth
http://data.bter.com/api2/1/orderBook/omg_cny
http://data.bter.com/api2/1/orderBook/omg_btc
http://data.bter.com/api2/1/orderBook/omg_eth
http://data.bter.com/api2/1/orderBook/pay_cny
http://data.bter.com/api2/1/orderBook/pay_btc
http://data.bter.com/api2/1/orderBook/pay_eth
http://data.bter.com/api2/1/orderBook/bat_eth
http://data.bter.com/api2/1/orderBook/ico_cny
http://data.bter.com/api2/1/orderBook/ico_btc
http://data.bter.com/api2/1/orderBook/ico_eth
http://data.bter.com/api2/1/orderBook/cvc_cny
http://data.bter.com/api2/1/orderBook/cvc_btc
http://data.bter.com/api2/1/orderBook/cvc_eth
http://data.bter.com/api2/1/orderBook/doc_cny
http://data.bter.com/api2/1/orderBook/doc_btc
http://data.bter.com/api2/1/orderBook/storj_cny
http://data.bter.com/api2/1/orderBook/storj_btc
http://data.bter.com/api2/1/orderBook/storj_eth
http://data.bter.com/api2/1/orderBook/eos_cny
http://data.bter.com/api2/1/orderBook/eos_btc
http://data.bter.com/api2/1/orderBook/eos_eth
http://data.bter.com/api2/1/orderBook/doge_cny
http://data.bter.com/api2/1/orderBook/dash_cny
http://data.bter.com/api2/1/orderBook/eth_cny
http://data.bter.com/api2/1/orderBook/etc_cny
http://data.bter.com/api2/1/orderBook/exc_cny
http://data.bter.com/api2/1/orderBook/ftc_cny
http://data.bter.com/api2/1/orderBook/ifc_cny
http://data.bter.com/api2/1/orderBook/nmc_cny
http://data.bter.com/api2/1/orderBook/nxt_cny
http://data.bter.com/api2/1/orderBook/ppc_cny
http://data.bter.com/api2/1/orderBook/shell_cny
http://data.bter.com/api2/1/orderBook/tips_cny
http://data.bter.com/api2/1/orderBook/tix_cny
http://data.bter.com/api2/1/orderBook/xcp_cny
http://data.bter.com/api2/1/orderBook/xmr_cny
http://data.bter.com/api2/1/orderBook/xpm_cny
http://data.bter.com/api2/1/orderBook/xtc_cny
http://data.bter.com/api2/1/orderBook/ltc_btc
http://data.bter.com/api2/1/orderBook/bts_btc
http://data.bter.com/api2/1/orderBook/cnc_btc
http://data.bter.com/api2/1/orderBook/rep_btc
http://data.bter.com/api2/1/orderBook/bat_btc
http://data.bter.com/api2/1/orderBook/hkg_btc
http://data.bter.com/api2/1/orderBook/doge_btc
http://data.bter.com/api2/1/orderBook/dash_btc
http://data.bter.com/api2/1/orderBook/eth_btc
http://data.bter.com/api2/1/orderBook/etc_btc
http://data.bter.com/api2/1/orderBook/ftc_btc
http://data.bter.com/api2/1/orderBook/nmc_btc
http://data.bter.com/api2/1/orderBook/nxt_btc
http://data.bter.com/api2/1/orderBook/ppc_btc
http://data.bter.com/api2/1/orderBook/xtc_btc
http://data.bter.com/api2/1/orderBook/xcn_btc
http://data.bter.com/api2/1/orderBook/xcp_btc
http://data.bter.com/api2/1/orderBook/xem_btc
http://data.bter.com/api2/1/orderBook/xem_cny
http://data.bter.com/api2/1/orderBook/xpm_btc
http://data.bter.com/api2/1/orderBook/xmr_btc
http://data.bter.com/api2/1/orderBook/mg_btc
http://data.bter.com/api2/1/orderBook/ifc_ltc
http://data.bter.com/api2/1/orderBook/tips_ltc
http://data.bter.com/api2/1/orderBook/tix_ltc
http://data.bter.com/api2/1/orderBook/etc_eth
http://data.bter.com/api2/1/orderBook/zec_btc
http://data.bter.com/api2/1/orderBook/zec_cny

Trade History API

Return the most recent 80 trade history records:

URL: http://data.bter.com/api2/1/trade/[CURR_A]_[CURR_B]

Return at most 1,000 trade history records after [TID]:

URL: http://data.bter.com/api2/1/tradeHistory/[CURR_A]_[CURR_B]/[TID]

Replace [CURR_A] and [CURR_B] with the selected currencies.

Links:

http://data.bter.com/api2/1/tradeHistory/btc_cny
http://data.bter.com/api2/1/tradeHistory/ltc_cny
http://data.bter.com/api2/1/tradeHistory/xrp_cny
http://data.bter.com/api2/1/tradeHistory/xrp_btc
http://data.bter.com/api2/1/tradeHistory/bcc_cny
http://data.bter.com/api2/1/tradeHistory/bcc_btc
http://data.bter.com/api2/1/tradeHistory/qtum_btc
http://data.bter.com/api2/1/tradeHistory/qtum_eth
http://data.bter.com/api2/1/tradeHistory/qtum_cny
http://data.bter.com/api2/1/tradeHistory/zrx_btc
http://data.bter.com/api2/1/tradeHistory/zrx_eth
http://data.bter.com/api2/1/tradeHistory/zrx_cny
http://data.bter.com/api2/1/tradeHistory/dnt_btc
http://data.bter.com/api2/1/tradeHistory/dnt_eth
http://data.bter.com/api2/1/tradeHistory/dnt_cny
http://data.bter.com/api2/1/tradeHistory/llt_eth
http://data.bter.com/api2/1/tradeHistory/llt_cny
http://data.bter.com/api2/1/tradeHistory/dpy_eth
http://data.bter.com/api2/1/tradeHistory/etp_btc
http://data.bter.com/api2/1/tradeHistory/etp_cny
http://data.bter.com/api2/1/tradeHistory/oax_btc
http://data.bter.com/api2/1/tradeHistory/oax_eth
http://data.bter.com/api2/1/tradeHistory/ubc_btc
http://data.bter.com/api2/1/tradeHistory/ubc_eth
http://data.bter.com/api2/1/tradeHistory/lrc_eth
http://data.bter.com/api2/1/tradeHistory/lrc_cny
http://data.bter.com/api2/1/tradeHistory/pst_btc
http://data.bter.com/api2/1/tradeHistory/pst_eth
http://data.bter.com/api2/1/tradeHistory/pst_cny
http://data.bter.com/api2/1/tradeHistory/tnt_eth
http://data.bter.com/api2/1/tradeHistory/tnt_cny
http://data.bter.com/api2/1/tradeHistory/bts_cny
http://data.bter.com/api2/1/tradeHistory/cnc_cny
http://data.bter.com/api2/1/tradeHistory/rep_cny
http://data.bter.com/api2/1/tradeHistory/bat_cny
http://data.bter.com/api2/1/tradeHistory/snt_cny
http://data.bter.com/api2/1/tradeHistory/snt_btc
http://data.bter.com/api2/1/tradeHistory/snt_eth
http://data.bter.com/api2/1/tradeHistory/btm_eth
http://data.bter.com/api2/1/tradeHistory/omg_cny
http://data.bter.com/api2/1/tradeHistory/omg_btc
http://data.bter.com/api2/1/tradeHistory/omg_eth
http://data.bter.com/api2/1/tradeHistory/pay_cny
http://data.bter.com/api2/1/tradeHistory/pay_btc
http://data.bter.com/api2/1/tradeHistory/pay_eth
http://data.bter.com/api2/1/tradeHistory/bat_eth
http://data.bter.com/api2/1/tradeHistory/ico_cny
http://data.bter.com/api2/1/tradeHistory/ico_btc
http://data.bter.com/api2/1/tradeHistory/ico_eth
http://data.bter.com/api2/1/tradeHistory/cvc_cny
http://data.bter.com/api2/1/tradeHistory/cvc_btc
http://data.bter.com/api2/1/tradeHistory/cvc_eth
http://data.bter.com/api2/1/tradeHistory/doc_cny
http://data.bter.com/api2/1/tradeHistory/doc_btc
http://data.bter.com/api2/1/tradeHistory/storj_cny
http://data.bter.com/api2/1/tradeHistory/storj_btc
http://data.bter.com/api2/1/tradeHistory/storj_eth
http://data.bter.com/api2/1/tradeHistory/eos_cny
http://data.bter.com/api2/1/tradeHistory/eos_btc
http://data.bter.com/api2/1/tradeHistory/eos_eth
http://data.bter.com/api2/1/tradeHistory/doge_cny
http://data.bter.com/api2/1/tradeHistory/dash_cny
http://data.bter.com/api2/1/tradeHistory/eth_cny
http://data.bter.com/api2/1/tradeHistory/etc_cny
http://data.bter.com/api2/1/tradeHistory/exc_cny
http://data.bter.com/api2/1/tradeHistory/ftc_cny
http://data.bter.com/api2/1/tradeHistory/ifc_cny
http://data.bter.com/api2/1/tradeHistory/nmc_cny
http://data.bter.com/api2/1/tradeHistory/nxt_cny
http://data.bter.com/api2/1/tradeHistory/ppc_cny
http://data.bter.com/api2/1/tradeHistory/shell_cny
http://data.bter.com/api2/1/tradeHistory/tips_cny
http://data.bter.com/api2/1/tradeHistory/tix_cny
http://data.bter.com/api2/1/tradeHistory/xcp_cny
http://data.bter.com/api2/1/tradeHistory/xmr_cny
http://data.bter.com/api2/1/tradeHistory/xpm_cny
http://data.bter.com/api2/1/tradeHistory/xtc_cny
http://data.bter.com/api2/1/tradeHistory/ltc_btc
http://data.bter.com/api2/1/tradeHistory/bts_btc
http://data.bter.com/api2/1/tradeHistory/cnc_btc
http://data.bter.com/api2/1/tradeHistory/rep_btc
http://data.bter.com/api2/1/tradeHistory/bat_btc
http://data.bter.com/api2/1/tradeHistory/hkg_btc
http://data.bter.com/api2/1/tradeHistory/doge_btc
http://data.bter.com/api2/1/tradeHistory/dash_btc
http://data.bter.com/api2/1/tradeHistory/eth_btc
http://data.bter.com/api2/1/tradeHistory/etc_btc
http://data.bter.com/api2/1/tradeHistory/ftc_btc
http://data.bter.com/api2/1/tradeHistory/nmc_btc
http://data.bter.com/api2/1/tradeHistory/nxt_btc
http://data.bter.com/api2/1/tradeHistory/ppc_btc
http://data.bter.com/api2/1/tradeHistory/xtc_btc
http://data.bter.com/api2/1/tradeHistory/xcn_btc
http://data.bter.com/api2/1/tradeHistory/xcp_btc
http://data.bter.com/api2/1/tradeHistory/xem_btc
http://data.bter.com/api2/1/tradeHistory/xem_cny
http://data.bter.com/api2/1/tradeHistory/xpm_btc
http://data.bter.com/api2/1/tradeHistory/xmr_btc
http://data.bter.com/api2/1/tradeHistory/mg_btc
http://data.bter.com/api2/1/tradeHistory/ifc_ltc
http://data.bter.com/api2/1/tradeHistory/tips_ltc
http://data.bter.com/api2/1/tradeHistory/tix_ltc
http://data.bter.com/api2/1/tradeHistory/etc_eth
http://data.bter.com/api2/1/tradeHistory/zec_btc
http://data.bter.com/api2/1/tradeHistory/zec_cny


Trade API

The following APIs can be used for auto-trading in a program.
Notice: please set Content-Type to application/x-www-form-urlencoded in your HTTP request header if it's not the default value.

Click here to obtain a Key and Secret. Use the the Secret as a passphrase to sign the POST data in SHA512 encryption. Send the Key and Sign back in HTTPS Header for Authentication. Please refer to the following instructions and PHP example codes.

Get account fund balances API

API URL: https://api.bter.com/api2/1/private/balances

Parameter submission method: POST

Parameter: None

Return data format: JSON

Return data example:

	{
		"result":"true",
		"available":{
			"CNY":"1122.16",
			"BTC":"0.83337671",
			"LTC":"94.364",
			"YAC":"0.07161",
			"WDC":"82.35029899"
		},
		"locked":{
			"BTC":"0.0002",
			"YAC":"10.01"
		}
	}
				


get deposit address API

API URL: https://bter.com/api2/1/private/depositAddress

Parameter submission method: POST

Parameter:

Parameter Description Example
currency 币种 LTC

Return data format: JSON

Return data example:

	{
		"result":"true",
		"addr":{
			"LQ6sF9nsQssZST7YtLnMBwE3dVWqoDdrPc "
		}
	}
				


get new address API

API URL: https://bter.com/api2/1/private/newAddress

Parameter submission method: POST

Parameter:

Parameter Description Example
currency currency of new address LTC

Return data format: JSON

Return data example:

	{
		"result":"true",
		"addr":{
			"LQ6sF9nsQssZST7YtLnMBwE3dVWqoDdrPc "
		}
	}
				


get deposit withdrawal history API

API URL: https://bter.com/api2/1/private/depositsWithdrawals

Parameter submission method: POST

Parameter:

Parameter Description Example
start start UNIX time 1469092370
end end UNIX time 1469713981

Return data format: JSON

Return data example:

	{
		"result": "true",
		"deposits": [
			{
				"currency": "BTS",
				"address": "addr1",
				"amount": "800000000",
				"txid": "ab1efaba6a911f62d4eb88a7ac515cfe82f18f41",
				"timestamp": "1469092378",
				"status": "DONE"
			}
		
		],
		"withdraws": [
			{
				"currency": "BTS",
				"address": "addr2",
				"amount": "600000000",
				"txid": "afsad33eda911f62d4eb88fasd7fd89af7d9fs32",
				"timestamp": "1469092378",
				"status": "DONE"
			}
		],
		"message": "Success"
	}
				


Place order buy API

API URL: https://api.bter.com/api2/1/private/buy

Parameter submission method: POST

Parameter:

Parameter Description Example
currencyPair currency pair ltc_btc
rate The rate to buy 0.023
amount The amount to buy 100

Return data format: JSON

Return data example:

	{
		"result":"true",
		"orderNumber":"123456",
		"msg":"Success"
	}
				

Notice: The returned orderNumber can be used for cancelling or getting order.


Place order sell API

API URL: https://api.bter.com/api2/1/private/sell

Parameter submission method: POST

Parameter:

Parameter Description Example
currencyPair currency pair ltc_btc
rate The rate to buy 0.023
amount The amount to buy 100

Return data format: JSON

Return data example:

	{
		"result":"true",
		"orderNumber":"123456",
		"msg":"Success"
	}
				

Notice: The returned orderNumber can be used for cancelling or getting order.


Cancel order API

API URL: https://api.bter.com/api2/1/private/cancelOrder

Parameter submission method: POST

Parameter:

Parameter Description Example
orderNumber Order ID 123456

Return data format: JSON

Return data example:

	{
		"result":"true",
		"msg":"Success"
	}
				


Cancel all orders API

API URL: https://bter.com/api2/1/private/cancelAllOrders

Parameter submission method: POST

Parameter:

Parameter Description Example
type order type(0:sell,1:buy,-1:all) 0
currencyPair currency pair ltc_btc

Return data format: JSON

Return data example:

	{
		"result":"true",
		"message":"Success"
	}
				


Get order status API

API URL: https://api.bter.com/api2/1/private/getOrder

Parameter submission method: POST

Parameter:

Parameter Description Example
orderNumber Order ID 123456
currencyPair Pair ltc_btc

Return data format: JSON

Return data example:


	{
		"result":true,
		"order":{
			"id":"15088",
			"status":"cancelled",
			"pair":"btc_cny",
			"type":"sell",
			"rate":811,
			"amount":"0.39901357",
			"initial_rate":811,
			"initial_amount":"1"
		},
		"msg":"Success"
	}

				


Get my open order list API

API URL: https://api.bter.com/api2/1/private/openOrders

Parameter submission method: POST

Parameter: None

Return data format: JSON

Return data example:


	{
		"result":"true",
		"orders": [
			{
				"id": "3",
				"orderNumber": "0",
				"type": "sell",
				"rate": 0.0098,
				"amount": "100000",
				"total": "980",
				"currencyPair": "doge_cny",
				"timestamp": "1470648164",
				"status": "open"
			},
			{
				"id": "5",
				"orderNumber": "0",
				"type": "sell",
				"rate": 0.00000204,
				"amount": "1000204",
				"total": "2.04041616",
				"currencyPair": "doge_btc",
				"timestamp": "1470648850",
				"status": "open"
			}
		],
		"message":"Success"
	}

				


Get my last 24h trades API

API URL: https://api.bter.com/api2/1/private/tradeHistory

Parameter submission method: POST

Parameter:

Parameter Description Example
currencyPair currency pair ltc_btc
orderNumber Order ID (optional) 626150

Return data format: JSON

Return data example:


	{
		"result":"true",
		"trades":[
		    {
		      "id":"7942422"
		      "orderid":"38100777"
		      "pair":"ltc_btc"
		      "type":"sell"
		      "rate":"0.01719"
		      "amount":"0.0588"
		      "time":"06-12 02:49:11"
		      "time_unix":"1402512551"
		    }
		    {
		      "id":"7942422"
		      "orderid":"38100491"
		      "pair":"ltc_btc"
		      "type":"buy"
		      "rate":"0.01719"
		      "amount":"0.0588"
		      "time":"06-12 02:49:11"
		      "time_unix":"1402512551"
		    }
	  	]
	  	"message":"Success"
	}


				


withdrawal API

API URL: https://api.bter.com/api2/1/private/withdraw

Parameter submission method: POST

Parameter:

Parameter Description Example
currency withdraw currency btc
amount withdraw amount 0.01
address withdraw address 1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs

Return data format: JSON

Return data example:

	{
		"result":"true",
		"message":"Success"
	}
				


Example codes in PHP

				

<?php

	function bter_query($path, array $req = array()) {
		// API settings, add your Key and Secret at here
		$key = '';
		$secret = '';
	 
		// generate a nonce to avoid problems with 32bits systems
		$mt = explode(' ', microtime());
		$req['nonce'] = $mt[1].substr($mt[0], 2, 6);
	 
		// generate the POST data string
		$post_data = http_build_query($req, '', '&');
		$sign = hash_hmac('sha512', $post_data, $secret);
	 
		// generate the extra headers
		$headers = array(
			'KEY: '.$key,
			'SIGN: '.$sign
		);

		//!!! please set Content-Type to application/x-www-form-urlencoded if it's not the default value

		// curl handle (initialize if required)
		static $ch = null;
		if (is_null($ch)) {
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Bter PHP bot; '.php_uname('a').'; PHP/'.phpversion().')');
		}
		
		curl_setopt($ch, CURLOPT_URL, 'https://bter.com/api2/'.$path);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);


		// run the query
		$res = curl_exec($ch);
		
		if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
		//var_dump($res);
		//print_r($res);
		$dec = json_decode($res, true);
		if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists: '.$res);

		return $dec;
	}
 
	
	function curl_file_get_contents($url) {
		
		// our curl handle (initialize if required)
		static $ch = null;
		if (is_null($ch)) {
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_USERAGENT, 
				'Mozilla/4.0 (compatible; Bter PHP bot; '.php_uname('a').'; PHP/'.phpversion().')'
				);
		}
		curl_setopt($ch, CURLOPT_URL, 'https://bter.com/api2/'.$url);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

		// run the query
		$res = curl_exec($ch);
		if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
		//echo $res;
		$dec = json_decode($res, true);
		if (!$dec) throw new Exception('Invalid data: '.$res);
		
		return $dec;
	}

	function get_top_rate($currency_pair, $type='BUY') {
		
		$url = '1/orderBook/'.strtoupper($currency_pair);
		$json = curl_file_get_contents($url);
		
		$rate = 0;

		if (strtoupper($type) == 'BUY') {
			$r =  $json['bids'][0];
			$rate = $r[0];
		} else  {
			$r = end($json['asks']);
			$rate = $r[0];
		}

		return $rate;
	}	
	
	function get_pairs() {
		
		$url = '1/pairs';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	
	function get_marketinfo(){
		
		$url = '1/marketinfo';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_tickers(){
		
		$url = '1/tickers';
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_ticker($current_pairs){
		
		$url = '1/ticker/'.strtoupper($current_pairs);
		$json = curl_file_get_contents($url);
		
		return $json;		
	}
	 
	function get_orderbooks(){
		
		$url = '1/orderBooks';
		$json = curl_file_get_contents($url);
		
		return $json;
	}
	 
	function get_orderbook($current_pairs){
		
		$url = '1/orderBooks/'.strtoupper($current_pairs);
		$json = curl_file_get_contents($url);
		
		return $json;
	}
	 
	function get_trade_history($current_pairs, $tid){
		
		$url = '1/tradeHistory/'.strtoupper($current_pairs).'/'.$tid;
		$json = curl_file_get_contents($url);
		
		return $json;
	}	
	
	function get_balances() {
		
		return bter_query('1/private/balances');		
	}
	
	function get_order_trades($order_number) {
		
		return bter_query('1/private/orderTrades',
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function withdraw($currency, $amount, $address) {
		
		return bter_query('1/private/withdraw',
			array(
				'currency' => strtoupper($currency),
				'amount' => $amount,
				'address' => $address
			)
		);
	}
	
	function get_order($order_number) {
		
		return bter_query('1/private/getOrder', 
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function cancel_order($order_number) {
		
		return bter_query('1/private/cancelOrder',
			array(
				'orderNumber' => $order_number
			)
		);
	}
	
	function cancel_all_orders($type, $currency_pair) {
		
		return bter_query('1/private/cancelAllOrders',
			array(
				'type' => $type,
				'currencyPair' => strtoupper($currency_pair)
			)
		);
	}
	
	function sell($currency_pair, $rate, $amount) {
		
		return bter_query('1/private/sell',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'rate' => $rate,
				'amount' => $amount,
			)
		);
	}
	
	function buy($currency_pair, $rate, $amount) {
		
		return bter_query('1/private/buy',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'rate' => $rate,
				'amount' => $amount,
			)
		);
	}
	
	function get_my_trade_history($currency_pair, $order_number) {
		
		return bter_query('1/private/tradeHistory',
			array(
				'currencyPair' => strtoupper($currency_pair),
				'orderNumber' => $order_number
			)
		);
	}
	
	function open_orders() {
		
		return bter_query('1/private/openOrders');
	}
	
	function deposit_address($currency) {
		
		return bter_query('1/private/depositAddress',
			array(
				'currency' => strtoupper($currency)
			)
		);
	}


	try {
		// example 1: get balances
		var_dump(get_balances());
		
		// example 2: place a buy order
		$pair = 'ltc_btc';
		$rate = get_top_rate($pair, $type) * 1.01;
		var_dump(buy($pair, $rate, '0.01'));
		
		// example 3: cancel an order
		var_dump(cancel_order(125811));
		
		// example 4: get order status
		var_dump(get_order(15088));
		
		// example 5: list all open orders
		var_dump(open_orders());

	} catch (Exception $e) {
		echo "Error:".$e->getMessage();
		
	}
?>