Skip to content

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

License

Notifications You must be signed in to change notification settings

zhouaini528/kucoin-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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

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

More use cases

More API

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

More Test

More API

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages