Models

The supported model types between Server and Client are given in the following tables.

  • The Code in the table is the type value of the model. (The number on the top left of the model)

  • ShortName is the model code (which we use this way) that can be used as a variable, class, or enum name.

  • Mixes of types (letter code at the top right of the model) and usage patterns are as follows:

    • P: general packages. Contains type. There is no need to subscribe or login to any channel to receive or send.

    • U: General packages that are accessed only by logged-in users. These packages also do not have a /channel and subscription connection.

Code Example for Connecting Channels

        static async Task Main(string[] args)
        {
            await WebsocketConnection();
        }

        private static string message = "[151,{\"type\":151,\"channel\":\"CHANNEL_NAME_HERE\",event:\"EVENT_NAME_HERE\",\"join\":true}]";
        
        private static async Task WebsocketConnection()
        {
            ClientWebSocket client = new ClientWebSocket();
            Uri _uri = new Uri("wss://ws-feed-sandbox.btctrader.com");
            await client.ConnectAsync(_uri, CancellationToken.None);
            await SendSocketMessage(client, _orderBookFull);
        }
        
        
        private static async Task SendSocketMessage(ClientWebSocket client, string msg)
        {
            await client.SendAsync(buffer: new ArraySegment<byte>(array: Encoding.UTF8.GetBytes(msg),
                    offset: 0,
                    count: msg.Length),
                messageType: WebSocketMessageType.Text,
                endOfMessage: true,
                cancellationToken: CancellationToken.None);
            
            var buffer = new byte[1024 * 20];

            while (true)
            {
                WebSocketReceiveResult result = await client.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
            
                string resultMessage = Encoding.UTF8.GetString(buffer, 0, result.Count);

                Console.WriteLine(resultMessage);
            }
        }

Public Socket Messages

Channel 100 (Result)

A message sent from the server to the client. These are model-free results returned from requests sent to the server. For example, UserLogin, Subscription, and so on.

Channel 101 (Request)

Extra requests sent to the server. For example, the Request model is sent when the last operations list is requested again.

Channel 151 (Subscription)

A message sent from the client to the server. A model sent to subscribe to or unsubscribe from an event on a channel. Messages related to subscribed events are continuously sent to the user.

Request Example

[151,{"type":151,"channel":"CHANNEL_NAME","event":"PAIRSYMBOL","join":true}]

Channel 401 (TickerAll)

A message sent from the server to the client. It is the model of all ticker data belonging to all Pairs.

Request Example

[151,{"type":151,"channel":"ticker","event":"all","join":true}]

Channel 402 (TickerPair)

A message sent from the server to the client. It is only a model of all ticker data for a particular Pair.

Request Example

[151,{"type":151,"channel":"ticker","event":"BTCTRY","join":true}]

Channel 422 (TradeSingle)

A message sent from the server to the client. It is a single trade data of the specified Pair. This data is sent as it occurs.

Request Example

[151,{"type":151,"channel":"trade","event":"BTCTRY","join":true}]

Channel 431 (OrderBookFull)

A message sent from the server to the client. It is the entire order book model of a particular Pair.

Request Example

[151,{"type":151,"channel":"orderbook","event":"BTCTRY","join":true}]

Channel 432 (OrderBookDifference)

A message sent from the server to the client. Sends order book data of only a particular Pair's changes. The user must have previous order book data to use this model. This data is sent automatically from the server when the event is subscribed.

Changing process is:

  • CP: Orders are transaction type.

    • 0: Updated

    • 1: New added

    • 3: Deleted

  • P: Order price value.

  • A: Orders is the quantity.

Request Example

[151,{"type":151,"channel":"obdiff","event":"BTCTRY","join":true}]

Private Socket Messages

Channel 114 (UserLoginResult)

A message sent from the server to the client. This is the answer to the user input model. It is exactly the same as the Result model.When a request is made with a HMAC Authentication, user login response is received from channel 114.

Channel 423 (UserTrade)

A message sent from the server to the client. Socket message of user/transactions/trade endpoint. When user's order match, message is sent to the client.

Channel 441 (UserOrderMatch)

It is the model that contains the details of this process, which is sent from the server to the user when an order of the connected user is executed.

Channel 451 (OrderInsert)

A message sent from the server to the client. When a user's order is added to the system, it is the model sent to the user. Newly added orders will be sent with the model. When this model is received from the server, the user's orders can be updated from the endpoint.

Channel 452 (OrderDelete)

A message sent from the server to the client. When a user's order is deleted from the system, it is the model that is sent to the user. Deleted orders with model will be sent. When this model is received from the server, the user's orders can be updated from the endpoint. The model is the same as the OrderInsert model.

Channel 453 (OrderUpdate)

A message sent from the server to the client. This is the model sent to the user when an order of the user is updated in the system. Orders updated with the model will be sent. When this model is received from the server, the user's orders can be updated from the endpoint. The model is the same as the OrderInsert model.

Last updated