• BTC : ¥18652.00
  • LTC : ¥309.00
  • ETH : ¥1549.00
  • ETC : ¥108.90
  • QTUM : ¥50.64

比特儿API

1. 所有交易对 API

返回所有系统支持的交易对

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


2. 交易市场订单参数 API

返回所有系统支持的交易市场的参数信息,包括交易费,最小下单量,价格精度等。

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


3. 交易市场详细行情 API

返回所有系统支持的交易市场的详细行情和币种信息,包括币种名,市值,供应量,最新价格,涨跌趋势,价格曲线等。

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


4. 所有交易行情 API

返回系统支持的所有交易对的 最新,最高,最低 交易行情和交易量,每10秒钟更新:

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


5. 单项交易行情 API

返回最新,最高,最低 交易行情和交易量,每10秒钟更新:

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

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

http://data.bter.com/api/1/ticker/btc_cny
http://data.bter.com/api/1/ticker/ltc_cny
http://data.bter.com/api/1/ticker/xrp_cny
http://data.bter.com/api/1/ticker/xrp_btc
http://data.bter.com/api/1/ticker/qtum_btc
http://data.bter.com/api/1/ticker/qtum_cny
http://data.bter.com/api/1/ticker/etp_btc
http://data.bter.com/api/1/ticker/etp_cny
http://data.bter.com/api/1/ticker/btrx_cny
http://data.bter.com/api/1/ticker/btrx_btc
http://data.bter.com/api/1/ticker/bts_cny
http://data.bter.com/api/1/ticker/cnc_cny
http://data.bter.com/api/1/ticker/rep_cny
http://data.bter.com/api/1/ticker/bat_cny
http://data.bter.com/api/1/ticker/snt_cny
http://data.bter.com/api/1/ticker/snt_btc
http://data.bter.com/api/1/ticker/snt_eth
http://data.bter.com/api/1/ticker/bat_eth
http://data.bter.com/api/1/ticker/ico_cny
http://data.bter.com/api/1/ticker/ico_btc
http://data.bter.com/api/1/ticker/ico_eth
http://data.bter.com/api/1/ticker/eos_cny
http://data.bter.com/api/1/ticker/eos_btc
http://data.bter.com/api/1/ticker/eos_eth
http://data.bter.com/api/1/ticker/doge_cny
http://data.bter.com/api/1/ticker/dash_cny
http://data.bter.com/api/1/ticker/eth_cny
http://data.bter.com/api/1/ticker/etc_cny
http://data.bter.com/api/1/ticker/exc_cny
http://data.bter.com/api/1/ticker/ftc_cny
http://data.bter.com/api/1/ticker/ifc_cny
http://data.bter.com/api/1/ticker/nmc_cny
http://data.bter.com/api/1/ticker/nxt_cny
http://data.bter.com/api/1/ticker/ppc_cny
http://data.bter.com/api/1/ticker/shell_cny
http://data.bter.com/api/1/ticker/tips_cny
http://data.bter.com/api/1/ticker/tix_cny
http://data.bter.com/api/1/ticker/xcp_cny
http://data.bter.com/api/1/ticker/xmr_cny
http://data.bter.com/api/1/ticker/xpm_cny
http://data.bter.com/api/1/ticker/xtc_cny
http://data.bter.com/api/1/ticker/ltc_btc
http://data.bter.com/api/1/ticker/bts_btc
http://data.bter.com/api/1/ticker/cnc_btc
http://data.bter.com/api/1/ticker/rep_btc
http://data.bter.com/api/1/ticker/bat_btc
http://data.bter.com/api/1/ticker/hkg_btc
http://data.bter.com/api/1/ticker/doge_btc
http://data.bter.com/api/1/ticker/dash_btc
http://data.bter.com/api/1/ticker/eth_btc
http://data.bter.com/api/1/ticker/etc_btc
http://data.bter.com/api/1/ticker/ftc_btc
http://data.bter.com/api/1/ticker/nmc_btc
http://data.bter.com/api/1/ticker/nxt_btc
http://data.bter.com/api/1/ticker/ppc_btc
http://data.bter.com/api/1/ticker/xtc_btc
http://data.bter.com/api/1/ticker/xcn_btc
http://data.bter.com/api/1/ticker/xcp_btc
http://data.bter.com/api/1/ticker/xem_btc
http://data.bter.com/api/1/ticker/xem_cny
http://data.bter.com/api/1/ticker/xpm_btc
http://data.bter.com/api/1/ticker/xmr_btc
http://data.bter.com/api/1/ticker/mg_btc
http://data.bter.com/api/1/ticker/ifc_ltc
http://data.bter.com/api/1/ticker/tips_ltc
http://data.bter.com/api/1/ticker/tix_ltc
http://data.bter.com/api/1/ticker/etc_eth
http://data.bter.com/api/1/ticker/zec_btc
http://data.bter.com/api/1/ticker/zec_cny

