当前位置:首页学习比特时代 API 使用说明(附调用范例 )

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

交易行情API / Trades API

返回系统支持的所有交易对的最高,最低 交易行情和交易量,每15秒钟更新。
Return the highest, lowest trade and the ulome of trade pairs. Refreshed eery 15 seconds.

所有币种交易API / All Pairs
http://api.btc38.com/1/ticker.php?c=allAMPLmk_type=cny
http://api.btc38.com/1/ticker.php?c=allAMPLmk_type=btc

单个币种交易API / Single Pair
http://api.btc38.com/1/ticker.php?c=btcAMPLmk_type=cny
http://api.btc38.com/1/ticker.php?c=ltcAMPLmk_type=cny
http://api.btc38.com/1/ticker.php?c=dogAMPLmk_type=cny

http://api.btc38.com/1/ticker.php?c=btsAMPLmk_type=btc
http://api.btc38.com/1/ticker.php?c=ltcAMPLmk_type=btc
http://api.btc38.com/1/ticker.php?c=dogAMPLmk_type=btc

市场深度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.

http://api.btc38.com/1/depth.php?c=btcAMPLmk_type=cny
http://api.btc38.com/1/depth.php?c=ltcAMPLmk_type=cny
http://api.btc38.com/1/depth.php?c=dogAMPLmk_type=cny

http://api.btc38.com/1/depth.php?c=btsAMPLmk_type=btc
http://api.btc38.com/1/depth.php?c=ltcAMPLmk_type=btc
http://api.btc38.com/1/depth.php?c=dogAMPLmk_type=btc


历史成交API / History API

返回系统支持的历史成交记录,返回最新30条。
Return the trade history. 30 items for each call.

http://api.btc38.com/1/trades.php?c=btcAMPLmk_type=cny
http://api.btc38.com/1/trades.php?c=ltcAMPLmk_type=cny
http://api.btc38.com/1/trades.php?c=dogAMPLmk_type=cny

http://api.btc38.com/1/trades.php?c=btsAMPLmk_type=btc
http://api.btc38.com/1/trades.php?c=ltcAMPLmk_type=btc
http://api.btc38.com/1/trades.php?c=dogAMPLmk_type=btc


返回从[TID](交易数自递增id)往后的最多500条历史成交记录(以比特币对人民币和比特股对比特币为例)
Return 500 items from the TID (BTC_CNY and BTS_BTC for example).

http://api.btc38.com/1/trades.php?c=btcAMPLmk_type=cnyAMPLtid=100
http://api.btc38.com/1/trades.php?c=btsAMPLmk_type=btcAMPLtid=100

获取账户余额 Get Account Balance

http://www.btc38.com/trade/t_api/getMyBalance.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


返回:
JSON格式的余额,含所有币种


挂单 Make an Orders

http://www.btc38.com/trade/t_api/submitOrder.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
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 aries as per coins, you can get thedecimal digits on our website
amount,数量,最多6位小数 / the amount of the order. 6decimal digits at most
coinname,币名,比如BTC、DOGE、BTS / the Symbol of the coin. Ex: BTC, DOGE, BTS

返回 / Return:
succ,挂单成功 / successful
oerBalance,账户余额不足 / insuffient balance
其它返回表示不同的错误,情况太多,暂不罗列,这种错误发生的可能性不大

撤单 Cancel an Order

http://www.btc38.com/trade/t_api/cancelOrder.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


order_id,要撤的单的ID the ID of the order you’d cancel

返回:
succ,撤单成功 /successful
oertime,该单不存在,或者已成交了 / 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 DeFiault 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 serice.



由于我们的分布式CDN对非HTTP请求做了限制,因此调用API时,您可能需要人为设置HTTP,以免被防火墙拦截。 调用API有技术方面的故障,请联系加 API 技术QQ2805792922。
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 aoid the request being filtered. For technical help, please contact 2805792922(a)qq.com .

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


$date = new DateTime();
$stamp = $date-gt;getTimestamp();

$mdt = “这里写公钥_这里写用户ID_这里写私钥_” . $stAMPL
$mdt = md5($mdt);

$data = array(“key” =gt; “这里写公钥”, “time” =gt; $stamp, “md5” =gt; $mdt, “type” =gt; 1, “mk_type” =gt; “cny”,
“price” =gt; “0.0001”, “amount” =gt; “100”, “coinname” =gt; “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/’ . phpersion() . ‘)’);

$result = curl_exec($ch);
print_r($result);
?gt;

温馨提示:

文章标题:比特时代 API 使用说明(附调用范例 )

文章链接:https://www.btchangqing.cn/2603.html

更新时间:2022年03月05日

本站大部分内容均收集于网络,若内容若侵犯到您的权益,请联系我们,我们将第一时间处理。

学习

[教程帖]新手如何在比特时代买入btsx

2020-4-6 16:46:00

学习

区块链投资中,最被忽视的致胜因素

2020-4-6 16:47:49

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索