PHP code example of hsioe / quant-okx-api

1. Go to this page and download the library: Download hsioe/quant-okx-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hsioe / quant-okx-api example snippets


use Hsioe\QuantOkxApi\OkxApi;
use Hsioe\QuantOkxApi\Rest\OkxApiRequest;

//初始化链接

$apiRequest = new OkxApiRequest([
    'apiKey' => 'You Okx ApiKey',
    'apiSecret' => 'You Okx ApiSecret',
    'passphrase' => 'You Okx Passphrase'
]);

$accountApi = OkxApi::account($apiRequest);
// 获取账户余额
$accountApi->getBalance();
// 获取账户配置
$accountApi->getAccountConfig();
...

use Hsioe\QuantOkxApi\OkxWebsocket;
// 公共频道链接
$publicClient = OkxWebsocket::public('test01','public',[
    'wss_url' => 'ws://ws.okx.com/v5/public',
    'ping_interval' => 20
]);
// 启动websocket
$publicClient->start();

// 私有频道
$privateClient = OkxWebsocket::private('test02','private',[
    'wss_url' => 'ws://ws.okx.com/v5/private',
    'ping_interval' => 20
]);
$privateClient->start();