6. 市场深度 API

返回当前市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。

URL: http://data.bter.com/api/1/depth/[CURR_A]_[CURR_B]

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

http://data.bter.com/api/1/depth/btc_cny
http://data.bter.com/api/1/depth/ltc_cny
http://data.bter.com/api/1/depth/xrp_cny
http://data.bter.com/api/1/depth/xrp_btc
http://data.bter.com/api/1/depth/qtum_btc
http://data.bter.com/api/1/depth/qtum_cny
http://data.bter.com/api/1/depth/etp_btc
http://data.bter.com/api/1/depth/etp_cny
http://data.bter.com/api/1/depth/btrx_cny
http://data.bter.com/api/1/depth/btrx_btc
http://data.bter.com/api/1/depth/bts_cny
http://data.bter.com/api/1/depth/cnc_cny
http://data.bter.com/api/1/depth/rep_cny
http://data.bter.com/api/1/depth/bat_cny
http://data.bter.com/api/1/depth/snt_cny
http://data.bter.com/api/1/depth/snt_btc
http://data.bter.com/api/1/depth/snt_eth
http://data.bter.com/api/1/depth/bat_eth
http://data.bter.com/api/1/depth/ico_cny
http://data.bter.com/api/1/depth/ico_btc
http://data.bter.com/api/1/depth/ico_eth
http://data.bter.com/api/1/depth/eos_cny
http://data.bter.com/api/1/depth/eos_btc
http://data.bter.com/api/1/depth/eos_eth
http://data.bter.com/api/1/depth/doge_cny
http://data.bter.com/api/1/depth/dash_cny
http://data.bter.com/api/1/depth/eth_cny
http://data.bter.com/api/1/depth/etc_cny
http://data.bter.com/api/1/depth/exc_cny
http://data.bter.com/api/1/depth/ftc_cny
http://data.bter.com/api/1/depth/ifc_cny
http://data.bter.com/api/1/depth/nmc_cny
http://data.bter.com/api/1/depth/nxt_cny
http://data.bter.com/api/1/depth/ppc_cny
http://data.bter.com/api/1/depth/shell_cny
http://data.bter.com/api/1/depth/tips_cny
http://data.bter.com/api/1/depth/tix_cny
http://data.bter.com/api/1/depth/xcp_cny
http://data.bter.com/api/1/depth/xmr_cny
http://data.bter.com/api/1/depth/xpm_cny
http://data.bter.com/api/1/depth/xtc_cny
http://data.bter.com/api/1/depth/ltc_btc
http://data.bter.com/api/1/depth/bts_btc
http://data.bter.com/api/1/depth/cnc_btc
http://data.bter.com/api/1/depth/rep_btc
http://data.bter.com/api/1/depth/bat_btc
http://data.bter.com/api/1/depth/hkg_btc
http://data.bter.com/api/1/depth/doge_btc
http://data.bter.com/api/1/depth/dash_btc
http://data.bter.com/api/1/depth/eth_btc
http://data.bter.com/api/1/depth/etc_btc
http://data.bter.com/api/1/depth/ftc_btc
http://data.bter.com/api/1/depth/nmc_btc
http://data.bter.com/api/1/depth/nxt_btc
http://data.bter.com/api/1/depth/ppc_btc
http://data.bter.com/api/1/depth/xtc_btc
http://data.bter.com/api/1/depth/xcn_btc
http://data.bter.com/api/1/depth/xcp_btc
http://data.bter.com/api/1/depth/xem_btc
http://data.bter.com/api/1/depth/xem_cny
http://data.bter.com/api/1/depth/xpm_btc
http://data.bter.com/api/1/depth/xmr_btc
http://data.bter.com/api/1/depth/mg_btc
http://data.bter.com/api/1/depth/ifc_ltc
http://data.bter.com/api/1/depth/tips_ltc
http://data.bter.com/api/1/depth/tix_ltc
http://data.bter.com/api/1/depth/etc_eth
http://data.bter.com/api/1/depth/zec_btc
http://data.bter.com/api/1/depth/zec_cny

7. 历史成交记录 API

返回最新80条历史成交记录:

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

