PHPackages                             rabsana/kucoin-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rabsana/kucoin-php-sdk

ActiveLibrary[API Development](/categories/api)

rabsana/kucoin-php-sdk
======================

PHP SDK for KuCoin API

v1.1.0(2y ago)0141MITPHPPHP &gt;=5.5.0

Since Aug 31Pushed 2y agoCompare

[ Source](https://github.com/rabsana/kucoin-php-sdk)[ Packagist](https://packagist.org/packages/rabsana/kucoin-php-sdk)[ Docs](https://github.com/rabsana/kucoin-php-sdk)[ RSS](/packages/rabsana-kucoin-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

PHP SDK for KuCoin API
======================

[](#php-sdk-for-kucoin-api)

> The detailed document , in order to receive the latest API change notifications, please `Watch` this repository.

[![Latest Version](https://camo.githubusercontent.com/1e443c521ee32abac7054ca01633d76ec2ace61a90472012b9356672b40897ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4b75636f696e2f6b75636f696e2d7068702d73646b2e737667)](https://github.com/Kucoin/kucoin-php-sdk/releases)[![PHP Version](https://camo.githubusercontent.com/48406c13b71e95daaf6f82037c9c7577a99a8d960305db7b0806679e11063a55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6b75636f696e2f6b75636f696e2d7068702d73646b2e7376673f636f6c6f723d677265656e)](https://secure.php.net)[![Build Status](https://camo.githubusercontent.com/e896599ca32356a88255dbf81b8aa2bc4cc3fcc807c6b83c76fae2de95251bdd/68747470733a2f2f7472617669732d63692e6f72672f4b75636f696e2f6b75636f696e2d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Kucoin/kucoin-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/6ad5cefce0f5961289666f8098b980319156ea0a3ec4e372c9f2ae2c5b826067/68747470733a2f2f706f7365722e707567782e6f72672f6b75636f696e2f6b75636f696e2d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/kucoin/kucoin-php-sdk)[![License](https://camo.githubusercontent.com/e88f14defa212ea4572553921b02127430213a82c8b421dbd62c66bf294b2795/68747470733a2f2f706f7365722e707567782e6f72672f6b75636f696e2f6b75636f696e2d7068702d73646b2f6c6963656e7365)](LICENSE)

Requirements
------------

[](#requirements)

DependencyRequirement[PHP](https://secure.php.net/manual/en/install.php)`>=5.5.0` `Recommend PHP7+`[guzzlehttp/guzzle](https://github.com/guzzle/guzzle)`^6.0|^7.0`Install
-------

[](#install)

> Install package via [Composer](https://getcomposer.org/).

```
composer require "kucoin/kucoin-php-sdk:~1.1.0"
```

Usage
-----

[](#usage)

### Choose environment

[](#choose-environment)

EnvironmentBaseUri*Production*`https://api.kucoin.com(DEFAULT)`*Sandbox*`https://openapi-sandbox.kucoin.com````
// Switch to the sandbox environment
KuCoinApi::setBaseUri('https://openapi-sandbox.kucoin.com');
```

### Debug mode &amp; logging

[](#debug-mode--logging)

```
// Debug mode will record the logs of API and WebSocket to files in the directory "KuCoinApi::getLogPath()" according to the minimum log level "KuCoinApi::getLogLevel()".
KuCoinApi::setDebugMode(true);

// Logging in your code
// KuCoinApi::setLogPath('/tmp');
// KuCoinApi::setLogLevel(Monolog\Logger::DEBUG);
KuCoinApi::getLogger()->debug("I'm a debug message");
```

### Examples

[](#examples)

> See the [test case](tests) for more examples.

#### Example of API `without` authentication

[](#example-of-api-without-authentication)

```
use KuCoin\SDK\PublicApi\Time;

$api = new Time();
$timestamp = $api->timestamp();
var_dump($timestamp);
```

##### **Note**

[](#note)

To reinforce the security of the API, KuCoin upgraded the API key to version 2.0, the validation logic has also been changed. It is recommended to create() and update your API key to version 2.0. The API key of version 1.0 will be still valid until May 1, 2021

#### Example of API `with` authentication

[](#example-of-api-with-authentication)

```
use KuCoin\SDK\PrivateApi\Account;
use KuCoin\SDK\Exceptions\HttpException;
use KuCoin\SDK\Exceptions\BusinessException;
use KuCoin\SDK\Auth;

// Auth version v2 (recommend)
$auth = new Auth('key', 'secret', 'passphrase', Auth::API_KEY_VERSION_V2);
// Auth version v1
// $auth = new Auth('key', 'secret', 'passphrase');

$api = new Account($auth);

try {
    $result = $api->getList(['type' => 'main']);
    var_dump($result);
} catch (HttpException $e) {
    var_dump($e->getMessage());
} catch (BusinessException $e) {
    var_dump($e->getMessage());
}
```

#### Example of WebSocket feed

[](#example-of-websocket-feed)

```
use KuCoin\SDK\Auth;
use KuCoin\SDK\PrivateApi\WebSocketFeed;
use Ratchet\Client\WebSocket;
use React\EventLoop\Factory;
use React\EventLoop\LoopInterface;

$auth = null;
// Need to pass the Auth parameter when subscribing to a private channel($api->subscribePrivateChannel()).
// $auth = new Auth('key', 'secret', 'passphrase');
$api = new WebSocketFeed($auth);

// Use a custom event loop instance if you like
//$loop = Factory::create();
//$loop->addPeriodicTimer(1, function () {
//    var_dump(date('Y-m-d H:i:s'));
//});
//$api->setLoop($loop);

$query = ['connectId' => uniqid('', true)];
$channels = [
    ['topic' => '/market/ticker:KCS-BTC'], // Subscribe multiple channels
    ['topic' => '/market/ticker:ETH-BTC'],
];

$api->subscribePublicChannels($query, $channels, function (array $message, WebSocket $ws, LoopInterface $loop) use ($api) {
    var_dump($message);

    // Unsubscribe the channel
    // $ws->send(json_encode($api->createUnsubscribeMessage('/market/ticker:ETH-BTC')));

    // Stop loop
    // $loop->stop();
}, function ($code, $reason) {
    echo "OnClose: {$code} {$reason}\n";
});
```

#### ⚡️Coroutine HTTP client for asynchronous IO

[](#️coroutine-http-client-for-asynchronous-io)

> See the [benchmark](examples/BenchmarkCoroutine.php), almost `20x` faster than `curl`.

```
pecl install swoole
composer require swlib/saber
```

```
use KuCoin\SDK\Auth;
use KuCoin\SDK\Http\SwooleHttp;
use KuCoin\SDK\KuCoinApi;
use KuCoin\SDK\PrivateApi\Order;
use KuCoin\SDK\PublicApi\Time;

// Require PHP 7.1+ and Swoole 2.1.2+
// Require running in cli mode

go(function () {
    $api = new Time(null, new SwooleHttp);
    $timestamp = $api->timestamp();
    var_dump($timestamp);
});

go(function () {
    // Auth version v2 (recommend)
    $auth = new Auth('key', 'secret', 'passphrase', Auth::API_KEY_VERSION_V2);
    // Auth version v1
    // $auth = new Auth('key', 'secret', 'passphrase');
    $api = new Order($auth, new SwooleHttp);
    // Create 50 orders CONCURRENTLY in 1 second
    for ($i = 0; $i < 50; $i++) {
        go(function () use ($api, $i) {
            $order = [
                'clientOid' => uniqid(),
                'price'     => '1',
                'size'      => '1',
                'symbol'    => 'BTC-USDT',
                'type'      => 'limit',
                'side'      => 'buy',
                'remark'    => 'ORDER#' . $i,
            ];
            try {
                $result = $api->create($order);
                var_dump($result);
            } catch (\Throwable $e) {
                var_dump($e->getMessage());
            }
        });
    }
});
```

### API list

[](#api-list)

KuCoin\\SDK\\PrivateApi\\AccountAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Account::create()YESKuCoin\\SDK\\PrivateApi\\Account::getList()YESKuCoin\\SDK\\PrivateApi\\Account::getDetail()YESKuCoin\\SDK\\PrivateApi\\Account::getLedgers()YES`DEPRECATED` KuCoin\\SDK\\PrivateApi\\Account::getHolds()YESKuCoin\\SDK\\PrivateApi\\Account::innerTransfer()YES`DEPRECATED` KuCoin\\SDK\\PrivateApi\\Account::innerTransferV2()YESKuCoin\\SDK\\PrivateApi\\Account::getSubAccountUsers()YESKuCoin\\SDK\\PrivateApi\\Account::getSubAccountDetail()YESKuCoin\\SDK\\PrivateApi\\Account::getSubAccountList()YESKuCoin\\SDK\\PrivateApi\\Account::subTransfer()YES`DEPRECATED` KuCoin\\SDK\\PrivateApi\\Account::subTransferV2()YESKuCoin\\SDK\\PrivateApi\\Account::getLedgersV2()YESKuCoin\\SDK\\PrivateApi\\DepositAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Deposit::createAddress()YESKuCoin\\SDK\\PrivateApi\\Deposit::getAddress()YESKuCoin\\SDK\\PrivateApi\\Deposit::getAddresses()YESKuCoin\\SDK\\PrivateApi\\Deposit::getDeposits()YESKuCoin\\SDK\\PrivateApi\\Deposit::getV1Deposits()YESKuCoin\\SDK\\PrivateApi\\TradeFeeAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\TradeFee::getBaseFee()YESKuCoin\\SDK\\PrivateApi\\TradeFee::getTradeFees()YESKuCoin\\SDK\\PrivateApi\\SymbolAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Symbol::getAggregatedFullOrderBook()NOKuCoin\\SDK\\PrivateApi\\OrderAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Order::create()YESKuCoin\\SDK\\PrivateApi\\Order::createMulti()YESKuCoin\\SDK\\PrivateApi\\Order::cancel()YESKuCoin\\SDK\\PrivateApi\\Order::cancelAll()YESKuCoin\\SDK\\PrivateApi\\Order::getList()YESKuCoin\\SDK\\PrivateApi\\Order::getV1List()YESKuCoin\\SDK\\PrivateApi\\Order::getDetail()YESKuCoin\\SDK\\PrivateApi\\Order::getRecentList()YESKuCoin\\SDK\\PrivateApi\\Order::createMarginOrder()YESKuCoin\\SDK\\PrivateApi\\Order::cancelByClientOid()YESKuCoin\\SDK\\PrivateApi\\Order::getDetailByClientOid()YESKuCoin\\SDK\\PrivateApi\\StopOrderAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\StopOrder::create()YESKuCoin\\SDK\\PrivateApi\\StopOrder::cancel()YESKuCoin\\SDK\\PrivateApi\\StopOrder::cancelBatch()YESKuCoin\\SDK\\PrivateApi\\StopOrder::getList()YESKuCoin\\SDK\\PrivateApi\\StopOrder::getDetail()YESKuCoin\\SDK\\PrivateApi\\StopOrder::getDetailByClientOid()YESKuCoin\\SDK\\PrivateApi\\StopOrder::cancelByClientOid()YESKuCoin\\SDK\\PrivateApi\\FillAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Fill::getList()YESKuCoin\\SDK\\PrivateApi\\Fill::getRecentList()YESKuCoin\\SDK\\PrivateApi\\WebSocketFeedAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\WebSocketFeed::getPublicServer()NOKuCoin\\SDK\\PrivateApi\\WebSocketFeed::getPrivateServer()YESKuCoin\\SDK\\PrivateApi\\WebSocketFeed::subscribePublicChannel()NOKuCoin\\SDK\\PrivateApi\\WebSocketFeed::subscribePublicChannels()NOKuCoin\\SDK\\PrivateApi\\WebSocketFeed::subscribePrivateChannel()YESKuCoin\\SDK\\PrivateApi\\WebSocketFeed::subscribePrivateChannels()YESKuCoin\\SDK\\PrivateApi\\WithdrawalAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Withdrawal::getQuotas()YESKuCoin\\SDK\\PrivateApi\\Withdrawal::getList()YESKuCoin\\SDK\\PrivateApi\\Withdrawal::getV1List()YESKuCoin\\SDK\\PrivateApi\\Withdrawal::apply()YESKuCoin\\SDK\\PrivateApi\\Withdrawal::cancel()YESKuCoin\\SDK\\PublicApi\\CurrencyAPIAuthenticationDescriptionKuCoin\\SDK\\PublicApi\\Currency::getList()NOKuCoin\\SDK\\PublicApi\\Currency::getDetail()NOKuCoin\\SDK\\PublicApi\\Currency::getPrices()NOKuCoin\\SDK\\PublicApi\\Currency::getV2Detail()NOKuCoin\\SDK\\PublicApi\\SymbolAPIAuthenticationDescriptionKuCoin\\SDK\\PublicApi\\Symbol::getList()NOKuCoin\\SDK\\PublicApi\\Symbol::getTicker()NOKuCoin\\SDK\\PublicApi\\Symbol::getAllTickers()NOKuCoin\\SDK\\PublicApi\\Symbol::getAggregatedPartOrderBook()NOKuCoin\\SDK\\PublicApi\\Symbol::getTradeHistories()NOKuCoin\\SDK\\PublicApi\\Symbol::getKLines()NOKuCoin\\SDK\\PublicApi\\Symbol::get24HStats()NOKuCoin\\SDK\\PublicApi\\Symbol::getMarkets()NOKuCoin\\SDK\\PrivateApi\\MarginAPIAuthenticationDescriptionKuCoin\\SDK\\PrivateApi\\Margin::getMarkPrice()YESKuCoin\\SDK\\PrivateApi\\Margin::getConfig()YESKuCoin\\SDK\\PrivateApi\\Margin::getAccount()YESKuCoin\\SDK\\PrivateApi\\Margin::borrow()YESKuCoin\\SDK\\PrivateApi\\Margin::getBorrow()YESKuCoin\\SDK\\PrivateApi\\Margin::getOutstanding()YESKuCoin\\SDK\\PrivateApi\\Margin::getRepayRecord()YESKuCoin\\SDK\\PrivateApi\\Margin::repayAll()YESKuCoin\\SDK\\PrivateApi\\Margin::repaySingle()YESKuCoin\\SDK\\PrivateApi\\Margin::lend()YESKuCoin\\SDK\\PrivateApi\\Margin::cancelLend()YESKuCoin\\SDK\\PrivateApi\\Margin::setAutoLend()YESKuCoin\\SDK\\PrivateApi\\Margin::getLendActive()YESKuCoin\\SDK\\PrivateApi\\Margin::getLendDone()YESKuCoin\\SDK\\PrivateApi\\Margin::getUnsettled()YESKuCoin\\SDK\\PrivateApi\\Margin::getSettled()YESKuCoin\\SDK\\PrivateApi\\Margin::getLendAssets()YESKuCoin\\SDK\\PrivateApi\\Margin::getMarket()YESKuCoin\\SDK\\PrivateApi\\Margin::getTradeLast()YESKuCoin\\SDK\\PublicApi\\TimeAPIAuthenticationDescriptionKuCoin\\SDK\\PublicApi\\Time::timestamp()NOKuCoin\\SDK\\PublicApi\\ServiceStatusAPIAuthenticationDescriptionKuCoin\\SDK\\PublicApi\\ServiceStatus::getStatus()NORun tests
---------

[](#run-tests)

> Modify your API key in `phpunit.xml` first.

```
# Add your API configuration items into the environmental variable first
export API_BASE_URI=https://api.kucoin.com
export API_KEY=key
export API_SECRET=secret
export API_PASSPHRASE=passphrase
export API_KEY_VERSION=2

composer test
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

982d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9daa90d86597b133a494300e9ca45482f82497c9f692e521b7ea9eb3ba3513d?d=identicon)[rabsana](/maintainers/rabsana)

---

Top Contributors

[![sajjadsisakhti](https://avatars.githubusercontent.com/u/46242002?v=4)](https://github.com/sajjadsisakhti "sajjadsisakhti (2 commits)")

---

Tags

apisdkkucoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rabsana-kucoin-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/rabsana-kucoin-php-sdk/health.svg)](https://phpackages.com/packages/rabsana-kucoin-php-sdk)
```

###  Alternatives

[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[kucoin/kucoin-php-sdk

PHP SDK for KuCoin API

7955.8k](/packages/kucoin-kucoin-php-sdk)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[kucoin/kucoin-futures-php-sdk

PHP SDK for KuCoin Futures API

111.9k](/packages/kucoin-kucoin-futures-php-sdk)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
