mt logoMyToken
总市值:
0%
恐慌指数:
0%
币种:--
平台 --
ETH Gas:--
EN
USD
APP
Ap Store QR Code

Scan Download

比特时代 API 使用说明(附调用范例 )

收藏
分享
交易行情API / Trades API
返回系统支持的所有交易对的最高,最低 交易行情和交易量,每15秒钟更新。
Return the highest, lowest  trade and the vulome of trade pairs. Refreshed every 15 seconds.
所有币种交易API /  All Pairs
单个币种交易API / Single Pair
市场深度API / Depth API
返回当前市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。返回30条。
Return the trade depth (current orders). Asks for buyer's order and bids for seller's order. 30 items each.
历史成交API / History API
返回系统支持的历史成交记录,返回最新30条。
Return the trade history. 30 items for each call.
返回从[TID](交易数自递增id)往后的最多500条历史成交记录(以比特币对人民币和比特股对比特币为例)
Return 500 items from the TID (BTC_CNY and BTS_BTC for example).

获取账户余额 Get Account Balance
调用方式 / Method:POST
传入参数 / Value:
key,时代提供的32位公钥 / public key
time,挂单时的时间戳,单位为秒 / the timestamp or the order, measured by "second"
md5,使用md5(key_用户ID_skey_time),SKEY为32位密钥,顺序不可颠倒 / the result of md5(key_userID_skey_time), SKEY is the secret key
返回:
JSON格式的余额,含所有币种
挂单 Make an Orders
调用方式 / Method:POST
传入参数 / Value:
key,时代提供的32位公钥 / public key
time,挂单时的时间戳,单位为秒 / the timestamp or the order, measured by "second"
md5,使用md5(key_用户ID_skey_time),SKEY为32位密钥,顺序不可颠倒 / the result of md5(key_userID_skey_time), SKEY is the secret key
type,1为买入挂单,2为卖出挂单,不可为空 / the type of the order
mk_type,cny为人民币定价,btc为比特币定价,不可为空 / which market, BTC or CNY
price,价格,cny定价最多5位小数,btc定价最多8位小数,不同币种有所不同,以网站显示为准 / the price of  the order. decimal digits varies as per coins, you can get the decimal digits on our website
amount,数量,最多6位小数 / the amount of the order. 6 decimal digits at most
coinname,币名,比如BTC、DOGE、BTS / the Symbol of the coin. Ex: BTC, DOGE, BTS
返回 / Return:
succ,挂单成功 / successful
overBalance,账户余额不足 / insuffient balance
其它返回表示不同的错误,情况太多,暂不罗列,这种错误发生的可能性不大

撤单 Cancel an Order
调用方式 / Method:POST
传入参数 / Value:
key,时代提供的32位公钥 / public key
time,挂单时的时间戳,单位为秒 / the timestamp or the order, measured by "second"
md5,使用md5(key_用户ID_skey_time),SKEY为32位密钥,顺序不可颠倒 / the result of md5(key_userID_skey_time), SKEY is the secret key
mk_type,cny为人民币定价,btc为比特币定价,不可为空 / which market, BTC or CNY
order_id,要撤的单的ID the ID of the order you'd cancel
返回:
succ,撤单成功 / successful
overtime,该单不存在,或者已成交了 / order expired or traded

获取当前自己的挂单 Get Open Orders

http://www.btc38.com/trade/t_api/getOrderList.php
调用方式 / Method:POST
传入参数 / Value:
key,时代提供的32位公钥 / public key
time,挂单时的时间戳,单位为秒 / the timestamp or the order, measured by "second"
md5,使用md5(key_用户ID_skey_time),SKEY为32位密钥,顺序不可颠倒 / the result of md5(key_userID_skey_time), SKEY is the secret key
mk_type,cny为人民币定价,btc为比特币定价,不可为空 / which market, BTC or CNY
coinname,币名,比如BTC、LTC,不填则返回全部币种的挂单 / the coin's name. Eg. BTC、LTC. For default it will return order of all coins.
返回:
如果挂单为空,返回 [] / If there is no ordre, it will return []
如果挂单不为空,则返回比如 / if there is any order:
[{"order_id":"123", "order_type":"1", "order_coinname":"BTC", "order_amount":"23.232323", "order_price":"0.2929"}, {"order_id":"123", "order_type":"1", "order_coinname":"LTC","order_amount":"23.232323", "order_price":"0.2929"}]

行情API无须授权即可使用,交易API需要公钥和密钥,如果您需要使用自动交易API,请向我们的客服索取自动交易API的公钥和密钥。
Public Key and Secret Key are demanded to use the trade API. If you need it, pelase contact our customer service.
由于我们的分布式CDN对非HTTP请求做了限制,因此调用API时,您可能需要人为设置HTTP,以免被防火墙拦截。 调用API有技术方面的故障,请联系加 API 技术QQ 2805792922。
As the CDN has a technical strategy that limtes non-HTTP  calling, you may need to config the header the HTTP request, so as to avoid the request being filtered. For technical help, please contact 2805792922(a)qq.com .

附件:调用范例 / Demo (PHP)

$date = new DateTime();
$stamp = $date->getTimestamp();
$mdt = "这里写公钥_这里写用户ID_这里写私钥_" . $stamp;
$mdt = md5($mdt);
$data = array("key" => "这里写公钥", "time" => $stamp, "md5" => $mdt, "type" => 1, "mk_type" => "cny",
"price" => "0.0001", "amount" => "100", "coinname" => "XRP");
//$data_string = json_encode($data);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, 'http://www.btc38.com/trade/t_api/submitOrder.php' );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; btc38 PHP bot; ' . php_uname('a') . '; PHP/' . phpversion() . ')');
$result = curl_exec($ch);
print_r($result);
?>
免责声明:本文版权归原作者所有,不代表MyToken(www.mytokencap.com)观点和立场;如有关于内容、版权等问题,请与我们联系。
相关阅读