Coinbene 文档 https://github.com/Coinbene
所有接口方法的初始化都与coinbene提供的方法相同。更多细节 src/api
大部分的接口已经完成,使用者可以根据我的设计方案继续扩展,欢迎与我一起迭代它。
QQ交流群:668421169
Exchanges 它包含以下所有交易所,强烈推荐使用该SDK。
如果没有找到你想要的交易所SDK你可以告诉我,我来加入它们。
如果没有找到你想要的交易所SDK你可以告诉我,我来加入它们。
composer require linwj/coinbene
Support for more request Settings
$coinbene=new CoinbeneSpot();
//You can set special needs
$coinbene->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,
//If you are developing locally and need an agent, you can set this
//'proxy'=>true,
//More flexible Settings
/* 'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
], */
//Close the certificate
//'verify'=>false,
]);
Publics API More
$coinbene=new CoinbeneSpot();
try {
$result=$coinbene->publics()->getTradePairList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getTradePairOne([
'instrument_id'=>'BTC/USDT'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getDepth([
'instrument_id'=>'BTC/USDT',
'depth'=>5
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getTickerList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getTickerOne([
'instrument_id'=>'BTC/USDT',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Private API More
$coinbene=new CoinbeneSpot($key,$secret);
//Account
try {
$result=$coinbene->privates()->getAccountList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getAccountOne(['asset'=>'USDT']);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Order
try {
$result=$coinbene->privates()->postOrder([
'instrument_id'=>'BTC/USDT',
'direction'=>'1',
'price'=>'10000',
'quantity'=>'0.1',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->postBatchOrder([
[
'instrument_id'=>'BTC/USDT',
'direction'=>'1',
'price'=>'10000',
'quantity'=>'0.1',
],
[
'instrument_id'=>'BTC/USDT',
'direction'=>'1',
'price'=>'20000',
'quantity'=>'0.2',
]
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getOpenOrders([
'instrument_id'=>'BTC/USDT',
//'latestOrderId'=>'xxxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getClosedOrders([
'instrument_id'=>'BTC/USDT',
//'latestOrderId'=>'xxxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getOrderInfo([
'order_id'=>'xxxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->postCancelOrder([
'order_id'=>'xxxxxxxxxxx',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->postBatchCancelOrder([
'orderIds'=>['xxxxxx','xxxxxxx'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Publics API More
$coinbene=new CoinbeneSwapUsdt();
try {
$result=$coinbene->publics()->getDepth([
'instrument_id'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getTickerList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getTickerOne([
'instrument_id'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->publics()->getCandles([
'instrument_id'=>'BTC',
'resolution'=>5,
//'start_time'=>'',
//'end_time'=>''
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Private API More
$coinbene=new CoinbeneSwapUsdt($key,$secret);
try {
$result=$coinbene->privates()->getAccount();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getPositionList([
'instrument_id'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->postOrder([
'instrument_id'=>'BTC',
'direction'=>'openLong',
'leverage'=>'20',
'order_type'=>'limit',
'order_price'=>'10000',
'quantity'=>'10',
//'margin_mode'=>'crossed',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->postCancelOrder([
'order_id'=>'xxxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getOpenOrderList([
'instrument_id'=>'BTC'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getOrderInfo([
'order_id'=>'xxxxxxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getClosedOrderList([
'instrument_id'=>'BTC',
//'begin_time'=>''
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getFills([
'instrument_id'=>'BTC',
'order_id'=>'xxxxxxxxxxxxx'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getHistoricalFundingRate([
'instrument_id'=>'BTC',
'page_num'=>'1',
'page_size'=>'10',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Publics API More
Private API More
Publics API More
$coinbene=new CoinbeneAccount();
try {
$result=$coinbene->publics()->getCurrencyList();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Private API More
$coinbene=new CoinbeneAccount($key,$secret);
try {
$result=$coinbene->privates()->postWithdrawApply([
'asset'=>'BTC',
'amount'=>'1',
'address'=>'xxxxxxxxxxxx',
//'addressTag'=>'',
//'chain'=>'',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getDepositAddressList([
'asset'=>'BTC',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
try {
$result=$coinbene->privates()->getAssetTransferHistoryList([
'asset'=>'BTC',
'from'=>'spot',
//'to'=>'spot',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}