linwj / kucoin
Kucoin API Like the official document interface, Support for arbitrary extension.
Installs: 4 358
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=7.0
- guzzlehttp/guzzle: *
README
It is recommended that you read the official document first
Kucoin spot docs https://docs.kucoin.com
Kucoin futures docs https://docs.kucoin.com/futures/
All interface methods are initialized the same as those provided by kucoin. 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.
Installation
composer require linwj/kucoin
Support for more request Settings
$kucoin=new kucoin(); //You can set special needs $kucoin->setOptions([ //The default is v2 api, you can set //'headers'=>['KC-API-KEY-VERSION'=>1], //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, ]);
Spot Trading API
Order Book More
$kucoin=new kucoin(); try { $result=$kucoin->market()->getOrderBookLevel1([ 'symbol'=>'BTC-USDT' ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } try { $result=$kucoin->market()->getOrderBookLevel2([ 'symbol'=>'BTC-USDT' ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Order related API More
$client_id=rand(10000,99999).rand(10000,99999); try { $result=$kucoin->order()->post([ 'clientOid'=>$client_id, 'side'=>'buy', 'symbol'=>'ETH-BTC', 'price'=>'0.0001', 'size'=>'10', //'type'=>'market', //'size'=>'0.1' ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } sleep(1); try { $result=$kucoin->order()->get([ 'orderId'=>$result['data']['orderId'] ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } sleep(1); try { $result=$kucoin->order()->delete([ 'orderId'=>$result['data']['id'] ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } sleep(1); try { $result=$kucoin->order()->deleteAll([ 'symbol'=>'ETH-BTC' ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Accounts related API More
try { $result=$kucoin->account()->getAll(); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } try { $result=$kucoin->account()->get([ 'accountId'=>'5d5cba60ef83c753ca6ddd16', ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Future Trading API
Order Book API More
$kucoin=new KucoinFuture(); try { $result=$kucoin->level()->getTwoSnapshot([ 'symbol'=>'XBTUSDM', ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } try { $result=$kucoin->level()->getThreeSnapshot([ 'symbol'=>'XBTUSDM', ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Order related API More
$kucoin=new KucoinFuture($key,$secret,$passphrase); try { $result=$kucoin->order()->post([ 'clientOid'=>'xxxxxxx', 'side'=>'buy', 'symbol'=>'XBTUSDM', 'leverage'=>10, 'price'=>9000, 'size'=>10, ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } sleep(1); try { $result=$kucoin->order()->get([ 'order-id'=>$result['data']['orderId'], ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } sleep(1); try { $result=$kucoin->order()->delete([ 'order-id'=>$result['data']['id'], ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Accounts related API More
$kucoin=new KucoinFuture($key,$secret,$passphrase); try { $result=$kucoin->account()->getOverview(); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } try { $result=$kucoin->account()->getTransactionHistory(); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }
Position related API More
$kucoin=new KucoinFuture($key,$secret,$passphrase); try { $result=$kucoin->position()->getAll(); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); } try { $result=$kucoin->position()->get([ 'symbol'=>'XBTUSDM', ]); print_r($result); }catch (\Exception $e){ print_r($e->getMessage()); }