Skip to main content

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.

100ResultP
TypenumberModel type
IDnumberId value of the model being processed. It is used in some Result models. The value can be 0 when not in use.
OkbooleanTransaction success
messagestringtransaction message. It usually contains short codes for the transaction. It should not be shown to the end user. For example, the value returned as subscription result: "join | trade: BTCTRY" is similar.

Channel 101 (Request)

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

101RequestP
typenumberModel type
codenumberThe request code. Designed in the same way as possible with package types. These request codes are listed at the end of the document. For example, the client must send this code value 421 (model type of final operations) to request that the last transactions be sent back to it.
channelstringIf the request is sent over a particular channel, this value must be written to the channel name. For non-channel requests, null can be sent.
eventstringIf the request is sent over a particular event, this value must be written to the name of the event. For non-event requests, null can be sent.

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}]
151SubscriptionP
typenumberModel type
channelstringThe name of the channel. For example; trade, orderbook, ticker etc.
eventstringEvent names are often used as "all" or upper-case as pair name (eg BTCTRY, ETHTRY).
joinboolean
  • true means subscribe
  • false means unsubscribe

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}]
401TickerAllC
typenumberModel type
itemsTickerPair []An array of type TickerPair. The only difference is that there is no type variable in every TickerPair model. The TickerPair model is described below.

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}]
402TickerPairP
typenumberModel type
PSstringPair Symbol. For example; BTCTRY
HstringHighest price in the last 24 hours(high).
LstringThe lowest price in the last 24 hours(low).
LastringThe price of the last transaction(last).
VstringVolume.
AVstringAverage price.
DstringDaily change amount.
DSstringDenominator Symbol. For example BTCTRY TRY.
NSstringNumerator Symbol. For example BTCTRY for BTC.
PIDnumberPair Id value.
OnumberOpen. Price of the first transaction of the day.
BstringBid. Best buy order price.
AstringAsk. Best selling order price.
BAstringBidAmount. Best bid order amount.
AAstringAskAmount. Best ask order amount.
DPstringDaily percent. 24-hour change rate.

Channel 422 (TradeSingle)

A message sent from the server to the client represents a single trade data of the specified pair, executed as a taker order, and is sent as it occurs.

Request Example

[151,{"type":151,"channel":"trade","event":"BTCTRY","join":true}]
422TradeSingleP
typenumberModel type
PSnumberPair Symbol. For example; BTCTRY.
AstringThe amount of the transaction (Amount).
Snumber

Trade Side. Shows the side of the order.

  • 0: Buy
  • 1: Sell
DnumberTransaction date (Date). UnixTime is the value in milliseconds.
PstringThe price at which the transaction was made (Price).
IstringThe unique number of the transaction. (Uniqueness is valid only in its own pair)

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}]
431OrderBookFullP
typenumberModel type
CSnumberChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.
PSstringPair Symbol value. For example; BTCTRY
AOOrder []List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.
BOOrder []List of purchase orders.

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}]
432OrderBookDifferenceP
typenumberModel type
CSnumberChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.
PSstringPair Symbol value. For example; BTCTRY
CPnumberChanging Process of pair
AOChangingOrder []List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.
BOChangingOrder []List of purchase orders.

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.

114UserLoginResultP

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.

423UserTradeU
typenumberModel Type
idnumberId of the trade.
orderIdnumberOrder id of the trade.
timestampnumberServer time of the order
numeratorSymbolstringNumerator Symbol. For example for BTCTRY, it is BTC
denominatorSymbolstringDenominator Symbol. For example for BTCTRY, it is TRY
amountstringAmount of the trade.
feestringFee amount of the trade.
taxstringTax amount of the trade.
pricestringPrice of the trade.
orderTypestringThis field indicates if it is a buy order or a sell order.
orderClientIdstringClient Id of the order
preciseAmountnumberPrecise amount of the trade.

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.

441UserOrderMatchU
typenumberModel type
idnumberId value of the model being processed.
usernumberThe id of the user being processed.
isBidbooleanTrue if the transaction is buying or false if the transaction is selling.
methodnumbertransaction method. 0: limit, 1: market, 2: stop limit
pairnumberpair id value of the transaction
symbolstringThe pair symbol value of the operation. For example; BTCTRY
amountstringThe amount of the transaction.
pricestringThe price at which the transaction occurred.
clientIdstringClientId of the order
timestampdateServer time of the order

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.

451orderınsertU
typenumberModel type
pairIdnumberThe pair id value of the order
symbolstringThe pair symbol value of the order
IDnumberOrder Id value
methodnumberType of order (0: limit, 1: market, 2: stop limit)
userIdnumberThe Id value of the user who issued the order
pricestringPrice of the order
amountstringAmount of order
numLeftnumbertotal crypto amount
denomLeftnumbertotal order amount (TRY, USDT, BTC)
newOrderClientIdstringClientId of the order

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.

452OrderDeleteU

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.

453OrderUpdateU