From sgcWebSockets 2023.8.0 the CEX.IO Plus API is supported.
APIs supported
WebSocket is a TCP-based full-duplex communication protocol. Full-duplex means that both parties can send each other messages asynchronously using the same communication channel. This section describes which messages should Exchange Plus and Client send each other. All messages should be valid JSON objects.
WebSocket API is mostly used to obtain information or do actions which are not available or not easy to do using REST API. However, some requests or actions are possible to do in both REST API and WebSocket API. Exchange Plus sends messages to Client as a response to request previously sent by Client, or as a notification about some event (without prior Client's request).
Public API rate limit is implied in order to protect the system from DDoS attacks and ensuring all Clients can have same level of stable access to Exchange Plus API endpoints. Public requests are limited by IP address from which public API requests are made. Request limits are determined from cost associated with each public API call. By default, each public request has a cost of 1 point, but for some specific requests this cost can be higher. See up-to-date request rate limit cost information in specification of each method.
Exchange Plus limits Public API calls to maximum of 100 points per minute, considering that each Public API call has its' cost (see below). If request rate limit is reached then Exchange Plus replies with error, sends disconnected event to Client and closes WS connection afterwards. Exchange Plus will continue to serve Client starting from the next calendar minute. In the following example, request counter will be reset at 11:02:00.000.
Example: get the latest ticker of BTC-USD pair
oClient := TsgcWebSocketClient.Create(nil); oCexPlus := TsgcWSAPI_CexPlus.Create(nil); oCexPlus.Client := oClient; oCexPlus.OnCexPlusConnect := OnCexPlusConnectEvent; oCexPlus.OnCexPlusMessage := OnCexPlusMessageEvent; oClient.Active := True; procedure OnCexPlusConnectEvent(Sender: TObject); begin oCexPlus.GetTicker('BTC-USD'); end; procedure OnCexPlusMessageEvent(Sender: TObject; Event, Msg: string); begin ShowMessage('Ticker data: ' + Msg); end;
Exchange Plus uses API keys to allow access to Private APIs.
Client can generate, configure and manage api keys, set permission levels, whitelisted IPs for API key etc. via Exchange Plus Web Terminal in the API Keys Management Profile section.
API Keys limit: By default Client can have up to 5 API Keys.
To restrict access to certain functionality while using of API Keys there should be defined specific set of permissions for each API Key. The defined set of permissions can be edited further if necessary.
The following permission levels are available for API Keys:
Example: get the orders.
oClient := TsgcWebSocketClient.Create(nil); oCexPlus := TsgcWSAPI_CexPlus.Create(nil); oCexPlus.Client := oClient; oCexPlus.CexPlus.ApiKey := 'your-api-key'; oCexPlus.CexPlus.ApiSecret := 'your-api-secret'; oCexPlus.OnCexPlusAuthenticated := OnCexPlusAuthenticatedEvent; oCexPlus.OnCexPlusMessage := OnCexPlusMessageEvent; oClient.Active := True; procedure OnCexPlusAuthenticatedEvent(Sender: TObject); begin oCexPlus.GetOrders(); end; procedure OnCexPlusMessageEvent(Sender: TObject; Event, Msg: string); begin ShowMessage('Orders: ' + Msg); end;
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.