PHPackages                             kucoin/kucoin-futures-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. kucoin/kucoin-futures-php-sdk

ActiveLibrary[API Development](/categories/api)

kucoin/kucoin-futures-php-sdk
=============================

PHP SDK for KuCoin Futures API

v1.0.28(1y ago)111.9k10[1 issues](https://github.com/Kucoin/kucoin-futures-php-sdk/issues)MITPHPPHP &gt;=5.5.0

Since Jul 3Pushed 1y ago11 watchersCompare

[ Source](https://github.com/Kucoin/kucoin-futures-php-sdk)[ Packagist](https://packagist.org/packages/kucoin/kucoin-futures-php-sdk)[ Docs](https://github.com/Kucoin/kucoin-futures-php-sdk)[ RSS](/packages/kucoin-kucoin-futures-php-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (31)Used By (0)

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

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

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

[![Latest Version](https://camo.githubusercontent.com/90c35799ac255645c984c4e6244caf97c2344150d47ff7d7acfd59d60608148e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4b75636f696e2f6b75636f696e2d667574757265732d7068702d73646b2e737667)](https://github.com/Kucoin/kucoin-futures-php-sdk/releases)[![PHP Version](https://camo.githubusercontent.com/e2062a961e29b11617c28616a504836990f891b14f4d5eac98805634b48d4e84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6b75636f696e2f6b75636f696e2d667574757265732d7068702d73646b2e7376673f636f6c6f723d677265656e)](https://secure.php.net)[![Build Status](https://camo.githubusercontent.com/f7f7704f907e446e351b50c2c91aad199fda973e993ed3e03b30cbcaded8aa5f/68747470733a2f2f7472617669732d63692e6f72672f4b75636f696e2f6b75636f696e2d667574757265732d7068702d73646b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Kucoin/kucoin-futures-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/91f679989a052c6e6dd34220fb8b305520bd6e37f308bf195c3423d397085d5b/68747470733a2f2f706f7365722e707567782e6f72672f6b75636f696e2f6b75636f696e2d667574757265732d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/kucoin/kucoin-futures-php-sdk)[![License](https://camo.githubusercontent.com/6b58368f1d6aa282ff747269fc7f920d00ab007e3072c2214738ec1e7acfcd1c/68747470733a2f2f706f7365722e707567782e6f72672f6b75636f696e2f6b75636f696e2d667574757265732d7068702d73646b2f6c6963656e7365)](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-futures-php-sdk:~1.0.0"
```

Usage
-----

[](#usage)

### Choose environment

[](#choose-environment)

EnvironmentBaseUri*Production*`https://api-futures.kucoin.com(DEFAULT)````
use KuCoin\Futures\SDK\KuCoinFuturesApi;
// Switch to the sandbox environment
KuCoinFuturesApi::setBaseUri('https://api-sandbox-futures.kucoin.com');
```

### Debug mode &amp; logging

[](#debug-mode--logging)

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

// Logging in your code
// KuCoinFuturesApi::setLogPath('/tmp');
// KuCoinFuturesApi::setLogLevel(Monolog\Logger::DEBUG);
KuCoinFuturesApi::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\Futures\SDK\PublicApi\Time;

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

#### Example of API `with` authentication

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

##### **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

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

// 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->getOverview();
    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\Futures\SDK\Auth;
use KuCoin\Futures\SDK\KuCoinFuturesApi;
use KuCoin\Futures\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 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 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);

    // Subscribe another channel
    // $ws->send(json_encode($api->createSubscribeMessage('/contractMarket/ticker:ETHUSDTM')));

    // Unsubscribe the channel
    // $ws->send(json_encode($api->createUnsubscribeMessage('/contractMarket/ticker:XBTUSDM')));

    // 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\Futures\SDK\Auth;
use KuCoin\Futures\SDK\Http\SwooleHttp;
use KuCoin\Futures\SDK\KuCoinFuturesApi;
use KuCoin\Futures\SDK\PrivateApi\Order;
use KuCoin\Futures\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\\Futures\\SDK\\PrivateApi\\AccountAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Account::getOverview()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::getTransactionHistory()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::transferIn()YES`deprecated`KuCoin\\Futures\\SDK\\PrivateApi\\Account::transferOut()YES`deprecated` KuCoin\\Futures\\SDK\\PrivateApi\\Account::transferOutV2()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::cancelTransferOut()YES`deprecated` KuCoin\\Futures\\SDK\\PrivateApi\\Account::getTransferList()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::getSubApikey()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::createSubApikey()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::modifySubApikey()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::deleteSubApikey()YESKuCoin\\Futures\\SDK\\PrivateApi\\Account::transferOutV3()YESKuCoin\\Futures\\SDK\\PrivateApi\\DepositAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Deposit::getAddress()YESKuCoin\\Futures\\SDK\\PrivateApi\\Deposit::getDeposits()YESKuCoin\\Futures\\SDK\\PrivateApi\\FillAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Fill::getFills()YESKuCoin\\Futures\\SDK\\PrivateApi\\Fill::getRecentList()YESKuCoin\\Futures\\SDK\\PrivateApi\\FeeAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Fee::getTradeFees()YESKuCoin\\Futures\\SDK\\PrivateApi\\OrderAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Order::create()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::cancel()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::batchCancel()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::stopOrders()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getList()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getStopOrders()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getRecentDoneOrders()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getDetail()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getDetailByClientOid()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::getOpenOrderStatistics()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::cancelByClientOid()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::createTest()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::createStOrder()YESKuCoin\\Futures\\SDK\\PrivateApi\\Order::createMultiOrders()YESKuCoin\\Futures\\SDK\\PrivateApi\\PositionAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Position::getList()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getDetail()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::changeAutoAppendStatus()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::marginAppend()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getMaxWithdrawMargin()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::withdrawMargin()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getHistoryPositions()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getMaxOpenSize()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::modifyCrossUserLeverage()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getCrossUserLeverage()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::modifyMarginMode()YESKuCoin\\Futures\\SDK\\PrivateApi\\Position::getMarginMode()YESKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeedAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::getPublicServer()NOKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::getPrivateServer()YESKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::subscribePublicChannel()NOKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::subscribePublicChannels()NOKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::subscribePrivateChannel()YESKuCoin\\Futures\\SDK\\PrivateApi\\WebSocketFeed::subscribePrivateChannels()YESKuCoin\\Futures\\SDK\\PrivateApi\\WithdrawalAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\Withdrawal::getQuotas()YESKuCoin\\Futures\\SDK\\PrivateApi\\Withdrawal::getList()YESKuCoin\\Futures\\SDK\\PrivateApi\\Withdrawal::apply()YESKuCoin\\Futures\\SDK\\PrivateApi\\Withdrawal::cancel()YESKuCoin\\Futures\\SDK\\PrivateApi\\RiskLimitLevelAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PrivateApi\\RiskLimitLevel::getRiskLimitLevelYESKuCoin\\Futures\\SDK\\PrivateApi\\RiskLimitLevel::changeRiskLimitLevel()YESKuCoin\\Futures\\SDK\\PublicApi\\SymbolAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getTicker()NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel2Snapshot()NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel3Snapshot()NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getV2Level3Snapshot()NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel2Message()NO`deprecated` KuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel3Message()NO`deprecated` KuCoin\\Futures\\SDK\\PublicApi\\Symbol::getTradeHistory()NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getKLines()NO[https://docs.kucoin.com/futures/?lang=en\_US#get-k-line-data-of-contract](https://docs.kucoin.com/futures/?lang=en_US#get-k-line-data-of-contract)KuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel2Depth20NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getLevel2Depth100NOKuCoin\\Futures\\SDK\\PublicApi\\Symbol::getFundingRatesNOKuCoin\\Futures\\SDK\\PublicApi\\ContractAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PublicApi\\Contract::getList()NOKuCoin\\Futures\\SDK\\PublicApi\\Contract::getDetail()NOKuCoin\\Futures\\SDK\\PublicApi\\Contract::getAllTickers()NOKuCoin\\Futures\\SDK\\PublicApi\\TimeAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PublicApi\\Time::timestamp()NOKuCoin\\Futures\\SDK\\PublicApi\\StatusAPIAuthenticationDescriptionKuCoin\\Futures\\SDK\\PublicApi\\Status::status()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-futures.kucoin.com
export API_KEY=key
export API_SECRET=secret
export API_PASSPHRASE=passphrase
export API_KEY_VERSION=2
export API_DEBUG_MODE=1

composer test
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance43

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~76 days

Recently: every ~71 days

Total

28

Last Release

429d ago

### Community

Maintainers

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

---

Top Contributors

[![c2s](https://avatars.githubusercontent.com/u/17718352?v=4)](https://github.com/c2s "c2s (45 commits)")[![hhxsv5](https://avatars.githubusercontent.com/u/7278743?v=4)](https://github.com/hhxsv5 "hhxsv5 (34 commits)")[![Artisan-Liu](https://avatars.githubusercontent.com/u/135569268?v=4)](https://github.com/Artisan-Liu "Artisan-Liu (15 commits)")[![fieyum](https://avatars.githubusercontent.com/u/133764661?v=4)](https://github.com/fieyum "fieyum (7 commits)")[![viaweb3](https://avatars.githubusercontent.com/u/17975348?v=4)](https://github.com/viaweb3 "viaweb3 (3 commits)")[![ISAAC-XXYYZZ](https://avatars.githubusercontent.com/u/176384951?v=4)](https://github.com/ISAAC-XXYYZZ "ISAAC-XXYYZZ (2 commits)")[![sh7ning](https://avatars.githubusercontent.com/u/4698385?v=4)](https://github.com/sh7ning "sh7ning (2 commits)")

---

Tags

futureskucoinphpsdkv2apisdkkucoinkumexfutures

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/kucoin-kucoin-futures-php-sdk/health.svg)](https://phpackages.com/packages/kucoin-kucoin-futures-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)[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)
