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.
    • A: Packages received only when subscribed to events on the channels. In the models of these packages, besides the type variable, there are string variables named channel and event.

Code Example for connecting channels

C#
Python
GoLang
Node.js
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);
}
}
import json
import pprint
import time
import websocket
try:
import thread
except ImportError:
import _thread as thread
def on_message(ws, message):
data = json.loads(message)
pprint.pprint(data)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
def run(*args):
time.sleep(1)
message = [
151,
{
"type": 151,
"channel": 'CHANNEL_NAME_HERE',
"event": 'EVENT_NAME_HERE',
"join": True
}
]
ws.send(json.dumps(message))
thread.start_new_thread(run, ())
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp(
"wss://ws-feed-pro.btcturk.com/",
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever()
package main
import (
"flag"
"github.com/gorilla/websocket"
"log"
"net/url"
)
var addr = flag.String("addr", "ws-feed-pro.btcturk.com", "BtcTurk Websocket Feed")
func main() {
u := url.URL{Scheme: "wss", Host: *addr, Path: "/"}
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
log.Fatal("Dial Error:", err)
}
message := []byte(`[151, {
"type":151,
"channel":"CHANNEL_NAME_HERE",
"event": "EVENT_NAME_HERE",
"join":true}]`)
err = c.WriteMessage(websocket.TextMessage, message)
if err != nil {
log.Println("ERROR:", err)
return
}
for {
messageType, p, err := c.ReadMessage()
if err != nil {
log.Println(err)
return
}
log.Println(string(p))
if err = c.WriteMessage(messageType, p); err != nil {
log.Println(err)
return
}
}
}
const WebSocket = require('ws')
const url = 'wss://ws-feed-pro.btcturk.com/'
const connection = new WebSocket(url)
const message = `[151,{"type":151,"channel":"CHANNEL_NAME_HERE","event":"EVENT_NAME_HERE","join":true}]`
connection.onopen = () => {
connection.send(message)
}
connection.onerror = (error) => {
console.log(`WebSocket error: ${error}`)
}
connection.onmessage = (e) => {
console.log(e.data)
}

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.
100
Result
P
Type
number
Model type
ID
number
Id value of the model being processed. It is used in some Result models. The value can be 0 when not in use.
Ok
boolean
Transaction success
message
string
transaction 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.
101
Request
P
type
number
Model type
code
number
The 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.
channel
string
If 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.
event
string
If 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}]
151
Subscription
P
type
number
Model type
channel
string
The name of the channel. For example; trade, orderbook, ticker etc.
event
string
speak event name event name. Event names are often used as “all” or upper-case as pair name (eg BTCTRY, ETHTRY).
join
boolean
If true, it means that you want to subscribe, if false, you can 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}]
401
TickerAll
C
type
number
Model type
items
TickerPair []
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}]
402
TickerPair
C
type
number
Model type
PS
string
Pair Symbol. For example; BTCTRY
H
string
High. Highest price in the last 24 hours.
L
string
Lower. The lowest price in the last 24 hours.
La
string
Last. The price of the last transaction.
V
string
Volume. Volume.
AV
string
Average. Average price.
D
string
Daily. Daily change amount.
DS
string
Denominator Symbol. For example BTCTRY TRY.
NS
string
Numerator Symbol. For example BTCTRY for BTC.
PID
number
Pair Id value.
O
number
Open. Price of the first transaction of the day.
B
string
Bid. Best purchase order price.
A
string
Ask. Best selling order price.
DP
string
Daily percent. 24-hour exchange rate.

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}]
422
TradeSingle
C
type
number
Model type
PS
number
Pair Symbol. For example; BTCTRY.
A
string
Amount. The amount of the transaction.
S
number
Trade Side. Shows the status of the order.
  • 0: Buy
  • 1: Sell
D
number
Date. Transaction date. UnixTime is the value in milliseconds.
P
string
Price. The price at which the transaction was made.
I
string
The unique number of the transaction. (Uniqueness is valid only in its own pairi)

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}]
431
OrderBookFull
C
type
number
Model type
CS
number
ChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.
PS
string
Pair Symbol value. For example; BTCTRY
AO
Order []
List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.
BO
Order []
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.
Changingord 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}]
432
OrderBookDifference
C
type
number
Model type
CS
number
ChangeSet. Change number. It comes in the form of sequential values. There is no control at this time.
PS
string
Pair Symbol value. For example; BTCTRY
CP
number
Changing Process of pair
AO
ChangingOrder []
List of sales orders. The Order object contains two variables: A, amount, and transaction quantity. P is the price, the transaction price.
BO
ChangingOrder []
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.
114
UserLoginResult
P

Channel 201 (BalanceUpdated)

The model sent by the server when the user's balance changes for any reason (confirmation, withdrawal request, deposit request, request confirmations, etc.). When this message is received, the user's balance must be updated from the API endpoint.
201
BalanceUpdated
U
type
number
Model type
UserID
number
User Id
payload
string
Transaction description. For informational purposes.

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.
441
UserOrderMatch
U
type
number
Model type
id
number
Id value of the model being processed.
user
boolean
The id of the user being processed.
isBid
string
True if the transaction is buying or false if the transaction is buying.
method
number
transaction method. 0: limit, 1: market, 2: stop limit
pair
number
pair id value of the transaction
symbol
string
The pair symbol value of the operation. For example; BTCTRY
amount
string
The amount of the transaction.
price
string
The price at which the transaction occurred.
clientId
string
ClientId of the order
timestamp
date
Server 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.
451
orderınsert
U
type
number
Model type
pairId
number
The pair id value of the order
symbol
string
The pair symbol value of the order
ID
number
Order Id value
method
number
Type of order (0: limit, 1: market, 2: stop limit)
userId
number
The Id value of the user who issued the order
price
string
Price of the order
amount
string
Amount of order
numLeft
number
total crypto amount
denomLeft
number
total order amount (TRY, USDT, BTC)
newOrderClientId
string
ClientId 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.
452
OrderDelete
U

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.
453
OrderUpdate
U