Introduction
WebSockets application programming interface (API) offers real-time market data updates. WebSockets is a bidirectional protocol offering the fastest real-time data, helping you build real-time applications.
The public message types presented below do not require authentication.
Private-data messages can be subscribed to on a separate authenticated endpoint.
General Considerations
- Transport Layer Security (TLS) with Server Name Indication (SNI) is required in order to establish a Kraken WebSockets API connection. Note: See Cloudflare's "What is SNI?" guide for more details.
- All messages sent and received via WebSockets are encoded in JavaScript Object Notation (JSON) format.
- All decimal fields (including timestamps) are quoted to preserve precision.
- Timestamps should not be considered unique and not be considered as aliases for transaction identifiers (IDs). Also, the granularity of timestamps is not representative of transaction rates.
- At least one private message should be subscribed to keep the authenticated client connection open.
- Please use the instrument channel to fetch the
list of pairs which can be subscribed via WebSockets API.
The
pairs
array contains the supported pair names (see fieldsymbol
). - Cloudflare imposes a connection/re-connection rate limit---per Internet Protocol (IP) address---of approximately 150 attempts per rolling 10 minutes. If this is exceeded, the IP address is banned for 10 minutes.
Recommended Reconnection Behaviour
- Normal operation
- Attempt reconnection instantly up to a handful of times if the websocket is dropped randomly.
- After maintenance or extended downtime
- Attempt to reconnect no more quickly than once every five (5) seconds.
There is no advantage to reconnecting more rapidly after maintenance during `cancel_only` mode.
Endpoints
The WebSockets v2 endpoints can be reached via two endpoints.
Public Market Data
wss://ws.kraken.com/v2
Private Market Data
wss://ws-auth.kraken.com/v2
Authentication
The API client must request an authentication "token" via the following REST
API endpoint GetWebSocketsToken
to connect to WebSockets Private endpoints.
The token should be used within 15 minutes of creation.
The token does not expire once a connection to a
WebSockets API private-data message (feed) is maintained.
Endpoint Uniform Resource Locator (URL):
https://api.kraken.com/0/private/GetWebSocketsToken
The resulting token must be provided in the "token" field of any WebSockets API private-data message (feed) subscription.
Data Format Notes
Timestamps using the RFC3339 format (e.g. 2021-05-11T19:47:09.896860Z
) to be
both: machine-readable and human-readable.
Payloads are normalised JSON objects with no/minimal positional or variable length fields, to allow for maximum future flexibility without breaking client code.
WebSockets v2 aims to incorporate a number of bug fixes and to clean up many idiosyncrasies and ambiguities from v1, requiring breaking changes, such that integrating with the API from scratch is a much easier and more pleasant experience.
Methods
method
can be considered as analogous to and consistent with a specific
combination of REST endpoint and HTTP method in a future improved REST API.
(e.g. Websockets v2 cancel_order
will correspond to a REST v2
DELETE /api/order
, etc.)
Requests
Requests are made for a particular method
, with the required
params
for that method specified by the client.
All requests accept an optional client-specified integer request identifier
(req_id
) for matching up the response, when returned.
Note: Uniqueness of the req_id
is not enforced.
Responses
All responses include both time_in
and time_out
to reflect when our
Websockets server received the request and sent the response, to help further
isolate and measure network/client/server latency.
success
indicates if the request was handled successfully.
result
includes details of the response, if applicable.
error
, if present, gives details of what error occurred.
Channels (Snapshot/Update)
Channel messages include a data
payload specific to that channel, and either
provide a snapshot
of or update
to data, depending on the type of the
channel message.
Public Messages
Messages without the need of authentication.
Ping
Example Ping Request
{
"method": "ping"
}
Example Ping (Pong) Response
{
"method": "pong",
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Ping (Pong) Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"method": {
"const": "pong",
"type": "string"
},
"time_in": {
"type": "string"
},
"time_out": {
"type": "string"
}
},
"required": [
"method",
"time_in",
"time_out"
],
"title": "Ping (pong) response JavaScript Object Notation (JSON) schema",
"type": "object"
}
Clients can ping server to determine whether connection is alive; the server responds with pong. This is an application level ping, distinct from the protocol-level ping in the WebSockets standard, the latter of being server-initiated.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | ping method name |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message |
Subscribe
Example Subscribe Request
{
"method": "subscribe",
"params": {
"channel": "book",
"snapshot": false,
"symbol": [
"BTC/USD"
]
},
"req_id": 1234567890
}
Example Subscribe Response
{
"method": "subscribe",
"req_id": 1234567890,
"result": {
"channel": "book",
"snapshot": false,
"symbol": "BTC/USD"
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Subscriptions to a particular channel can be made for multiple symbols at once. They are individually confirmed and responded to.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Unsubscribe
Example Unsubscribe Request
{
"method": "unsubscribe",
"params": {
"channel": "book",
"symbol": [
"BTC/USD"
]
},
"req_id": 1234567890
}
Example Unsubscribe Response
{
"method": "unsubscribe",
"req_id": 1234567890,
"result": {
"channel": "book",
"symbol": "BTC/USD"
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Canceling the subscriptions of a particular channel can be made for multiple symbols at once. They are individually confirmed and responded to.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | unsubscribe method name. |
params | yes | object | Parameters for the given unsubscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Private Messages
Add Order
Example Add Order Request
{
"method": "add_order",
"params": {
"limit_price": 1010.10,
"order_type": "limit",
"order_userref": 1,
"order_qty": 0.123456789,
"side": "buy",
"symbol": "BTC/USD",
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
Example Add Order Response
{
"method": "add_order",
"result": {
"order_id": "ORDERX-IDXXX-XXXXX1",
"order_userref": 1
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Allows you to place a new order.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | add_order method name. |
params | yes | object | Parameters for the given add_order method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
cash_order_qty | no | integer | Order volume expressed in quote currency. Note: this is supported for "market" orders only. |
conditional | no | object | Conditional parameters, see below. |
deadline | no | string | RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) after which the matching engine should reject the new order request, in presence of latency or order queueing. Note: timestamp must be at least 2 seconds and at most 60 seconds in the future. |
display_qty | no | float | When set this turns the order into an iceberg order with display_qty as visible quantity and hiding rest of order_qty . This can only be used with limit order type. |
effective_time | no | string | RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) of scheduled start time. |
expire_time | no | string | RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) of expiration time. |
fee_preference | no | string | Fee preference base or quote currency.
|
limit_price | no | float | Limit price for limit orders |
margin | no | boolean | Uses margin trading. |
no_mpp | no | boolean | Disable market price protection for market orders.
|
order_qty | no | float | Order quantity in terms of the base asset. |
order_type | yes | string | Sets order type.
|
order_userref | no | integer | User reference that identifies one or more orders. |
post_only | no | boolean | Post-only order.
Note: this is supported for limit orders only. |
reduce_only | no | boolean | If set as true , it reduces an existing position without opening an opposite long or short position worth more than the current value of your leveraged assets.
|
side | yes | string | Side type.
|
stop_price | no | float | Stop price for stop-loss-limit and take-profit-limit orders. |
stp_type | no | string | Self trade prevention behavior definition.
|
symbol | yes | string | Currency pair. |
time_in_force | no | string | Time-in-force of the order to specify how long it should remain in the order book before being cancelled.
GTC |
token | yes | string | Session token. |
trigger | no | string | Reference price to trigger stop-loss , stop-loss-limit , take-profit and take-profit-limit orders.
|
validate | no | boolean | If set to true , validate inputs only; do not submit order. |
Request Params-Order-Conditional Fields
The conditional
objects contains order type and price fields:
Field | Required | Type | Description |
---|---|---|---|
order_type | no | string | Conditional close order type.
|
stop_price | no | float | Conditional stop order price. |
limit_price | no | float | Conditional limit order price. |
Note: Conditional close orders are triggered by execution of the primary order in the same quantity and opposite direction, but once triggered are independent orders that may reduce or increase net position.
Batch Add
Example Batch Add Request
{
"method": "batch_add",
"params": {
"deadline": "2022-06-13T08:09:10.123456Z",
"orders": [
{
"limit_price": 1010.10,
"order_qty": 0.123456789,
"order_type": "limit",
"order_userref": 1,
"side": "buy"
},
{
"limit_price": 2020.20,
"order_qty": 0.987654321,
"order_type": "limit",
"order_userref": 2,
"side": "sell",
"stp_type": "cancel_both"
}
],
"symbol": "BTC/USD",
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN",
"validate": false
},
"req_id": 1234567890
}
Example Batch Add Response
{
"method": "batch_add",
"req_id": 1234567890,
"result": [
{
"order_id": "ORDERX-IDXXX-XXXXX1",
"order_userref": 1
},
{
"order_id": "ORDERX-IDXXX-XXXXX2",
"order_userref": 2
}
],
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Multiple orders can be submitted in one request via batch_add
method.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | batch_add method name. |
params | yes | object | Parameters for the given batch_add method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
deadline | no | string | RFC3339 timestamp after which the matching engine should reject the new order request, in presence of latency or order queueing. Note: timestamp must be at least 2 seconds and at most 60 seconds in the future. |
orders | yes | array | Array of orders to add. Note: must contain between 2 and 15 orders. |
symbol | yes | string | Currency pair. |
token | yes | string | Session token. |
validate | no | boolean | If set to true , validate inputs only; do not submit order.
|
Request Params-Order Fields
orders
is an array of individual objects representing add orders, individual
objects have these possible fields:
Field | Required | Type | Description |
---|---|---|---|
cash_order_qty | no | float | Order volume expressed in quote currency. Note: this is supported for market orders only. |
conditional | no | object | Conditional parameters. |
display_qty | no | float | When set this turns the order into an iceberg order with display_qty as visible quantity and hiding rest of order_qty . This can only be used with limit order type. |
effective_time | no | string | RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) of scheduled start time. |
expire_time | no | string | RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) of expiration time. |
fee_preference | no | string | Fee preference base or quote currency.
|
limit_price | no | float | Limit price for limit orders. |
margin | no | boolean | Uses margin trading. |
no_mpp | no | boolean | Disable market price protection for market orders.
|
order_qty | no | float | Order quantity in terms of the base asset. |
order_type | yes | string | Sets order type.
|
order_userref | no | integer | User reference that identifies one or more orders. |
post_only | no | boolean | Post-only order.
Note: this is supported for limit orders only. |
reduce_only | no | boolean | If set as true , it reduces an existing position without opening an opposite long or short position worth more than the current value of your leveraged assets.
|
side | yes | string | Side type.
|
stop_price | no | float | Stop price for stop-loss-limit and take-profit-limit orders. |
stp_type | no | string | Self trade prevention behavior definition.
|
time_in_force | no | string | Time-in-force of the order to specify how long it should remain in the order book before being cancelled.
GTC |
trigger | no | string | Reference price to trigger stop-loss , stop-loss-limit , take-profit and take-profit-limit orders.
|
Request Params-Order-Conditional Fields
The conditional
objects contains order type and price fields:
Field | Required | Type | Description |
---|---|---|---|
limit_price | no | float | Conditional limit order price. |
order_type | no | string | Conditional close order type.
|
stop_price | no | float | Conditional stop order price. |
Note: Conditional close orders are triggered by execution of the primary order in the same quantity and opposite direction, but once triggered are independent orders that may reduce or increase net position.
Batch Cancel
Example Batch Cancel Request
{
"method": "batch_cancel",
"params": {
"orders": [
"1",
"2",
"ORDERX-IDXXX-XXXXX3"
],
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
Example Batch Cancel Response
{
"method": "batch_cancel",
"req_id": 1234567890,
"result": {
"count": 3
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Multiple orders can be canceled in one request via batch_cancel
method.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | batch_cancel method name. |
params | yes | object | Parameters for the given batch_cancel method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
orders | yes | array | Array of strings representing either: order_userref (s) or order_id (s) Note: array must contain between 2 and 50 items. |
token | yes | string | Session token. |
Cancel All Orders
Example Cancel All Request
{
"method": "cancel_all",
"params": {
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
Example Cancel All Response
{
"method": "cancel_all",
"req_id": 1234567890,
"result": {
"count": 123
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | cancel_all method name. |
params | yes | object | Parameters for the given cancel_all method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
token | yes | string | Session token. |
Cancel All Orders After
Example Cancel All Orders After Request
{
"method": "cancel_all_orders_after",
"params": {
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN",
"timeout": 100
},
"req_id": 1234567890
}
Example Cancel All Orders After Response
{
"method": "cancel_all_orders_after",
"req_id": 1234567890,
"result": {
"currentTime": "2022-06-13T08:09:10Z",
"triggerTime": "2022-06-13T08:09:20Z"
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
cancel_all_orders_after
provides a "Dead Man's Switch" mechanism to protect
the client from network malfunction, extreme latency or unexpected matching
engine downtime.
The client can send a request with a timeout (in seconds), that will start a
countdown timer which will cancel all client orders when the timer expires.
The client has to keep sending new requests to push back the trigger time, or
deactivate the mechanism by specifying a timeout of 0.
If the timer expires, all orders are cancelled and then the timer remains
disabled until the client provides a new (non-zero) timeout.
The recommended use is to make a call every 15 to 30 seconds, providing a timeout of 60 seconds. This allows the client to keep the orders in place in case of a brief disconnection or transient delay, while keeping them safe in case of a network breakdown. It is also recommended to disable the timer ahead of regularly scheduled trading engine maintenance (if the timer is enabled, all orders will be cancelled when the trading engine comes back from downtime - planned or otherwise).
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | cancel_all_orders_after method name. |
params | yes | object | Parameters for the given cancel_all_orders_after method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
token | yes | string | Session token. |
timeout | yes | integer | Duration (in seconds) to set/extend the timer by. Note: should be less than 86400 seconds. |
Cancel Order
Example Cancel Order Request
{
"method": "cancel_order",
"params": {
"order_id": [
"ORDERX-IDXXX-XXXXX1",
"ORDERX-IDXXX-XXXXX2"
],
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
Example Cancel Order response for
ORDERX-IDXXX-XXXXX1
{
"method": "cancel_order",
"req_id": 1234567890,
"result": {
"order_id": "ORDERX-IDXXX-XXXXX1"
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Example Cancel Order response for
ORDERX-IDXXX-XXXXX2
{
"method": "cancel_order",
"req_id": 1234567890,
"result": {
"order_id": "ORDERX-IDXXX-XXXXX2"
},
"success": true,
"time_in": "2022-06-13T08:09:10.123456Z",
"time_out": "2022-06-13T08:09:10.7890123"
}
Cancels a particular open order (or set of open orders) by order_id or user reference.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | cancel_order method name. |
params | yes | object | Parameters for the given cancel_order method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
order_id | no | array | Array of strings representing order_id (s). |
order_userref | no | array | Array of strings representing order_userref (s). |
token | yes | string | Session token. |
Note: Though order_id
and order_userref
are individually optional,
at least one of them must be filled.
Edit Order
Example Edit order Request
{
"method": "edit_order",
"params": {
"order_id": "ORDERX-IDXXX-XXXXX1",
"order_qty": 0.2123456789,
"symbol": "BTC/USD",
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
Example Edit Order response
{
"method": "edit_order",
"req_id": 1234567890,
"result": {
"order_id": "ORDERX-IDXXX-XXXXX2",
"original_order_id": "ORDERX-IDXXX-XXXXX1"
},
"success": true,
"time_in": "2022-07-15T12:56:09.876488Z",
"time_out": "2022-07-15T12:56:09.923422Z"
}
Edit volume and price on open orders.
Un-editable orders include triggered stop/profit orders, orders
with conditional close terms attached, those already cancelled or filled and
those where the executed volume is greater than the newly supplied volume.
post_only
flag is not retained from original order after successful edit.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | edit_order method name. |
params | yes | object | Parameters for the given edit_order method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
Field | Required | Type | Description |
---|---|---|---|
deadline | no | string | RFC3339 timestamp after which the matching engine should reject the new order request, in presence of latency or order queueing. Note: timestamp must be at least 2 seconds and at most 60 seconds in the future. |
display_qty | no | float | When set this turns the order into an iceberg order with display_qty as visible quantity and hiding rest of order_qty . This can only be used with limit order type. |
fee_preference | no | string | Fee preference base or quote currency.
|
limit_price | no | float | Limit price. |
no_mpp | no | boolean | Disable market price protection for market orders.
|
order_id | yes | string | Either order_id or order_userref of the order to be edited. |
order_qty | no | float | Order quantity in terms of the base asset. |
order_userref | no | string | User reference that identifies one or more orders. |
post_only | no | boolean | Post-only order.
Note: this is supported for limit orders only. |
price | no | float | DEPRECATED: use limit_price . limit orders. |
reduce_only | no | boolean | If set as true , it reduces an existing position without opening an opposite long or short position worth more than the current value of your leveraged assets.
|
stop_price | no | float | Stop price for stop-loss-limit and take-profit-limit orders. |
symbol | yes | string | Currency pair. |
token | yes | string | Session token. |
trigger | no | string | Price signal used to trigger stop-loss , stop-loss-limit , take-profit and take-profit-limit orders.
|
validate | no | boolean | If set to true , validate inputs only; do not submit order. |
Note: Though limit_price
and order_qty
and stop_price
are individually
optional, at least one of them must be present.
Channels
Book
Example Subscribe Book Request
{
"method": "subscribe",
"params": {
"channel": "book",
"depth": 10,
"snapshot": true,
"symbol": [
"BTC/USD"
]
},
"req_id": 1234567890
}
The channel book
pushes order book snapshots and real-time updates.
Subscriptions to channel book
can be made for multiple symbols at once.
They are individually confirmed and responded to.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | book channel name. |
depth | no | integer | Book depth for subscription.
|
snapshot | no | boolean | Request a snapshot after subscribing.
|
symbol | yes | array | Symbol(s) to subscribe to. |
Snapshot Response
Example Book Snapshot Response
{
"channel": "book",
"type": "snapshot",
"data": [
{
"asks": [
{
"price": 34726.4,
"qty": 0.25
},
{
"price": 34727.7,
"qty": 0.21
},
{
"price": 34727.8,
"qty": 0.05
},
{
"price": 34731.6,
"qty": 0.3459
},
{
"price": 34731.7,
"qty": 0.07103557
},
{
"price": 34731.9,
"qty": 0.28802536
},
{
"price": 34733,
"qty": 0.72004074
},
{
"price": 34736.2,
"qty": 0.31988209
},
{
"price": 34738,
"qty": 0.143
},
{
"price": 34739,
"qty": 0.24041
}
],
"bids": [
{
"price": 34717.6,
"qty": 0.13
},
{
"price": 34714.1,
"qty": 0.08572098
},
{
"price": 34713.9,
"qty": 0.38
},
{
"price": 34712.6,
"qty": 0.028808
},
{
"price": 34711.8,
"qty": 0.86
},
{
"price": 34710.2,
"qty": 1.67978564
},
{
"price": 34710.0,
"qty": 0.71990644
},
{
"price": 34709.3,
"qty": 0.26085746
},
{
"price": 34707.9,
"qty": 0.16037166
},
{
"price": 34707.8,
"qty": 0.05682871
}
],
"checksum": 2645840827,
"symbol": "BTC/USD"
}
]
}
Book Snapshot Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"channel": {
"const": "book",
"type": "string"
},
"data": {
"items": {
"properties": {
"asks": {
"items": {
"properties": {
"price": {
"type": "number"
},
"qty": {
"type": "number"
}
},
"required": [
"price",
"qty"
],
"type": "object"
},
"type": "array"
},
"bids": {
"items": {
"properties": {
"price": {
"type": "number"
},
"qty": {
"type": "number"
}
},
"required": [
"price",
"qty"
],
"type": "object"
},
"type": "array"
},
"checksum": {
"type": "integer"
},
"symbol": {
"type": "string"
}
},
"required": [
"asks",
"bids",
"checksum",
"symbol"
],
"type": "object"
},
"type": "array"
},
"type": {
"const": "snapshot",
"type": "string"
}
},
"required": [
"channel",
"data",
"type"
],
"title": "Book snapshot response JavaScript Object Notation (JSON) schema",
"type": "object"
}
The returned snapshot data contains the top 10 bids and asks for the relevant symbol including a CRC32 checksum of the top 10 bids and asks.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | book channel name. |
data | yes | object | The snapshot data payload. |
type | yes | string | The snapshot data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
asks | yes | array | The top 10 asks. |
bids | yes | array | The top 10 bids. |
checksum | yes | integer | CRC32 checksum for the top 10 bids and asks. |
symbol | yes | string | The relevant symbol. |
Response Data-Asks Fields
Field | Required | Type | Description |
---|---|---|---|
price | yes | float | The ask price. |
qty | yes | float | The ask quantity |
Response Data-Bids Fields
Field | Required | Type | Description |
---|---|---|---|
price | yes | float | The bid price. |
qty | yes | float | The bid quantity |
Update Response
Example Book Update Response
{
"channel": "book",
"data": [
{
"asks": [
{
"price": 34726.4,
"qty": 0
},
{
"price": 34739.7,
"qty": 2.1541
}
],
"bids": [],
"checksum": 4022926185,
"symbol": "BTC/USD",
"timestamp": "2022-06-13T08:09:10.123456Z"
}
],
"type": "update"
}
Book Update Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"channel": {
"const": "book",
"type": "string"
},
"data": {
"items": {
"properties": {
"asks": {
"items": {
"properties": {
"price": {
"type": "number"
},
"qty": {
"type": "number"
}
},
"required": [],
"type": "object"
},
"type": "array"
},
"bids": {
"items": {
"properties": {
"price": {
"type": "number"
},
"qty": {
"type": "number"
}
},
"required": [],
"type": "object"
},
"type": "array"
},
"checksum": {
"type": "integer"
},
"symbol": {
"type": "string"
},
"timestamp": {
"format": "date-time",
"type": "string"
}
},
"required": [
"asks",
"bids",
"checksum",
"symbol",
"timestamp"
],
"type": "object"
},
"type": "array"
},
"type": {
"const": "update",
"type": "string"
}
},
"required": [
"channel",
"data",
"type"
],
"title": "Book update response JavaScript Object Notation (JSON) schema",
"type": "object"
}
The returned snapshot data contains the updates of the bids and asks for the relevant symbol including a CRC32 checksum of the top 10 bids and asks.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | book channel name. |
data | yes | object | The update data payload. |
type | yes | string | The update data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
asks | yes | array | The top 10 asks. Note: can be empty if no updates. |
bids | yes | array | The top 10 bids. Note: can be empty if no updates. |
checksum | yes | integer | CRC32 checksum for the top 10 bids and asks. |
symbol | yes | string | The relevant symbol. |
timestamp | yes | string | The book order update timestamp (RFC3339). |
Response Data-Asks Fields
Field | Required | Type | Description |
---|---|---|---|
price | yes | float | The ask price. |
qty | yes | float | The ask quantity |
Response Data-Bids Fields
Field | Required | Type | Description |
---|---|---|---|
price | yes | float | The bid price. |
qty | yes | float | The bid quantity |
Executions
Example Subscribe Executions Request
{
"method": "subscribe",
"params": {
"channel": "executions",
"snapshot": true,
"snapshot_trades": false,
"order_status": true,
"ratecounter": true,
"token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN"
},
"req_id": 1234567890
}
The executions
channel sends both order updates, corresponding to the
"openOrders" channel in WS API v1, and trade execution updates, corresponding
to the "ownTrades" channel in WS API v1.
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | executions channel name. |
snapshot | no | boolean | Request a snapshot containing all open orders and latest 50 trades
|
snapshot_trades | no | boolean | If true snapshot only provides trade events.
|
order_status | no | boolean | If true client will receive a message for all possible execution status transitions. If false client will only receive updates when order enters the book (new ) and when order is closed (filled , canceled or expired ).
|
ratecounter | no | boolean | Send rate-limit counter in updates.
|
token | yes | string | Session token. |
Example Subscribe Executions Response
{
"channel": "executions",
"data": [
{
"cum_cost": 0.00000000,
"exec_type": "new",
"fee_ccy_pref": "fciq",
"fee_usd_equiv": 0.00000000,
"limit_price": 59.00000,
"order_id": "ORDERX-IDXXX-XXXXX1",
"order_qty": 5.00000000,
"order_status": "new",
"order_type": "limit",
"order_userref": 1,
"side": "sell",
"stop_price": 0.00000,
"symbol": "BTC/USD",
"time_in_force": "GTC",
"timestamp": "2022-06-13T08:09:10.123456Z"
},
{
"cost": 95.45000000,
"exec_id": "EXECXX-IDXXX-XXXXX1",
"exec_type": "trade",
"fees": [
{
"asset": "USD",
"qty": 0.24817000
}
],
"liquidity_ind": "t",
"ord_type": "market",
"order_id": "ORDERX-IDXXX-XXXXX2",
"last_qty": 5.00000000,
"order_userref": 0,
"last_price": 19.09000,
"side": "buy",
"symbol": "XRP/USD",
"timestamp": "2022-06-13T08:09:10.123456Z",
"trade_id": 123456
}
],
"sequence": 1,
"type": "snapshot"
}
Example Subscribe Executions Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"channel": {
"type": "string"
},
"data": {
"items": {
"properties": {
"avg_price": {
"type": "number"
},
"cancel_reason": {
"type": "string"
},
"cost": {
"type": "number"
},
"cum_cost": {
"type": "number"
},
"cum_qty": {
"type": "number"
},
"display_qty": {
"type": "number"
},
"display_qty_remain": {
"type": "number"
},
"effective_time": {
"format": "date-time",
"type": "string"
},
"exec_id": {
"type": "string"
},
"exec_type": {
"type": "string"
},
"expire_time": {
"format": "date-time",
"type": "string"
},
"fee_ccy_pref": {
"type": "string"
},
"fee_usd_equiv": {
"type": "number"
},
"fees": {
"items": {
"properties": {
"asset": {
"type": "string"
},
"qty": {
"type": "number"
}
},
"required": [
"asset",
"qty"
],
"type": "object"
},
"type": "array"
},
"limit_price": {
"type": "number"
},
"liquidity_ind": {
"type": "string"
},
"no_mpp": {
"type": "boolean"
},
"ord_ref_id": {
"type": "number"
},
"order_id": {
"type": "string"
},
"order_qty": {
"type": "number"
},
"last_qty": {
"type": "number"
},
"order_status": {
"type": "string"
},
"order_type": {
"type": "string"
},
"order_userref": {
"type": "number"
},
"post_only": {
"type": "boolean"
},
"last_price": {
"type": "number"
},
"reduce_only": {
"type": "boolean"
},
"side": {
"type": "string"
},
"stop_price": {
"type": "number"
},
"symbol": {
"type": "string"
},
"time_in_force": {
"type": "string"
},
"timestamp": {
"format": "date-time",
"type": "string"
},
"trade_id": {
"type": "number"
},
"trigger": {
"type": "string"
},
"triggered_price": {
"type": "number"
}
},
"required": [
"exec_type",
"order_id",
"order_status",
"timestamp"
],
"type": "object"
},
"type": "array"
},
"sequence": {
"type": "number"
},
"type": {
"type": "string"
}
},
"required": [
"channel",
"data",
"sequence",
"type"
],
"title": "Subscribe executions update response JavaScript Object Notation (JSON) schema",
"type": "object"
}
Response Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | executions channel name. |
data | yes | object | The executions data payload. |
sequence | yes | integer | The running sequence number. |
type | yes | string | The executions data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
avg_price | no | float | Order's average fill price. |
cancel_reason | no | string | Cancel reason. |
cost | no | float | Cost of trade (only when exec_type:"trade" ). |
cum_cost | no | float | Order's cumulative cost. |
cum_qty | no | float | Order's cumulative executed quantity. |
display_qty | no | float | Display quantity (iceberg's only). |
display_qty_remain | no | float | Display quantity remaining (iceberg's only). |
effective_time | no | string | Timestamp (RFC3339) of order's start time. |
exec_id | no | string | Execution identifier (only when exec_type:"trade" ). |
exec_type | yes | string | Execution update type.
|
expire_time | no | string | Timestamp (RFC3339) of order's end time. |
fee_ccy_pref | no | string | Fee Preference.
|
fee_usd_equiv | no | float | Total fee (USD). |
fees | no | object | Fee's object (WIP) (only when exec_type:"trade" ). |
last_price | no | float | Filled price (only when exec_type:"trade" ). |
last_qty | no | float | Filled quantity when exec_type:"trade" . |
limit_price | no | float | Order's limit price. |
liquidity_ind | no | string | The liquidity indicator.
|
margin | no | boolean | true if the order funded on margin. |
no_mpp | no | boolean | true if the order has no market price protection. |
ord_ref_id | no | integer | Referral order transaction id that created this order. |
order_id | yes | string | The order identifier. |
order_qty | no | float | Order's quantity. |
order_status | yes | string | Order status.
|
order_type | no | string | Order type.
|
order_userref | no | integer | The user order reference. |
post_only | no | boolean | If order's flagged for post only. |
reduce_only | no | boolean | If order's flagged for reduce only. |
side | no | string | Order's side.
|
stop_price | no | float | Stop price. |
symbol | no | string | Currency pair. |
time_in_force | no | string | Time in force.
|
timestamp | yes | string | Timestamp (RFC3339) of execution event. |
trade_id | no | integer | The trade identifier. |
trigger | no | string | Reference price to trigger order.
|
triggered_price | no | float | Price which triggered the order. |
Response Data-Fees Fields
Field | Required | Type | Description |
---|---|---|---|
asset | yes | string | The fee currency. |
qty | yes | float | The fee amount. |
Heartbeat
Example Heartbeat Response
{
"channel": "heartbeat"
}
Heartbeat Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"channel": {
"const": "heartbeat",
"type": "string"
}
},
"required": [
"channel"
],
"title": "Heartbeat response JavaScript Object Notation (JSON) schema",
"type": "object"
}
Once subscribed to at least one channel, heartbeat messages are sent approximately once every second in the absence of subscription data.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | heartbeat channel name. |
Instrument
Example Subscribe Instrument Request
{
"method": "subscribe",
"params": {
"channel": "instrument",
"snapshot": true
},
"req_id": 1234567890
}
The instrument
channel provides a snapshot of all active assets and tradeable
pairs, along with the relevant trading parameters and rules (precisions,
minimums, and so on).
Note: In the future, it will also implement updates to trading parameters and status in real-time
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | instrument channel name. |
snapshot | no | boolean | Request a snapshot after subscribing.
|
Example Instrument Snapshot Response
{
"channel": "instrument",
"data": {
"assets": [
{
"borrowable": true,
"collateral_value": 1.00,
"id": "USD",
"margin_rate": 0.015000,
"precision": 4,
"precision_display": 2,
"status": "enabled"
},
{
"borrowable": true,
"collateral_value": 1.00,
"id": "EUR",
"margin_rate": 0.015000,
"precision": 4,
"precision_display": 2,
"status": "enabled"
},
{
"borrowable": true,
"collateral_value": 1.00,
"id": "BTC",
"margin_rate": 0.010000,
"precision": 10,
"precision_display": 5,
"status": "enabled"
}
],
"pairs": [
{
"base": "BTC",
"cost_min": 0.50,
"cost_precision": 5,
"has_index": true,
"margin_initial": 0.20,
"marginable": true,
"position_limit_long": 200,
"position_limit_short": 200,
"price_increment": 0.1,
"price_precision": 1,
"qty_increment": 0.00000001,
"qty_min": 0.00010000,
"qty_precision": 8,
"quote": "USD",
"status": "online",
"symbol": "BTC/USD",
},
{
"base": "EUR",
"cost_min": 0.50,
"cost_precision": 5,
"has_index": true,
"marginable": false,
"price_increment": 0.00001,
"price_precision": 5,
"qty_increment": 0.00000001,
"qty_min": 5.00000000,
"qty_precision": 8,
"quote": "USD",
"status": "online",
"symbol": "EUR/USD",
}
]
},
"type": "snapshot"
}
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | instrument channel name. |
data | yes | object | The instrument data payload. |
type | yes | string | The instrument data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
assets | yes | array | Array with objects of all the available assets. |
pairs | yes | array | Array with objects of all the available asset pairs. |
Response Data-Assets Fields
Field | Required | Type | Description |
---|---|---|---|
borrowable | yes | boolean | Flag if asset is borrowable. |
collateral_value | yes | float | Valuation as margin collateral (if applicable). |
id | yes | string | Asset identifier. |
margin_rate | no | float | Interest rate to borrow the asset. |
precision | yes | integer | Maximum precision for asset ledger, balances. |
precision_display | yes | integer | Recommended display precision. |
status | yes | string | Status of asset.
|
Response Data-Pairs Fields
Field | Required | Type | Description |
---|---|---|---|
base | yes | string | Asset identifier of the base currency. |
cost_min | yes | float | Minimum cost (price * qty) for new orders. |
cost_precision | yes | integer | Maximum precision used for cost prices. |
has_index | yes | boolean | Whether the pair has an index available for example stop-loss triggers. |
margin_initial | no | float | Initial margin requirement (in percent, if marginable). |
marginable | yes | boolean | Whether the pair can be traded on margin. |
position_limit_long | no | integer | Limit for long positions (marginable pairs). |
position_limit_short | no | integer | Limit for short positions (marginable pairs). |
price_increment | yes | float | Minimum price increment for new orders. |
price_precision | yes | integer | Maximum precision used for order prices. |
qty_increment | yes | float | Minimum quantity increment for new orders. |
qty_min | yes | float | Minimum quantity (in base currency) for new orders. |
qty_precision | yes | integer | Maximum precision used for order quantities. |
quote | yes | string | Asset identifier of the quote currency. |
status | yes | string | Status of pair.
|
symbol | yes | string | Asset pair identifier. |
tick_size | no | float | DEPRECATED: use price_increment . |
Open, High, Low, and Close (OHLC)
Example Open, High, Low, and Close (OHLC) Request
{
"method": "subscribe",
"params": {
"channel": "ohlc",
"symbol": [
"BTC/USD"
]
}
}
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | ohlc channel name. |
symbol | yes | array | Symbol(s) to subscribe to. |
snapshot | no | boolean | Request a snapshot after subscribing.
|
Example Open, High, Low, and Close (OHLC) Response
{
"channel": "ohlc",
"timestamp": "2022-06-13T08:09:10.123456Z",
"data": [
{
"close": 30001.4,
"high": 3000.9,
"low": 3000.1,
"open": 3000.3,
"symbol": "BTC/USD",
"interval_begin": "2022-06-12T08:09:10.123456Z",
"trades": 1,
"volume": 0.0001,
"vwap": 3000.3,
"interval": 5,
"timestamp": "2022-06-13T08:09:10.123456Z",
}
],
"type": "snapshot"
}
Open, High, Low, and Close (Candle) feed for a given currency pair.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | ohlc channel name. |
data | yes | object | The ohlc data payload. |
type | yes | string | The ohlc data payload type. |
timestamp | yes | string | Timestamp of the OHLC response |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
close | yes | float | The close (last traded) price. |
high | yes | float | 24-hour highest trade price. |
low | yes | float | 24-hour lowest trade price. |
open | yes | float | The open (first traded) price. |
symbol | yes | string | Currency pair. |
interval_begin | yes | string | The timestamp for the first interval |
timestamp (DEPRECATED) | yes | string | The book order update timestamp (RFC3339). |
trades | yes | integer | Number of trades within interval. |
volume | yes | float | 24-hour traded volume (in base currency terms). |
vwap | yes | float | 24-hour volume-weight average price. |
interval | yes | float | The interval used for each OHLC grouping |
Ticker
Example Subscribe Ticker Request
{
"method": "subscribe",
"params": {
"channel": "ticker",
"snapshot": true,
"symbol": [
"BTC/USD"
]
},
"req_id": 1234567890
}
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | ticker channel name. |
symbol | yes | array | Symbol(s) to subscribe to. |
snapshot | no | boolean | Request a snapshot after subscribing.
|
Snapshot Response
Example Ticker Snapshot Response
{
"channel": "ticker",
"data": [
{
"ask": 7000.3,
"ask_qty": 0.01,
"bid": 6000.0,
"bid_qty": 0.01,
"change": -100.0,
"change_pct": -1.54,
"high": 6500.9,
"last": 6400.6,
"low": 6400.1,
"symbol": "BTC/EUR",
"volume": 0.02,
"vwap": 6450.2
}
],
"type": "snapshot"
}
ticker
snapshots reflect the current state of the market.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | ticker channel name. |
data | yes | object | The ticker data payload. |
type | yes | string | The ticker data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
ask | yes | float | Best (top-of-book) ask. |
ask_qty | yes | float | Best (top-of-book) ask quantity. |
bid | yes | float | Best (top-of-book) bid. |
bid_qty | yes | float | Best (top-of-book) bid quantity. |
change | yes | float | 24-hour price change (in quote currency terms). |
change_pct | yes | float | 24-hour price change (in percentage points). |
high | yes | float | 24-hour highest trade price. |
last | yes | float | Last traded price. |
low | yes | float | 24-hour lowest trade price. |
symbol | yes | string | Currency pair. |
volume | yes | float | 24-hour traded volume (in base currency terms). |
vwap | yes | float | 24-hour volume-weight average price. |
Update Response
Example Ticker Update Response
{
"channel": "ticker",
"data": [
{
"ask": 7000.3,
"ask_qty": 0.01,
"bid": 6000.0,
"bid_qty": 0.01,
"change": -100.0,
"change_pct": -1.54,
"high": 6500.9,
"last": 6400.6,
"low": 6400.1,
"symbol": "BTC/EUR",
"volume": 0.02,
"vwap": 6450.2
}
],
"type": "update"
}
ticker
pushes updates whenever there is a trade or there is a change (price
or quantity) at the top-of-book.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | ticker channel name. |
data | yes | object | The ticker data payload. |
type | yes | string | The ticker data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
ask | yes | float | Best (top-of-book) ask. |
ask_qty | yes | float | Best (top-of-book) ask quantity. |
bid | yes | float | Best (top-of-book) bid. |
bid_qty | yes | float | Best (top-of-book) bid quantity. |
change | yes | float | 24-hour price change (in quote currency terms). |
change_pct | yes | float | 24-hour price change (in percentage points). |
high | yes | float | 24-hour highest trade price. |
last | yes | float | Last traded price. |
low | yes | float | 24-hour lowest trade price. |
symbol | yes | string | Currency pair. |
volume | yes | float | 24-hour traded volume (in base currency terms). |
vwap | yes | float | 24-hour volume-weight average price. |
Trade
Example Subscribe Trade Request
{
"method": "subscribe",
"params": {
"channel": "trade",
"snapshot": true,
"symbol": [
"BTC/USD"
]
},
"req_id": 1234567890
}
Request Fields
Field | Required | Type | Description |
---|---|---|---|
method | yes | string | subscribe method name. |
params | yes | object | Parameters for the given subscribe method. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
Request Params Fields
param | Required | Type | Description |
---|---|---|---|
channel | yes | string | trade channel name. |
symbol | yes | array | Symbol(s) to subscribe to. |
snapshot | no | boolean | Request a snapshot after subscribing.
|
Example Trade Update Response
{
"channel": "trade",
"data": [
{
"ord_type": "market",
"price": 4136.4,
"qty": 0.23374249,
"side": "sell",
"symbol": "BTC/USD",
"timestamp": "2022-06-13T08:09:10.123456Z",
"trade_id": 0
},
{
"ord_type": "market",
"price": 4136.4,
"qty": 0.00060615,
"side": "sell",
"symbol": "BTC/USD",
"timestamp": "2022-06-13T08:09:20.123456Z",
"trade_id": 0
},
{
"ord_type": "market",
"price": 4136.4,
"qty": 0.00000136,
"side": "sell",
"symbol": "BTC/USD",
"timestamp": "2022-06-13T08:09:30.123456Z",
"trade_id": 0
}
],
"type": "update"
}
trade
pushes trades in real-time.
Multiple trades may be batched in a single message but that does not
necessarily mean that every trade in a single message resulted from a single
taker order.
- Snapshots reflect the most recent 100 trades.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | trade channel name. |
data | yes | object | The trade data payload. |
type | yes | string | The trade data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
ord_type | yes | string | Taker order type. |
price | yes | float | Execution price. |
qty | yes | float | Execution quantity. |
side | yes | string | Taker order direction. |
symbol | yes | string | The relevant symbol. |
timestamp | yes | string | The book order update timestamp (RFC3339). |
trade_id | yes | integer | Unique trade identifier for this symbol. |
Status
Example Status Update Response
{
"channel": "status",
"data": [
{
"api_version": "v2",
"connection_id": 17182357368067543000,
"system": "online",
"version": "2.0.0"
}
],
"type": "update"
}
Example Status Update Response JSON Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"channel": {
"const": "status",
"type": "string"
},
"data": {
"items": {
"properties": {
"api_version": {
"type": "string"
},
"connection_id": {
"type": "number"
},
"system": {
"enum": [
"cancel_only",
"maintenance",
"online",
"post_only"
],
"type": "string"
},
"version": {
"type": "string"
}
},
"required": [
"api_version",
"connection_id",
"system",
"version"
],
"type": "object"
},
"type": "array"
},
"type": {
"type": "string"
}
},
"required": [
"channel",
"data",
"type"
],
"title": "Status update response JavaScript Object Notation (JSON) schema",
"type": "object"
}
Sent upon connection and upon change to our system/trading status.
Response Fields
Field | Required | Type | Description |
---|---|---|---|
channel | yes | string | status channel name. |
data | yes | object | The status data payload. |
type | yes | string | The status data payload type. |
Response Data Fields
Field | Required | Type | Description |
---|---|---|---|
api_version | yes | string | The version of the application programming interface. |
connection_id | yes | integer | The connection identifier. |
system | yes | string | The system/trading status.
|
version | yes | string | The active WebSockets application programming interface (API) version. |
Maintaining the book
All book updates in a message should be processed before the book is considered updated and the checksum confirmed. Update messages may contain updates to either the bids and/or asks.
An update with "qty": 0
indicates that price level should be removed from
your book.
Additionally, after each update, the book should be truncated to your
subscribed depth as you won't receive "qty": 0
for price levels that fall out
of scope.
In other words, if you are subscribed with "depth": 10
and an insert into the
middle of the book results in you having 11 bids, you must remove the 11th
worst bid.
Checksum logic is the same as in v1, but prices and volumes are now sent as
floats and so their precisions will need to be determined from the instrument
channel in order to compute the checksum (specifically, fields
price_precision
and qty_precision
).
Detailed instructions can be found in the
Calculate Book Checksum section.
Calculate Book Checksum
Example BTC/USD Book
ask price: 0.3501, quantity: 0.01
ask price: 0.3502, quantity: 0.02
ask price: 0.3503, quantity: 0.03
ask price: 0.3504, quantity: 0.04
ask price: 0.3505, quantity: 0.05
ask price: 0.3506, quantity: 0.06
ask price: 0.3507, quantity: 0.07
ask price: 0.3508, quantity: 0.08
ask price: 0.3509, quantity: 0.09
ask price: 0.3510, quantity: 0.10
bid price: 0.3410, quantity: 0.10
bid price: 0.3409, quantity: 0.09
bid price: 0.3408, quantity: 0.08
bid price: 0.3407, quantity: 0.07
bid price: 0.3406, quantity: 0.06
bid price: 0.3405, quantity: 0.05
bid price: 0.3404, quantity: 0.04
bid price: 0.3403, quantity: 0.03
bid price: 0.3402, quantity: 0.02
bid price: 0.3401, quantity: 0.01
Example BTC/USD Price and Quantity Precision
price_precision: 6
qty_precision : 8
The checksum is a CRC32 value based on the top 10 bids and 10 asks. It can be used to verify that your data is correct and up to date by calculating the checksum independently and comparing it against the value provided.
The checksum is computed by concatenating the top 10 bids and asks in the current book in a particular format and then taking the CRC32 checksum of that string.
Note: The following results are based in on the Example BTC/USD Book
and
Example BTC/USD Price and Quantity Precision
.
- Sort the asks by price from low to high:
0.3501, 0.3502, ..., 0.3510
- For each of the top ten asks:
- Convert the price-quantity pair to a string by:
- Change price using the
price_precision
(6
) to a string:0.3501 -> "0.350100"
- Remove the decimal point (
.
) from the price:"0.350100" -> "0350100"
- Remove all leading zero (
0
) characters from the price:"0350100" -> "350100"
- Change quantity using the
qty_precision
(8
) to a string0.01 -> "0.01000000"
- Remove the decimal point (
.
) from the quantity:"0.01000000" -> "001000000"
- Remove all leading zero (
0
) characters from the quantity:"001000000" -> "1000000"
- Combine converted price (
"350100"
) and quantity ("1000000"
):"3501001000000"
- Change price using the
- Combine the converted top 10 asks price-quantity strings:
"35010010000003502002000000350300300000035040040000003505005000000350600600000035070070000003508008000000350900900000035100010000000"
- Convert the price-quantity pair to a string by:
- Sort the bids by price from high to low:
0.3410, 0.3409, ..., 0.3401
- For each of the top ten bids:
- Convert the price-quantity pair to a string by:
- Change price using the
price_precision
(6
) to a string:0.3410 -> "0.341000"
- Remove the decimal point (
.
) from the price:"0.341000" -> "0341000"
- Remove all leading zero (
0
) characters from the price:"0341000" -> "341000"
- Change quantity using the
qty_precision
(8
) to a string0.10 -> "0.10000000"
- Remove the decimal point (
.
) from the quantity:"0.10000000" -> "010000000"
- Remove all leading zero (
0
) characters from the quantity:"010000000" -> "10000000"
- Combine converted price (
"341000"
) and quantity ("10000000"
):"34100010000000"
- Change price using the
- Combine the converted top 10 bids price-quantity strings:
"34100010000000340900900000034080080000003407007000000340600600000034050050000003404004000000340300300000034020020000003401001000000"
- Convert the price-quantity pair to a string by:
- Combine the asks and bids results:
"3501001000000350200200000035030030000003504004000000350500500000035060060000003507007000000350800800000035090090000003510001000000034100010000000340900900000034080080000003407007000000340600600000034050050000003404004000000340300300000034020020000003401001000000"
- Use the combined asks-and-bids value as input to a CRC32 checksum function
- Feed the concatenated string to a CRC32 checksum function:
187053740
Note: If needed, cast the result (comprising 32 bits) as an unsigned 32-bit integer.
This value can now be compared to the checksum received to ensure your local book is accurate.
Rate Limits
Matching Engine Rate Limits
Limits
Separate limits apply to the number of orders clients may have open in each pair at a time, and the speed with which they may add and cancel orders in each pair. These limits vary by the account verification tier:
Tier | Max. Orders Count | Max. Rate-limit Count | Rate-limit Count Delay |
---|---|---|---|
Starter | 60 | 60 | - 1/s |
Intermediate | 80 | 125 | - 2.34/s |
Pro | 225 | 180 | - 3.75/s |
Penalties
The speed is controlled by a rate-limit counter for each (client, pair) which starts at zero, is incremented when penalties are applied, and decremented according to the decay rates above.
A penalty is added to the rate-limit counter for each new order placed
(add_order
and batch_add
) or cancelled (batch_cancel
, cancel_all
,
cancel_all_orders_after
, and cancel_order
) on the pair.
The cancellation penalty varies according to the lifetime of the order.
Add Actions
Action / Order Lifetime | |
---|---|
add_order |
+ 1 |
batch_add 1 |
+ (n/2) |
- 1
n
represents the number of orders in a batch.
Cancel And Edit Actions
Action / Order Lifetime | < 5 s | < 10 s | < 15 s | < 45 s | < 90 s | < 300 s | > 300 s |
---|---|---|---|---|---|---|---|
batch_cancel 1 |
+ 8 | + 6 | + 5 | + 4 | + 2 | + 1 | 0 |
edit_order |
+ 6 | + 5 | + 4 | + 2 | + 1 | 0 | 0 |
cancel_all |
+ 8 | + 6 | + 5 | + 4 | + 2 | + 1 | 0 |
cancel_all_orders_after |
+ 8 | + 6 | + 5 | + 4 | + 2 | + 1 | 0 |
cancel_order |
+ 8 | + 6 | + 5 | + 4 | + 2 | + 1 | 0 |
- 1
- Rate limits penalty for
batch_batch
will be cumulative sum of individual orders' penalty, accumulated up to the maximum rate-limit count. In case, the cumulative penalty in the batch exceeds maximum rate-limit count, cancel requests in batch are still accepted.
Note: A client's exact rate-limit counter values can be monitored via the Websockets executions channel.
Errors
"EOrder:Orders limit exceeded"
- If the number of open orders in a given pair is exceeded.
"EOrder:Rate limit exceeded""
- If the user's max rate count for a given pair is exceeded.
Additional Information
Additional information can be found on our support center.
Errors
Example Error Response
{
"error": "Already subscribed",
"method": "subscribe",
"success": false,
"time_in": "2021-06-28T07:22:47.907236Z",
"time_out": "2021-06-28T07:22:48.907236Z"
}
Example Example Error Response
{
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"error": {
"type": "string"
},
"method": {
"type": "string"
},
"req_id": {
"maximum": 18446744073709551615,
"minimum": 0,
"type": "integer"
},
"success": {
"const": false,
"type": "boolean"
},
"time_in": {
"format": "date-time",
"type": "string"
},
"time_out": {
"format": "date-time",
"type": "string"
}
},
"required": [
"error",
"method",
"success",
"time_in",
"time_out"
],
"title": "Error response JavaScript Object Notation (JSON) schema",
"type": "object"
}
Error responses are request specific and contain at least the following fields:
Response Fields
Field | Required | Type | Description |
---|---|---|---|
error | yes | string | The error description. |
method | yes | object | The error causing request method name. |
req_id | no | integer | Client originated request identifier sent as acknowledgment in the response message. |
success | yes | boolean | The status of the error response. Note: always false . |
time_in | yes | string | RFC3339 timestamp when the Websockets server received the request. |
time_out | yes | string | RFC3339 timestamp when the Websockets server sent the response. |
Public Data Errors
The following error messages can be thrown as part of the Subscribe request:
- Already subscribed
- Currency pair not in ISO 4217-A3 format
- Malformed request
- Pair field must be an array
- Pair field unsupported for this subscription type
- Pair(s) not found
- Subscription book depth must be an integer
- Subscription depth not supported
- Subscription field must be an object
- Subscription name invalid
- Subscription object unsupported field
- Subscription ohlc interval must be an integer
- Subscription ohlc interval not supported
- Subscription ohlc requires interval
Private Data Errors
The following error messages may be thrown for private data requests. Segments in brackets ([]) indicate additional information that may or not be present in the error message.
- EAccount:Invalid permissions
- EAuth:Account temporary disabled
- EAuth:Account unconfirmed
- EAuth:Rate limit exceeded
- EAuth:Too many requests
- EDatabase: Internal error (to be deprecated)
- EGeneral:Internal error[:<code>]
- EGeneral:Invalid arguments
- EOrder:Cannot open opposing position
- EOrder:Cannot open position
- EOrder:Insufficient funds (insufficient user funds)
- EOrder:Insufficient margin (exchange does not have sufficient funds to allow margin trading)
- EOrder:Invalid price
- EOrder:Margin allowance exceeded
- EOrder:Margin level too low
- EOrder:Margin position size exceeded (client would exceed the maximum position size for this pair)
- EOrder:Order minimum not met (volume too low)
- EOrder:Orders limit exceeded
- EOrder:Positions limit exceeded
- EOrder:Rate limit exceeded
- EOrder:Reduce only:Non-PC
- EOrder:Scheduled orders limit exceeded
- EOrder:Unknown position
- EService:Deadline elapsed
- EService:Market in cancel_only mode
- EService:Market in limit_only mode
- EService:Market in post_only mode
- EService:Unavailable
- ETrade:Invalid request
FAQs
The Frequently Asked Questions (FAQs) section tries to answer the most common questions that users can encounter.
Connection times out
The server closes any open websocket connection within approximately one (1) minute of inactivity.
Any, for example a ping, request can be used to keep the connection alive.
EOrder:Reduce only:Non-PC
The "EOrder:Reduce only:Non-PC" error response indicated to a problem with the Permitted Client (PC).
For more information please see the Kraken support article Margin trading and Permitted Client self-certification for Ontario, Canada clients.
XBT/USD pair is missing
If you are getting the error "Currency pair not supported XBT/USD" that is
because we are using BTC
instead of XBT
for bitcoin in v2.
Please use the instrument channel to fetch the list of pairs which can be subscribed to via WebSockets API.
API Clients
Below is sample code that can be referenced when writing your own application programming interface (API) client. Please keep in mind that neither Payward nor the third party authors are responsible for losses due to bugs or improper use of the APIs.
Payward has performed an initial review of the safety of the third party code before listing them but cannot vouch for any changes added since then. If you have concerns, please contact support.
Go
Kraken WebSocket order book listener --- https://github.com/jurijbajzelj/kraken_ws_orderbook
Python
Kraken WebSockets Client in Python --- https://github.com/krakenfx/kraken-wsclient-py
About
Version
The content of this documentation relates to the WebSockets application programming interface (API) version 2.0.0 release.
Note: The Status channel contains an Example Status Update Response which provides the used version.
Change Log
- 2023-03-22
- edit_order request:
limit_price
field added,price
field deprecated. - executions channel:
margin
field added to order details in snapshots and updates. - instrument channel:
price_precision
is now populated from the instrument service.tick_size
has been deprecated. - 2023-03-15
- Added
last_qty
andlast_price
fields to trade events in Executions channel. - Added
interval
andinterval_begin
fields to OHLC channel.timestamp
field is deprecated. - Corrected default
time_in_force
settings. - 2022-11-28
- Corrected several details in the channel's Executions, Heartbeat, and Instrument sections.
- 2022-11-23
- Corrected the Websockets executions channel hypertext reference in the note regarding how to monitor the exact rate-limit in the Rate Limits's Matching Engine Rate Limits section.
- 2022-11-22
-
Removed the document's (internal) version from the About section
to align it with the production release version (v2.0.0) of the
WebSockets application programming interface (API).
Replacing change log item 2022-07-29 action. - Corrected the response data fields in the channel's Status section.
- Reformatted the style of all items in the Change Log section.
- Moved Change Log section to become sub-section in About section
-
Corrected
stop_price
's type tofloat
in the private message's Add Order section. -
Corrected the types of
cash_order_qty
,limit_price
, andstop_price
tofloat
in the private message's Batch Add section. -
Corrected the types of
price
, andstop_price
tofloat
in theprivate message's Edit Order section. - 2022-11-21
- Corrected
order_qty
's type tofloat
in the private message's Edit Order section. - 2022-11-18
-
Added
Connection times out
entry to the Frequently Asked Questions (FAQs) section. - Corrected response data fields in the channel's Open, High, Low, and Close (OHLC) section.
- 2022-11-16
- Added
EOrder:Reduce only:Non-PC
entry to the Errors and Frequently Asked Questions (FAQs) sections. - 2022-11-07
- Added Frequently Asked Questions (FAQs) section.
- 2022-10-21
- Corrected
stp_type
's accepted values in all examples. - 2022-10-10
- Removed misleading entry from change log item 2021-10-06.
- 2022-10-04
- Corrected channel's Executions parameter to refer to
order_qty
and addeddisplay_qty
to channel's Batch Add section. - 2022-09-02
- Corrected
req_id
's value maximum value and updated eachreq_id
's value in all examples. - 2022-08-12
- Enhanced description of
conditional
field in private messages's Add Order section. - 2022-08-05
- Style changes in the Change Log section.
- 2022-08-02
- Changed Introduction section to refer to the channel's
Instrument
section to fetch the list of pairs. - 2022-07-29
- Added About section to version the documentation.
- 2022-07-28
- Finalized documentation structure for release.
- 2022-07-07
- Clean-up of documentation and added JavaScript Object Notation (JSON) schemas.
- 2022-01-10
- Minor clean-up and clarification.
- 2021-10-06
trade_id
now active ontrade
channel.- 2021-06-27
- Added details for
instrument
andbook
. - 2021-05-11
- Initial docs for
ticker
andtrade
.