This is the API reference for Korbit's old WebSocket API. This API is scheduled to be removed in June 2025, so please consider migrating to the latest API, which can be found here.
The new API is mostly compatible with the old version, with those differences:
MyAsset
type which provides real-time updates on your balances.MyOrder
and MyTrade
types.The WebSocket API is a WebSocket connection interface designed for bidirectional communication between the Korbit server and user clients. Using the WebSocket API allows you to receive real-time information from the Korbit cryptocurrency exchange at the fastest possible speed.
With the REST API, users must send an HTTP request to receive a response and retrieve information. However, with the WebSocket API, a persistent, bidirectional connection is maintained between the Korbit server and user client. As a result, when events such as price changes or order executions occur, information is continuously delivered from the Korbit server to the user client in real-time. Therefore, if you aim to receive real-time information on prices, orders, and trades quickly and conveniently, we recommend using the WebSocket API over the REST API.
Data provided by the WebSocket API is classified into Public
and Private
types, depending on whether it is public information or specific to individual users. Public type data can be received without any authentication. However, to receive Private type data, authentication with Korbit Open API keys is required when establishing the WebSocket connection.
For Public type data, sending a subscription request via WebSocket immediately provides the latest data at the time of the request as snapshot
data. (Snapshot data is not real-time.) All non-snapshot data is real-time
.
ticker
: Provides snapshots and real-time current prices for a specified trading pair.orderbook
: Provides snapshots and real-time order book data for a specified trading pair.trade
: Provides snapshots and real-time trade history for a specified trading pair.myOrder
: Provides real-time status updates on your orders.myTrade
: Provides real-time execution updates on your trades.wss://ws-api.korbit.co.kr/v2/ws
Public type data (Ticker, Orderbook, Trade) can be received simply by connecting to the WebSocket and sending a subscription message, without any authentication. However, to receive Private type data (My Order, My Trade), authentication using Korbit Open API keys is required upon establishing the WebSocket connection.
For authentication, as with the REST API, you need to send a request with an X-KAPI-KEY
header and a signature generated using either HMAC-SHA256
or ED25519
during the WebSocket connection. Specifically, include the X-KAPI-KEY
in the request header, and add timestamp
and signature
information to the URL query string.
Please refer to the Sign API Requests section and the attached example code for more details.
// Node.js, npm i ws
import crypto from "crypto";
import WebSocket from "ws";
const apiKey = "XyAZ_apaUv9pg4ZyGzNHTxabfIDrWIRpPBgk5-olIuM"; // API Key
const apiSecret = "ZwKS2evdxj9j3Neir2s0UHAmpNFfo4a0iHawEElGCBs"; // HMAC-SHA256 Secret Key
const wsUrl = "wss://ws-api.korbit.co.kr/v2/ws"; // Base URL
// HMAC-SHA256 Signature
const createHmacSignature = (query) => {
return crypto.createHmac("sha256", apiSecret).update(query, "utf-8").digest("hex");
};
const timestamp = Date.now(); // Timestamp (ms)
const params = new URLSearchParams({
timestamp: timestamp,
});
const signature = createHmacSignature(params.toString());
// Add Signature to params
params.append("signature", signature);
// Add API Key to the header, Open a WebSocket connection
const ws = new WebSocket(`${wsUrl}?${params.toString()}`, [], {
headers: {
"X-KAPI-KEY": apiKey,
}
});
ws.on("open", () => {
console.log("connected!");
// Send messages to subscribe
ws.send(`[{"method":"subscribe","type":"ticker","symbols":["btc_krw","eth_krw"]}]`);
ws.send(`[{"method":"subscribe","type":"myOrder","symbols":["btc_krw","eth_krw"]},{"method":"subscribe","type":"myTrade","symbols":["btc_krw","eth_krw"]}]`);
});
ws.on("error", (error) => {
console.error(error);
});
ws.on("message", (event) => {
const message = JSON.parse(event);
console.log(message);
});
ws.on("close", () => {
console.log("connection closed!");
});
After the WebSocket connection is established, you must send a request indicating which type of data you wish to subscribe to. In the WebSocket API, subscription request messages are sent in JSON format, with method
, type
, and symbols
specified accordingly.
Since multiple messages can be included at once, even when sending a single request message, it must be enclosed in square brackets []. (Please note that case sensitivity applies.)
[{"method":"subscribe","type":"ticker","symbols":["btc_krw","eth_krw"]}]
[{"method":"subscribe","type":"ticker","symbols":["btc_krw","eth_krw"]},[{"method":"subscribe","type":"orderbook","symbols":["btc_krw","eth_krw"]}]]
# Using wscat in a Node.js environment
$ npm install -g wscat
$ wscat -c wss://ws-api.korbit.co.kr/v2
connected (press CTRL+C to quit)
# Once the WebSocket connection is established, send a data subscription request
> [{"method":"subscribe","type":"ticker","symbols":["btc_krw","eth_krw"]}]
< {"symbol":"btc_krw","timestamp":1730365099072,"type":"ticker","snapshot":true,"data":{"open":"100500000","high":"100651000","low":"100492000","close":"100650000","prevClose":"100497000","priceChange":"153000","priceChangePercent":"0.15","volume":"0.89102242","quoteVolume":"89632429.21566","bestAskPrice":"100651000","bestBidPrice":"100650000","lastTradedAt":1730356819663}}
< {"symbol":"eth_krw","timestamp":1730365099072,"type":"ticker","snapshot":true,"data":{"open":"4390000","high":"4390000","low":"4357000","close":"4357000","prevClose":"4456000","priceChange":"-99000","priceChangePercent":"-2.22","volume":"0.1702132","quoteVolume":"744416.83456","bestAskPrice":"4357000","bestBidPrice":"4324000","lastTradedAt":1730361789775}}
< {"symbol":"btc_krw","timestamp":1730365220489,"type":"ticker","data":{"open":"100501000","high":"100651000","low":"100501000","close":"100650000","prevClose":"100492000","priceChange":"158000","priceChangePercent":"0.16","volume":"0.81866504","quoteVolume":"82360867.25161","bestAskPrice":"100651000","bestBidPrice":"100650000","lastTradedAt":1730356819663}}
In the example, a subscription request is sent to receive current price (ticker
) information for the Bitcoin (btc_krw
) and Ethereum (eth_krw
) trading pairs. First, snapshot data is received, followed by a continuous stream of real-time data. If you want to receive information for multiple trading pairs, enclose the pairs in square brackets [] and separate them with commas ,, as shown in the example above.
To subscribe, set method
to subscribe
; to stop receiving a specific type of data, set method
to unsubscribe
to cancel the subscription.
Refer below for example subscription request and response messages for each type.
Streams latest pricing information for a symbol.
Set to subscribe
or unsubscribe
Set to ticker
Enter the symbols of the trading pairs you want to query.
["btc_krw","eth_krw"]
Fixed value ticker
Server time (unix timestamp, in milliseconds)
1700000000000
Trading pair symbol
btc_krw
Whether the data is a snapshot or a real-time data.
true
- The data is a latest snapshot and not a real-time data. Sent as the first message on subscription.
false
or null
- The data is from a real-time trade.
Open price (24H)
361922.23
High price (24H)
361922.23
Low price (24H)
361922.23
Last price (24H)
361922.23
Previous close price (24H)
261922.23
changed price. prevClose - close
261922.23
changed price percent. 100 * (prevClose - close) / prevClose
10
Trading volume (Base, 24H)
100
Trading volume (Quote/Counter, 24H)
1000000000
Best bid price
5000
Best ask price
6000
Last traded timestamp (unix timestamp, in milliseconds)
1700000000000
[{"method":"subscribe","type":"ticker","symbols":["btc_krw","eth_krw"]}]
{
"type": "ticker",
"timestamp": 1700000027754,
"symbol": "btc_krw",
"snapshot": true,
"data": {
"open": "94679000",
"high": "111162000",
"low": "93861000",
"close": "99027000",
"prevClose": "94679000",
"priceChange": "4348000",
"priceChangePercent": "4.59",
"volume": "147.94385655",
"quoteVolume": "14311735005.18033",
"bestAskPrice": "99027000",
"bestBidPrice": "99026000",
"lastTradedAt": 1700000010022
}
}
Streams orderbook data for a symbol. Up to 30 prices are available for each side.
Set to subscribe
or unsubscribe
Set to orderbook
Enter the symbols of the trading pairs you want to query.
["btc_krw","eth_krw"]
Fixed value orderbook
Server time (unix timestamp, in milliseconds)
1700000000000
Trading pair symbol
btc_krw
Whether the data is a snapshot or a real-time data.
true
- The data is a latest snapshot and not a real-time data. Sent as the first message on subscription.
false
or null
- The data is from a real-time trade.
Timestamp of the orderbook data (unix timestamp, in milliseconds)
1700000000000
bids
price
250000
quantity
10
asks
price
250000
quantity
10
[{"method":"subscribe","type":"orderbook","symbols":["btc_krw"]}]
{
"type": "orderbook",
"timestamp": 1700000006177,
"symbol": "btc_krw",
"snapshot": true,
"data": {
"timestamp": 1700000000234,
"asks": [
{
"price": "99131000",
"qty": "0.00456677"
},
{
"price": "99132000",
"qty": "0.00616665"
},
{
"price": "99133000",
"qty": "0.00808569"
}
],
"bids": [
{
"price": "99120000",
"qty": "0.00363422"
},
{
"price": "99119000",
"qty": "0.00475577"
},
{
"price": "99118000",
"qty": "0.00389054"
}
]
}
}
Streams real-time trades.
Set to subscribe
or unsubscribe
Set to trade
Enter the symbols of the trading pairs you want to query.
["btc_krw","eth_krw"]
Fixed value trade
Server time (unix timestamp, in milliseconds)
1700000000000
Trading pair symbol
btc_krw
Whether the data is a snapshot or a real-time data.
true
- The data is a latest snapshot and not a real-time data. Sent as the first message on subscription.
false
or null
- The data is from a real-time trade.
Time of the trade (unix timestamp, in milliseconds)
1700000000000
trade price
250000
trade quantity
10
whether the taker is the buyer.
true
trade ID (unique for each currency pair)
1234
[{"method":"subscribe","type":"trade","symbols":["btc_krw"]}]
{
"symbol": "btc_krw",
"timestamp": 1700000005498,
"type": "trade",
"snapshot": true,
"data": [
{
"timestamp": 1700000001239,
"price": "98909000",
"qty": "0.00146702",
"isBuyerTaker": true,
"tradeId": 123456
}
]
}
Streams the changes in my orders.
Set to subscribe
or unsubscribe
Set to myOrder
Enter the symbols of the trading pairs you want to query.
["btc_krw","eth_krw"]
Fixed value myOrder
Server time (unix timestamp, in milliseconds)
1700000000000
Trading pair symbol
btc_krw
Whether the data is a snapshot or a real-time data.
true
- The data is a latest snapshot and not a real-time data. Sent as the first message on subscription.
false
or null
- The data is from a real-time trade.
order ID
1234
Order status
pending
Order pending. If the balance is insufficient, the order may fail and change to the expired
status.open
Fully unfilledfilled
Fully executedcanceled
Fully canceledpartiallyFilled
Partially filledpartiallyFilledCanceled
Partially filled and remaining amount canceledexpired
Order submission failedpartiallyFilled
buy
sell
buy
Order price (limit order only. no price for market order.)
5000
open quantity
10
filled quantity
10
[{"method":"subscribe","type":"myOrder","symbols":["btc_krw"]}]
{
"symbol": "btc_krw",
"timestamp": 1700000000000,
"type": "myOrder",
"data": [
{
"orderId": 123456,
"status": "partiallyFilled",
"side": "buy",
"price": "99017000",
"openQty": "0.00206864",
"filledQty": "0.53793136",
}
]
}
Streams trades on my orders.
Set to subscribe
or unsubscribe
Set to myTrades
Enter the symbols of the trading pairs you want to query.
["btc_krw","eth_krw"]
Fixed value myTrades
Server time (unix timestamp, in milliseconds)
1700000000000
Trading pair symbol
btc_krw
Whether the data is a snapshot or a real-time data.
true
- The data is a latest snapshot and not a real-time data. Sent as the first message on subscription.
false
or null
- The data is from a real-time trade.
trade ID
1234
order ID
1234
buy
sell
buy
price
5000
quantity
10
taker=true, maker=false
true
[{"method":"subscribe","type":"myTrade","symbols":["btc_krw"]}]
{
"symbol": "btc_krw",
"timestamp": 1700000000000,
"type": "myTrade",
"data": [
{
"tradeId": 123456,
"orderId": 456789,
"side": "buy",
"price": "99051000",
"qty": "0.0013",
"isTaker": true
}
]
}