Kraken WebSockets Public API Version 0.1.1
Overview
WebSockets Public API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The message types presented below do not require authentication.
General Considerations
- All messages sent and received via WebSockets are encoded in JSON format
- All floating point fields (including timestamps) are quoted to preserve precision.
- Format of each tradeable pair is A/B, where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized.
- Timestamps should not be considered unique and not be considered as aliases for transaction ids. Also, the granularity of timestamps is not representative of transaction rates.
- Connection details for sandbox environment:
URL |
Scheme |
Description |
ws-sandbox.kraken.com |
wss |
Once the socket is open you can subscribe to a channel by sending a subscribe request message.
|
- Connection details for production environment:
URL |
Scheme |
Description |
ws.kraken.com |
wss |
Once the socket is open you can subscribe to a channel by sending a subscribe request message.
|
Supported Pairs
ADA/CAD, ADA/ETH, ADA/EUR, ADA/USD, ADA/XBT, BCH/EUR, BCH/USD, BCH/XBT, BSV/EUR, BSV/USD, BSV/XBT, DASH/EUR, DASH/USD, DASH/XBT, EOS/ETH, EOS/EUR, EOS/USD, EOS/XBT, GNO/ETH, GNO/EUR, GNO/USD, GNO/XBT, QTUM/CAD, QTUM/ETH, QTUM/EUR, QTUM/USD, QTUM/XBT, USDT/USD, ETC/ETH, ETC/XBT, ETC/EUR, ETC/USD, ETH/XBT, ETH/CAD, ETH/EUR, ETH/GBP, ETH/JPY, ETH/USD, LTC/XBT, LTC/EUR, LTC/USD, MLN/ETH, MLN/XBT, REP/ETH, REP/XBT, REP/EUR, REP/USD, STR/EUR, STR/USD, XBT/CAD, XBT/EUR, XBT/GBP, XBT/JPY, XBT/USD, BTC/CAD, BTC/EUR, BTC/GBP, BTC/JPY, BTC/USD, XDG/XBT, XLM/XBT, DOGE/XBT, STR/XBT, XLM/EUR, XLM/USD, XMR/XBT, XMR/EUR, XMR/USD, XRP/XBT, XRP/CAD, XRP/EUR, XRP/JPY, XRP/USD, ZEC/XBT, ZEC/EUR, ZEC/JPY, ZEC/USD, XTZ/CAD, XTZ/ETH, XTZ/EUR, XTZ/USD, XTZ/XBT
Aliases: Few pairs have supported aliases. When a subscribe request is made for an alias pair, then the original pair is subscribed and is mentioned in the response payload. For example, XBT/USD is mentioned in response payload when a subscription is made for BTC/USD.
Asset Name |
Symbol |
Alias |
Bitcoin |
XBT |
BTC |
Doge |
XDG |
DOGE |
Stellar |
XLM |
STR |
Error Types
Following error messages are thrown as part of subscriptionStatus message.
- Subscription field must be an object
- Subscription object unsupported field
- Subscription name invalid
- Subscription book depth must be an integer
- Subscription depth not supported
- Subscription ohlc interval must be an integer
- Subscription ohlc interval not supported
- Subscription ohlc requires interval
- Currency pair not in ISO 4217-A3 format
- Pair field must be an array
- Pair(s) not found
- Malformed request
Example API Clients
Below are sample API client code libraries that can be used when writing your own API client. Please keep in mind that 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.
Request: Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in WebSockets standard which is server initiated
Payload
Name |
Title |
Type |
Default |
Description |
event |
|
string
|
ping |
ping |
reqid |
|
integer
|
|
Optional, client originated ID reflected in response message. |
Example of payload
{
"event": "ping",
"reqid": 42
}
Response: Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in WebSockets standard which is sent by client in response to a ping
Payload
Name |
Title |
Type |
Default |
Description |
event |
|
string
|
pong |
pong |
reqid |
|
integer
|
|
Optional, matching client originated request ID. |
Example of payload
{
"event": "pong",
"reqid": 42
}
Publication: Server heartbeat sent if no subscription traffic within 1 second (approximately)
Payload
Name |
Title |
Type |
Default |
Description |
event |
|
string
|
heartbeat |
heartbeat |
Example of payload
{
"event": "heartbeat"
}
Publication: Status sent on connection or system status changes.
Payload
Name |
Title |
Type |
Default |
Description |
connectionID |
|
integer
|
connectionID |
Connection ID |
event |
|
string
|
systemStatus |
systemStatus |
status |
|
string
|
online |
online|maintenance|(custom status) |
version |
|
string
|
1.0.0 |
|
Example of payload
{
"connectionID":8628615390848610222,
"event": "systemStatus",
"status": "online",
"version": "1.0.0"
}
Request: Subscribe to a topic on a single or multiple currency pairs.
Payload
Name |
Title |
Type |
Default |
Description |
event |
|
string
|
subscribe |
subscribe |
reqid |
|
integer
|
|
Optional, client originated ID reflected in response message. |
pair |
pair |
array
|
|
Array of currency pairs (pair1,pair2,pair3).
|
subscription |
|
object
|
|
|
name |
name |
string
|
|
ticker|ohlc|trade|book|spread|*, * for all (ohlc interval value is 1 if all channels subscribed) |
interval |
interval |
integer
|
|
Optional - Time interval associated with ohlc subscription in minutes. Default 1. Valid Interval values: 1|5|15|30|60|240|1440|10080|21600 |
depth |
interval |
integer
|
10 |
Optional - depth associated with book subscription in number of levels each side, default 10. Valid Options are: 10, 25, 100, 500, 1000 |
Examples of payload
{
"event": "subscribe",
"pair": [
"XBT/USD","XBT/EUR"
],
"subscription": {
"name": "ticker"
}
}
{
"event": "subscribe",
"pair": [
"XBT/EUR"
],
"subscription": {
"name": "ohlc",
"interval": 5
}
}
Request: Unsubscribe from single subscription, can specify multiple currency pairs.
Payload
Name |
Title |
Type |
Default |
Description |
Message Payload |
|
oneOf
|
|
|
(Anonymous) |
|
object
|
|
|
event |
|
string
|
unsubscribe |
unsubscribe |
reqid |
|
integer
|
|
Optional, client originated ID reflected in response message. |
pair |
pair |
array
|
|
Array of currency pairs.
Format of each pair is "A/B", where A and B are ISO 4217-A3 for standardized assets
and popular unique symbol if not standardized.
|
subscription |
|
object
|
|
|
name |
name |
string
|
|
ticker|ohlc|trade|book|spread|*, * for all |
interval |
interval |
integer
|
|
Optional - Time interval associated with ohlc subscription in minutes; interval values: 1|5|15|30|60|240|1440|10080|21600 |
depth |
interval |
integer
|
10 |
Optional - depth associated with book subscription in number of levels each side, default 10. Valid options are: 10, 25, 100, 500, 1000 |
(Anonymous) |
|
object
|
|
|
event |
|
string
|
unsubscribe |
unsubscribe |
reqid |
|
integer
|
|
Optional, client originated ID reflected in response message. |
channelID |
channelID |
integer
|
|
ChannelID associated with pair subscription |
Examples of payload
{
"event": "unsubscribe",
"pair": [
"XBT/EUR","XBT/USD"
],
"subscription": {
"name": "ticker"
}
}
{
"event": "unsubscribe",
"channelID": 10001
}
Response & Publication: Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.
Payload
Name |
Title |
Type |
Default |
Description |
channelID |
|
integer
|
channelID |
ChannelID on successful subscription |
event |
|
string
|
subscriptionStatus |
subscriptionStatus |
status |
status |
string
|
|
Status of subscription: subscribed|unsubscribed|error |
pair |
pair |
string
|
|
Currency pair |
reqid |
|
integer
|
|
Optional, matching client originated request ID. |
subscription |
|
object
|
|
|
name |
name |
string
|
|
ticker|ohlc|trade|book|spread|*, * for all |
interval |
interval |
integer
|
|
Optional - Time interval associated with ohlc subscription in minutes, interval values: 1|5|15|30|60|240|1440|10080|21600 |
depth |
interval |
integer
|
10 |
Optional - depth associated with book subscription in number of levels each side, default 10. Valid options are: 10, 25, 100, 500, 1000 |
OneOf |
|
oneOf
|
|
|
errorMessage |
errorMessage |
string
|
|
Error message |
Examples of payload
{
"channelID": 10001,
"event": "subscriptionStatus",
"status": "subscribed",
"pair": "XBT/EUR",
"subscription": {
"name": "ticker"
}
}
{
"channelID": 10001,
"event": "subscriptionStatus",
"status": "unsubscribed",
"pair": "XBT/EUR",
"reqID": 42,
"subscription": {
"name": "ohlc",
"interval": 5
}
}
Example payload for error message 'Subscription depth not supported'
{
"errorMessage": "Subscription depth not supported",
"event": "subscriptionStatus",
"pair": "XBT/USD",
"status": "error",
"subscription": {
"name": "book",
"depth":42
}
}
Publication: Ticker information includes best ask and best bid prices, 24hr volume, last trade price, volume weighted average price, etc for a given currency pair. A ticker message is published every time a trade or a group of trade happens.
Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-ticker subscription |
(Anonymous) |
|
object
|
|
|
a |
ask |
array
|
|
Ask |
price |
price |
float
|
|
Best Ask Price |
wholeLotVolume |
wholeLotVolume |
integer
|
|
Whole lot volume |
lotVolume |
lotVolume |
float
|
|
Lot volume |
b |
bid |
array
|
|
Bid |
price |
price |
float
|
|
Best Bid Price |
wholeLotVolume |
wholeLotVolume |
integer
|
|
Whole lot volume |
lotVolume |
lotVolume |
float
|
|
Lot volume |
c |
close |
array
|
|
Close |
price |
price |
float
|
|
Price |
lotVolume |
lotVolume |
float
|
|
Lot volume |
v |
volume |
array
|
|
Volume |
today |
today |
float
|
|
Value today |
last24Hours |
last24Hours |
float
|
|
Volume over the past 24 hours |
p |
vwap |
array
|
|
Volume weighted average price |
today |
today |
float
|
|
Value today |
last24Hours |
last24Hours |
float
|
|
Value over the past 24 hours |
t |
num trades |
array
|
|
Number of trades |
today |
today |
integer
|
|
Value today |
last24Hours |
last24Hours |
integer
|
|
Value over the past 24 hours |
l |
low |
array
|
|
Low price |
today |
today |
float
|
|
Value today |
last24Hours |
last24Hours |
float
|
|
Value over the past 24 hours |
h |
high |
array
|
|
High price |
today |
today |
float
|
|
Value today |
last24Hours |
last24Hours |
float
|
|
Value over the past 24 hours |
o |
open |
array
|
|
Open Price |
today |
today |
float
|
|
Value today |
last24Hours |
last24Hours |
float
|
|
Value over the past 24 hours |
Example of payload
[
0,
{
"a": [
"5525.40000",
1,
"1.000"
],
"b": [
"5525.10000",
1,
"1.000"
],
"c": [
"5525.10000",
"0.00398963"
],
"v": [
"2634.11501494",
"3591.17907851"
],
"p": [
"5631.44067",
"5653.78939"
],
"t": [
11493,
16267
],
"l": [
"5505.00000",
"5505.00000"
],
"h": [
"5783.00000",
"5783.00000"
],
"o": [
"5760.70000",
"5763.40000"
]
}
]
Publication: Open High Low Close (Candle) feed for a currency pair and interval period.
Description: When subscribed for OHLC, a snapshot of the last valid candle (irrespective of the endtime) will be sent, followed by updates to the running candle.
For example, if a subscription is made to 1 min candle and there have been no trades for 5 mins, a snapshot of the last 1 min candle from 5 mins ago will be published. The endtime can be used to determine that it is an old candle.
Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-ohlc subscription |
Array |
|
array
|
|
|
time |
time |
float
|
|
Time, seconds since epoch |
endtime |
time |
float
|
|
End Timestamp of the interval |
open |
open |
float
|
|
First traded price of the interval |
high |
high |
float
|
|
Highest traded price of the interval |
low |
low |
float
|
|
Lowest traded price of the interval |
close |
close |
float
|
|
Last traded price of the interval |
vwap |
vwap |
float
|
|
Volume weighted average price of the interval |
volume |
volume |
float
|
|
Accumulated volume of the interval |
count |
count |
integer
|
|
Number of trades in the interval |
Example of payload
[
42,
[
"1542057314.748456",
"1542057360.435743",
"3586.70000",
"3586.70000",
"3586.60000",
"3586.60000",
"3586.68894",
"0.03373000",
2
]
]
Publication: Trade feed for a currency pair.
Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-trade subscription |
Array |
|
array
|
|
Array of trades |
Array |
|
array
|
|
Array of trade values |
price |
price |
float
|
|
Price |
volume |
volume |
float
|
|
Volume |
time |
time |
float
|
|
Time, seconds since epoch |
side |
buy/sell |
string
|
|
Triggering order side (buy/sell), values: b|s |
orderType |
market/limit |
string
|
|
Triggering order type (market/limit), values: m|l |
misc |
miscellaneous |
string
|
|
Miscellaneous |
Example of payload
[
0,
[
[
"5541.20000",
"0.15850568",
"1534614057.321597",
"s",
"l",
""
],
[
"6060.00000",
"0.02455000",
"1534614057.324998",
"b",
"l",
""
]
]
]
Publication: Spread feed to show best bid and ask price for a currency pair
Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-spreads subscription |
Array |
|
array
|
|
|
bid |
bid |
float
|
|
Bid price |
ask |
ask |
float
|
|
Ask price |
timestamp |
timestamp |
float
|
|
Time, seconds since epoch |
Example of payload
[
0,
[
"5698.40000",
"5700.00000",
"1542057299.545897"
]
]
Publication: Order book levels. On subscription, a snapshot will be published at the specified depth, following the snapshot, level updates will be published.
Snapshot Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-order book levels subscription |
(Anonymous) |
|
object
|
|
|
as |
ask |
array
|
|
Array of price levels, ascending from best ask |
Array |
|
array
|
|
Anonymous array of level values |
price |
price |
float
|
|
Price level |
volume |
volume |
float
|
|
Price level volume. |
timestamp |
timestamp |
float
|
|
Price level last updated, seconds since epoch |
bs |
bid |
array
|
|
Array of price levels, descending from best bid |
Array |
|
array
|
|
Anonymous array of level values |
price |
price |
float
|
|
Price level |
volume |
volume |
float
|
|
Price level volume |
timestamp |
timestamp |
float
|
|
Price level last updated, seconds since epoch |
Example of snapshot payload
[
0,
{
"as": [
[
"5541.30000",
"2.50700000",
"1534614248.123678"
],
[
"5541.80000",
"0.33000000",
"1534614098.345543"
],
[
"5542.70000",
"0.64700000",
"1534614244.654432"
]
],
"bs": [
[
"5541.20000",
"1.52900000",
"1534614248.765567"
],
[
"5539.90000",
"0.30000000",
"1534614241.769870"
],
[
"5539.50000",
"5.00000000",
"1534613831.243486"
]
]
}
]
Update Payload
Name |
Title |
Type |
Default |
Description |
channelID |
channelID |
integer
|
|
ChannelID of pair-order book levels subscription |
AnyOf |
|
anyOf
|
|
|
a |
|
array
|
|
Ask array of level updates. |
Array |
|
array
|
|
Anonymous array of level values |
price |
price |
float
|
|
Price level |
volume |
volume |
float
|
|
Price level volume, for updates volume = 0 for level removal/deletion |
timestamp |
timestamp |
float
|
|
Price level last updated, seconds since epoch |
b |
|
array
|
|
Bid array of level updates. |
Array |
|
array
|
|
Anonymous array of level values |
price |
price |
float
|
|
Price level |
volume |
volume |
float
|
|
Price level volume, for updates volume = 0 for level removal/deletion |
timestamp |
timestamp |
float
|
|
Price level last updated, seconds since epoch |
Examples of update payload
[
1234,
{"a": [
[
"5541.30000",
"2.50700000",
"1534614248.456738"
],
[
"5542.50000",
"0.40100000",
"1534614248.456738"
]
]}
]
[
1234,
{"b": [
[
"5541.30000",
"0.00000000",
"1534614335.345903"
]
]}
]
[
1234,
{"a": [
[
"5541.30000",
"2.50700000",
"1534614248.456738"
],
[
"5542.50000",
"0.40100000",
"1534614248.456738"
]
]
},
{"b": [
[
"5541.30000",
"0.00000000",
"1534614335.345903"
]
]
}
]