返回从[TID]往后的最多1000历史成交记录:

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

请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.

支持的兑换类型:

http://data.bter.com/api/1/trade/btc_cny
http://data.bter.com/api/1/trade/ltc_cny
http://data.bter.com/api/1/trade/xrp_cny
http://data.bter.com/api/1/trade/xrp_btc
http://data.bter.com/api/1/trade/qtum_btc
http://data.bter.com/api/1/trade/qtum_cny
http://data.bter.com/api/1/trade/etp_btc
http://data.bter.com/api/1/trade/etp_cny
http://data.bter.com/api/1/trade/btrx_cny
http://data.bter.com/api/1/trade/btrx_btc
http://data.bter.com/api/1/trade/bts_cny
http://data.bter.com/api/1/trade/cnc_cny
http://data.bter.com/api/1/trade/rep_cny
http://data.bter.com/api/1/trade/bat_cny
http://data.bter.com/api/1/trade/snt_cny
http://data.bter.com/api/1/trade/snt_btc
http://data.bter.com/api/1/trade/snt_eth
http://data.bter.com/api/1/trade/bat_eth
http://data.bter.com/api/1/trade/ico_cny
http://data.bter.com/api/1/trade/ico_btc
http://data.bter.com/api/1/trade/ico_eth
http://data.bter.com/api/1/trade/eos_cny
http://data.bter.com/api/1/trade/eos_btc
http://data.bter.com/api/1/trade/eos_eth
http://data.bter.com/api/1/trade/doge_cny
http://data.bter.com/api/1/trade/dash_cny
http://data.bter.com/api/1/trade/eth_cny
http://data.bter.com/api/1/trade/etc_cny
http://data.bter.com/api/1/trade/exc_cny
http://data.bter.com/api/1/trade/ftc_cny
http://data.bter.com/api/1/trade/ifc_cny
http://data.bter.com/api/1/trade/nmc_cny
http://data.bter.com/api/1/trade/nxt_cny
http://data.bter.com/api/1/trade/ppc_cny
http://data.bter.com/api/1/trade/shell_cny
http://data.bter.com/api/1/trade/tips_cny
http://data.bter.com/api/1/trade/tix_cny
http://data.bter.com/api/1/trade/xcp_cny
http://data.bter.com/api/1/trade/xmr_cny
http://data.bter.com/api/1/trade/xpm_cny
http://data.bter.com/api/1/trade/xtc_cny
http://data.bter.com/api/1/trade/ltc_btc
http://data.bter.com/api/1/trade/bts_btc
http://data.bter.com/api/1/trade/cnc_btc
http://data.bter.com/api/1/trade/rep_btc
http://data.bter.com/api/1/trade/bat_btc
http://data.bter.com/api/1/trade/hkg_btc
http://data.bter.com/api/1/trade/doge_btc
http://data.bter.com/api/1/trade/dash_btc
http://data.bter.com/api/1/trade/eth_btc
http://data.bter.com/api/1/trade/etc_btc
http://data.bter.com/api/1/trade/ftc_btc
http://data.bter.com/api/1/trade/nmc_btc
http://data.bter.com/api/1/trade/nxt_btc
http://data.bter.com/api/1/trade/ppc_btc
http://data.bter.com/api/1/trade/xtc_btc
http://data.bter.com/api/1/trade/xcn_btc
http://data.bter.com/api/1/trade/xcp_btc
http://data.bter.com/api/1/trade/xem_btc
http://data.bter.com/api/1/trade/xem_cny
http://data.bter.com/api/1/trade/xpm_btc
http://data.bter.com/api/1/trade/xmr_btc
http://data.bter.com/api/1/trade/mg_btc
http://data.bter.com/api/1/trade/ifc_ltc
http://data.bter.com/api/1/trade/tips_ltc
http://data.bter.com/api/1/trade/tix_ltc
http://data.bter.com/api/1/trade/etc_eth
http://data.bter.com/api/1/trade/zec_btc
http://data.bter.com/api/1/trade/zec_cny

8. 自动交易 API

通过以下API,用户可以使用程序控制自动进行账号资金查询,下单交易,取消挂单。
请注意:请在您的程序中设置的HTTP请求头参数 Content-Type 为 application/x-www-form-urlencoded

用户首先要通过这个链接获取API接口身份认证用到的Key和Secret。 然后在程序中用Secret作为密码,通过SHA512加密方式签名需要POST给服务器的数据得到Sign,并在HTTPS请求的Header部分传回Key和Sign。请参考以下接口说明和例子程序进行设置。

