OKX API
OKX v5 WebSocket and REST client — unified spot, futures, perpetual and options market data plus authenticated trading.
OKX v5 WebSocket and REST client — unified spot, futures, perpetual and options market data plus authenticated trading.
WebSocket channels are divided into two categories: public and private channels.
TsgcWSAPI_OKX| Standards & specs | OKX v5 API documentation |
| Component class | TsgcWSAPI_OKX (unit sgcWebSocket_API_OKX) |
| Frameworks | VCL, FireMonkey, Lazarus / FPC, .NET |
| Platforms | Windows, macOS, Linux, iOS, Android |
The principal published / public properties used to configure and drive the component. Consult the online help for the full list.
Client | Published or public property used to configure or query the component. |
OnOKXSubscribed | Published or public property used to configure or query the component. |
OnOKXUnsubscribed | Published or public property used to configure or query the component. |
OnConnect | Published or public property used to configure or query the component. |
OnOKXConnect | Published or public property used to configure or query the component. |
OnOKXMessage | Published or public property used to configure or query the component. |
OnOKXError | Published or public property used to configure or query the component. |
OnDisconnect | Published or public property used to configure or query the component. |
OKX | Published or public property used to configure or query the component. |
RawMessages | Published or public property used to configure or query the component. |
The principal public methods exposed by the component.
SubscribeTrades() | Public procedure exposed by the component. |
UnSubscribeTrades() | Public procedure exposed by the component. |
SubscribeOrderBook() | Public procedure exposed by the component. |
UnSubscribeOrderBook() | Public procedure exposed by the component. |
SubscribeIndexCandlestick() | Public procedure exposed by the component. |
UnSubscribeIndexCandlestick() | Public procedure exposed by the component. |
SubscribeIndexTicker() | Public procedure exposed by the component. |
UnSubscribeIndexTicker() | Public procedure exposed by the component. |
SubscribePublicStructureBlockTrades() | Public procedure exposed by the component. |
UnSubscribePublicStructureBlockTrades() | Public procedure exposed by the component. |
Drop the component on a form, configure the properties below and activate it. The snippet that follows shows the typical Binance | Connect WebSocket API configuration sourced from the online help.
oClient := TsgcWebSocketClient.Create(nil); oBinance := TsgcWSAPI_Binance.Create(nil); oBinance.Client := oClient; oClient.Active := True;
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(NULL); TsgcWSAPI_Binance *oBinance = new TsgcWSAPI_Binance(NULL); oBinance->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Binance oBinance = new TsgcWSAPI_Binance(); oBinance.Client = oClient; oClient.Active = true;
The following scenarios are lifted verbatim from the online help. Each shows the configuration and method calls needed to drive the component through a specific real-world flow.
In order to connect to Bitmex WebSocket API, just create a new Bitmex API client and attach to TsgcWebSocketClient.
oClient := TsgcWebSocketClient.Create(nil); oBitmex := TsgcWSAPI_Bitmex.Create(nil); oBitmex .Client := oClient; oClient.Active := True;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex.Client = oClient; oClient.Active = true;
In order to connect to Coinbase WebSocket API, just create a new Coinbase API client and attach to TsgcWebSocketClient. See below an example:
oClient := TsgcWebSocketClient.Create(nil); oCoinbase := TsgcWSAPI_Coinbase.Create(nil); oCoinbase.Client := oClient; oClient.Active := True;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Coinbase oCoinbase = new TsgcWSAPI_Coinbase(); oCoinbase->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Coinbase oCoinbase = new TsgcWSAPI_Coinbase(); oCoinbase.Client = oClient; oClient.Active = true;
In order to connect to Kucoin WebSocket API, just create a new Kucoin API client and attach to TsgcWebSocketClient.
oClient := TsgcWebSocketClient.Create(nil); oKucoin := TsgcWSAPI_Kucoin.Create(nil); oKucoin.Client := oClient; oClient.Active := True;
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(); TsgcWSAPI_Kucoin *oKucoin = new TsgcWSAPI_Kucoin(); oKucoin->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Kucoin oKucoin = new TsgcWSAPI_Kucoin(); oKucoin.Client = oClient; oClient.Active = true;
In order to connect to Kucoin WebSocket API, just create a new Kucoin API client and attach to TsgcWebSocketClient.
oClient := TsgcWebSocketClient.Create(nil); oKucoin := TsgcWSAPI_Kucoin_Futures.Create(nil); oKucoin.Client := oClient; oClient.Active := True;
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(); </code><code class="delphi">TsgcWSAPI_Kucoin_Futures </code><code class="cpp">*oKucoin = new </code><code class="delphi">TsgcWSAPI_Kucoin_Futures</code><code class="cpp">(); oKucoin->Client = oClient; oClient->Active = true;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); </code><code class="delphi">TsgcWSAPI_Kucoin_Futures </code><code class="csharp">oKucoin = new </code><code class="delphi">TsgcWSAPI_Kucoin_Futures</code><code class="csharp">(); oKucoin.Client = oClient; oClient.Active = true;
Binance offers a variety of channels where you can subscribe to get real-time updates of market data, orders... Find below a sample of how to subscribe to a Ticker:
oClient := TsgcWebSocketClient.Create(nil); oBinance := TsgcWSAPI_Binance.Create(nil); oBinance.Client := oClient; oBinance.SubscribeTicker('bnbbtc'); procedure OnMessage(Connection: TsgcWSConnection; const aText: string); begin // here you will receive the ticker updates end;
TsgcWebSocketClient *oClient = new TsgcWebSocketClient(NULL); TsgcWSAPI_Binance *oBinance = new TsgcWSAPI_Binance(NULL); oBinance->Client = oClient; oBinance->SubscribeTicker("bnbbtc"); void OnMessage(TsgcWSConnection *Connection, const string aText) { // here you will receive the ticker updates }
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Binance oBinance = new TsgcWSAPI_Binance(); oBinance.Client = oClient; oBinance.SubscribeTicker("bnbbtc"); void OnMessage(TsgcWSConnection Connection, const string aText) { // here you will receive the ticker updates }
Bitmex offers a variety of channels where you can subscribe to get real-time updates of market data, orders... Find below a sample of how subscribe to a Trade Channel:
oClient := TsgcWebSocketClient.Create(nil); oBitmex := TsgcWSAPI_Bitmex.Create(nil); oBitmex.Client := oClient; oBitmex.Subscribe(btmTrade, 'XBTUSD'); procedure OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string); begin // here you will receive the trade updates end;
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex->Client = oClient; oBitmex->Subscribe(btmTrade, "XBTUSD"); void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string) { // here you will receive the trade updates }
TsgcWebSocketClient oClient = new TsgcWebSocketClient(); TsgcWSAPI_Bitmex oBitmex = new TsgcWSAPI_Bitmex(); oBitmex.Client = oClient; oBitmex.Subscribe(btmTrade, "xbtusd"); void OnBitmexMessage(Sender: TObject; const aTopic: TwsBitmexTopics; const aMessage: string) { // here you will receive the tradeupdates }
Every external claim links back to a primary source. The online-help references decode the canonical deep-link the company maintains for this component.
Demos\05.Crypto\12.OKX
.net\demos\05.Crypto\12.OKX