Skip to content

Coinbene API Like the official document interface, Support for arbitrary extension.

License

Notifications You must be signed in to change notification settings

zhouaini528/coinbene-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

It is recommended that you read the official document first

Coinbene docs https://github.com/Coinbene

All interface methods are initialized the same as those provided by Coinbene. See details src/api

Most of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.

中文文档

Other exchanges API

Exchanges It includes all of the following exchanges and is highly recommended.

Bitmex Support Websocket

Okex Support Websocket

Huobi Support Websocket

Binance Support Websocket

Kucoin

Mxc

Coinbase

ZB

Bitfinex

Bittrex

Kraken

Gate

Bigone

Crex24

Bybit

Coinbene

Bitget

Poloniex

If you don't find the exchange SDK you want, you can tell me and I'll join them.

Installation

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,
]);

Coinbene Spot API

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));
}

Coinbene Swap USDT API

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));
}

Coinbene Swap BTC API

Publics API More

Private API More

Coinbene Account API

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));
}

More Test

More Api