获取帐号资金余额API

API URL: https://api.bter.com/api/1/private/getfunds

参数数据提交方式:POST

参数:无

返回数据格式:JSON

返回数据例子:

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


下单交易API

API URL: https://api.bter.com/api/1/private/placeorder

参数数据提交方式:POST

参数:

参数 说明 示例
pair 交易币种对 ltc_btc
type 交易类型,卖出为 SELL, 买入为 BUY SELL 或者 BUY
rate 价格 0.023
amount 交易量 100

返回数据格式:JSON

返回数据例子:

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

注:返回的order_id可用于查询,取消订单。


取消下单API

API URL: https://api.bter.com/api/1/private/cancelorder

参数数据提交方式:POST

参数:

参数 说明 示例
order_id 下单单号 123456
pair 交易币种对 ltc_btc

返回数据格式:JSON

返回数据例子:

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


注:返回的order_id可用于查询,取消订单。


取消多个下单API

API URL: https://api.bter.com/api/1/private/cancelorders

参数数据提交方式:POST

参数:

参数 说明 示例
orders_json 下单单号和pair的json数据 [ { "id":"7942422" "pair":"ltc_btc" } { "id":"7942422" "pair":"ltc_btc" } ]

返回数据格式:JSON

返回数据例子:

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


获取下单状态API

API URL: https://api.bter.com/api/1/private/getorder

参数数据提交方式:POST

参数:

参数 说明 示例
order_id 下单单号 123456
pair 交易币种对 ltc_btc

返回数据格式:JSON

返回数据例子:


	{
		"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"
	}

				


获取我的当前挂单列表API

API URL: https://api.bter.com/api/1/private/orderlist

参数数据提交方式:POST

参数:无

返回数据格式:JSON

返回数据例子:


	{
		"result":true,
		"orders":[
			{
				"id":"15088",				
				"sell_type":"BTC",
				"buy_type":"LTC",				
				"sell_amount":"0.39901357",
				"buy_amount":"12.0",		
				"pair":"ltc_btc",
				"type":"buy",
				"rate":0.033251,
				"amount":"0.39901357",
				"initial_rate":0.033251,
				"initial_amount":"1"
				"status":"open"
			},
			{
				"id":"15092",				
				"sell_type":"LTC",
				"buy_type":"BTC",				
				"sell_amount":"13.0",
				"buy_amount":"0.4210",
				"pair":"ltc_btc",
				"type":"buy",
				"rate":0.0323846,
				"amount":"0.4210",
				"initial_rate":0.0323846,
				"initial_amount":"1"
				"status":"open"
			}
			]
		"msg":"Success"
	}

				


获取我的24小时内成交记录API

API URL: https://api.bter.com/api/1/private/mytrades

参数数据提交方式:POST

参数:

参数 说明 示例
pair 交易币种对 ltc_btc
order_id 下单单号(可选项) 626150

返回数据格式:JSON

返回数据例子:


	{
		"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"
		    }
	  	]
	  	"msg":"Success"
	}



				


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://api.bter.com/api/'.$path);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

		// run the query
		$res = curl_exec($ch);

		if ($res === false) throw new Exception('Curl error: '.curl_error($ch));
		//echo $res;
		$dec = json_decode($res, true);
		if (!$dec) throw new Exception('Invalid data: '.$res);
		return $dec;
	}
	 
	 function get_top_rate($pair, $type='BUY') {
		$rate = 0;

		// 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://api.bter.com/api/1/depth/'.$pair);
		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);
		
		if (strtoupper($type) == 'BUY') {
			$r =  $dec['bids'][0];
			$rate = $r[0];
		} else  {
			$r = end($dec['asks']);
			$rate = $r[0];
		}

		return $rate;
	}


	try {
		// example 1: get funds
		var_dump(bter_query('1/private/getfunds'));
		
		// example 2: place a buy order
		$pair = 'ltc_btc';
		$type = 'buy';
		$rate = get_top_rate($pair, $type) * 1.01;
		var_dump(bter_query('1/private/placeorder', 
			array(
				'pair' => "$pair",
				'type' => "$type",
				'rate' => "$rate",
				'amount' => '0.01',
				)
			  )
			);
		
		// example 3: cancel an order
		var_dump(bter_query('1/private/cancelorder', array('order_id' => 125811)));
		
		// example 4: get order status
		var_dump(bter_query('1/private/getorder', array('order_id' => 15088)));
		
		//example 5: list all open orders
		var_dump(bter_query('1/private/orderlist'));

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