Use the Channel property to select the channel type:
You can configure the following properties in the CryptoCom property.
When the client successfully connects to Crypto.com servers, the event OnConnect is fired. After the event OnConnect is fired, then you can start to send and receive messages to/from Crypto.com servers. If you are connecting to the User channel, you must wait till OnCryptoComAuthentication event is fired and check if the success parameter is true, before subscribing to any private channel.
TsgcWebSocketClient oClient = new TsgcWebSocketClient();
TsgcWS_API_CryptoCom oCryptoCom = new TsgcWS_API_CryptoCom();
oCryptoCom.Client = oClient;
oCryptoCom.CryptoCom.ApiKey = "your_api_key";
oCryptoCom.CryptoCom.ApiSecret = "your_api_secret";
oCryptoCom.Channel = cccMarket;
oClient.Active = true;
void OnConnect(TsgcWSConnection Connection)
{
DoLog("#CryptoCom Connected");
}
The Crypto.com 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 Market channels (public):
| Method | Description |
| SubscribeTicker | Subscribe to the ticker stream for an instrument. Provides real-time price and volume data. |
| SubscribeTrade | Subscribe to the recent trades stream for an instrument. |
| SubscribeCandlestick | Subscribe to the candlestick stream. Supports multiple intervals (e.g. 5m, 15m, 30m, 1h, 4h, 1D). |
| SubscribeBook | Subscribe to the order book stream. Supports configurable depth levels (e.g. 10, 50). |
You can subscribe to the following User channels (private, require authentication):
| Method | Description |
| SubscribeOrders | Subscribe to order updates. Optionally filter by instrument name. |
| SubscribeUserTrades | Subscribe to user trade updates. Optionally filter by instrument name. |
| SubscribeBalance | Subscribe to balance updates for your account. |
Find below an example of subscribing to market channels.
void OnConnect(TsgcWSConnection Connection)
{
oCryptoCom.SubscribeTicker("BTC_USDT");
oCryptoCom.SubscribeBook("BTC_USDT", "10");
}
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 |
| GetInstruments | Public | Get the list of available instruments. |
| GetTicker | Public | Get ticker information for one or all instruments. |
| GetOrderBook | Public | Get the order book for an instrument. |
| GetTrades | Public | Get the most recent trades for an instrument. |
| GetCandlestick | Public | Get candlestick/kline data for an instrument. |
| CreateOrder | Private | Create a new order. Supports limit and market orders. |
| CancelOrder | Private | Cancel an existing order. |
| CancelAllOrders | Private | Cancel all open orders for an instrument. |
| GetOpenOrders | Private | Get the list of open orders. |
| GetOrderDetail | Private | Get details of a specific order. |
| GetOrderHistory | Private | Get the order history. |
| GetAccountSummary | Private | Get account summary information. |
Find below an example of using the REST API.
TsgcWS_API_CryptoCom oCryptoCom = new TsgcWS_API_CryptoCom();
oCryptoCom.CryptoCom.ApiKey = "your_api_key";
oCryptoCom.CryptoCom.ApiSecret = "your_api_secret";
// Get instruments
oCryptoCom.REST_API.GetInstruments();
// Create an order
oCryptoCom.REST_API.CreateOrder("BTC_USDT", "BUY", "MARKET", "", "0.001");
// Get account summary
oCryptoCom.REST_API.GetAccountSummary();