Use the GateIOChannel property to select the channel type:
You can configure the following properties in the GateIO property.
When the client successfully connects to Gate.io servers, the event OnConnect is fired. After the event OnConnect is fired, then you can start to send and receive messages to/from Gate.io servers. If you are connecting to the private websocket channel, you must wait till OnGateIOAuthentication event is fired and check if the success parameter is true, before subscribing to any private channel.
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWS_API_GateIO oGateIO = new TsgcWS_API_GateIO();
oGateIO.Client = oClient;
oGateIO.GateIO.ApiKey = "your_api_key";
oGateIO.GateIO.ApiSecret = "your_api_secret";
oGateIO.GateIOChannel = giocSpot;
oClient.Active = true;
void OnConnect(TsgcWSConnection Connection)
{
DoLog("#GateIO Connected");
}
The GateIO client implements the following events to control the connection flow and get data sent from the WebSocket server:
The websocket feed provides real-time market data updates for orders and trades.
You can subscribe to the following channels:
| Method | Public or Private | Description |
| SubscribeTicker | Public | Subscribe to the ticker stream for a symbol. |
| SubscribeTrades | Public | Subscribe to the recent trades stream. |
| SubscribeCandlesticks | Public | Subscribe to the candlestick stream. Supports multiple intervals (e.g. 1m, 5m, 15m, 30m, 1h). |
| SubscribeOrderBook | Public | Subscribe to the order book stream. Supports configurable depth levels and update intervals. |
| SubscribeOrders | Private | Subscribe to order updates. Requires authentication. |
| SubscribeBalances | Private | Subscribe to balance updates. Requires authentication. |
Find below an example of subscribing to public websocket channels.
void OnConnect(TsgcWSConnection Connection)
{
oGateIO.SubscribeTicker("BTC_USDT");
oGateIO.SubscribeOrderBook("BTC_USDT", "20", "100ms");
}
The REST API provides Public and Private methods to request data from markets and private accounts. Access the REST API through the REST_API property of the component.
| Method | Public / Private | Description |
| GetCurrencyPairs | Public | Get information about available currency pairs. |
| GetTickers | Public | Get ticker information for one or all currency pairs. |
| GetOrderBook | Public | Get the order book for a currency pair. |
| GetCandlesticks | Public | Get candlestick/kline data for a currency pair. |
| GetTrades | Public | Get the most recent trades for a currency pair. |
| PlaceOrder | Private | Place a new order. Supports limit and market orders. |
| CancelOrder | Private | Cancel an existing order. |
| GetOrder | Private | Get details of a specific order. |
| GetOpenOrders | Private | Get the list of open orders. |
| GetSpotAccounts | Private | Get spot account information. |
Find below an example of using the REST API.
TsgcWS_API_GateIO oGateIO = new TsgcWS_API_GateIO();
oGateIO.GateIO.ApiKey = "your_api_key";
oGateIO.GateIO.ApiSecret = "your_api_secret";
// Get tickers
oGateIO.REST_API.GetTickers("BTC_USDT");
// Place an order
oGateIO.REST_API.PlaceOrder("BTC_USDT", "buy", "0.001", "50000", "limit");