Kraken WebSockets Public API Version 0.2.0

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

Connection details

Supported Pairs

ADA/CAD, ADA/ETH, ADA/EUR, ADA/USD, ADA/XBT, ATOM/CAD, ATOM/ETH, ATOM/EUR, ATOM/USD, ATOM/XBT, BCH/EUR, BCH/USD, BCH/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.

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.

Messages

ping

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 Type Description
event string ping
reqid integer Optional, client originated ID reflected in response message.

Example of payload

{
  "event": "ping",
  "reqid": 42
}

pong

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 Type Description
event string pong
reqid integer Optional, matching client originated request ID.

Example of payload

{
  "event": "pong",
  "reqid": 42
}

heartbeat

Publication: Server heartbeat sent if no subscription traffic within 1 second (approximately)

Payload

Name Type Description
event string heartbeat

Example of payload

{
  "event": "heartbeat"
}

systemStatus

Publication: Status sent on connection or system status changes.

Payload

Name Type Description
connectionID integer Connection ID
event string systemStatus
status string online|maintenance|(custom status)
version string

Example of payload

{
  "connectionID":8628615390848610222,
  "event": "systemStatus",
  "status": "online",
  "version": "1.0.0"
}

subscribe

Request: Subscribe to a topic on a single or multiple currency pairs.

Payload

Name Type Description
event string subscribe
reqid integer Optional, client originated ID reflected in response message.
pair array Array of currency pairs (pair1,pair2,pair3).
subscription object
name string ticker|ohlc|trade|book|spread|*, * for all (ohlc interval value is 1 if all channels subscribed)
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 integer 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
  }
}

unsubscribe

Request: Unsubscribe from single subscription, can specify multiple currency pairs.

Payload

Name Type Description
Message Payload oneOf
(Anonymous) object
event string unsubscribe
reqid integer Optional, client originated ID reflected in response message.
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 string ticker|ohlc|trade|book|spread|*, * for all
interval integer Optional - Time interval associated with ohlc subscription in minutes; interval values: 1|5|15|30|60|240|1440|10080|21600
depth integer 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
reqid integer Optional, client originated ID reflected in response message.
channelID integer ChannelID associated with pair subscription

Examples of payload

{
  "event": "unsubscribe",
  "pair": [
    "XBT/EUR","XBT/USD"
  ],
  "subscription": {
    "name": "ticker"
  }
}
{
  "event": "unsubscribe",
  "channelID": 10001
}

subscriptionStatus

Response & Publication: Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.

Payload

Name Type Description
channelID integer ChannelID on successful subscription
channelName string Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix.
event string subscriptionStatus
pair string Currency pair
status string Status of subscription: subscribed|unsubscribed|error
reqid integer Optional, matching client originated request ID.
subscription object
name string ticker|ohlc|trade|book|spread|*, * for all
interval integer Optional - Time interval associated with ohlc subscription in minutes, interval values: 1|5|15|30|60|240|1440|10080|21600
depth integer 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 string Error message

Examples of payload

{
  "channelID": 10001,
  "channelName": "ticker"
  "event": "subscriptionStatus",
  "pair": "XBT/EUR",
  "status": "subscribed",
  "subscription": {
    "name": "ticker"
  }
 
}
{
  "channelID": 10001,
  "channelName": "ohlc-5"
  "event": "subscriptionStatus",
  "pair": "XBT/EUR",
  "status": "unsubscribed",
  "reqID": 42,
  "subscription": {
    "interval": 5
    "name": "ohlc-5",
  }
  
}
Example payload for error message 'Subscription depth not supported'
{
  "errorMessage": "Subscription depth not supported",
  "event": "subscriptionStatus",
  "pair": "XBT/USD",
  "status": "error",
  "subscription": {
    "depth":42
    "name": "book",
  }
}

ticker

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 Type Description
channelID integer ChannelID of pair-ticker subscription
(Anonymous) object
a array Ask
price float Best Ask Price
wholeLotVolume integer Whole lot volume
lotVolume float Lot volume
b array Bid
price float Best Bid Price
wholeLotVolume integer Whole lot volume
lotVolume float Lot volume
c array Close
price float Price
lotVolume float Lot volume
v array Volume
today float Value today
last24Hours float Volume over the past 24 hours
p array Volume weighted average price
today float Value today
last24Hours float Value over the past 24 hours
t array Number of trades
today integer Value today
last24Hours integer Value over the past 24 hours
l array Low price
today float Value today
last24Hours float Value over the past 24 hours
h array High price
today float Value today
last24Hours float Value over the past 24 hours
o array Open Price
today float Value today
last24Hours float Value over the past 24 hours
channelName string Channel Name of subscription
pair string Asset pair

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"
    ]
  },
  "ticker",
  "XBT/USD"
]

ohlc

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 Type Description
channelID integer ChannelID of pair-ohlc subscription
Array array
time float Time, seconds since epoch
endtime float End Timestamp of the interval
open float First traded price of the interval
high float Highest traded price of the interval
low float Lowest traded price of the interval
close float Last traded price of the interval
vwap float Volume weighted average price of the interval
volume float Accumulated volume of the interval
count integer Number of trades in the interval
channelName string Channel Name of subscription and interval as suffix
pair string Asset pair

Example of payload

[
  42,
  [
    "1542057314.748456",
    "1542057360.435743",
    "3586.70000",
    "3586.70000",
    "3586.60000",
    "3586.60000",
    "3586.68894",
    "0.03373000",
    2
  ],
  "ohlc-5",
  "XBT/USD"
]

trade

Publication: Trade feed for a currency pair.

Payload

Name Type Description
channelID integer ChannelID of pair-trade subscription
Array array Array of trades
Array array Array of trade values
price float Price
volume float Volume
time float Time, seconds since epoch
side string Triggering order side (buy/sell), values: b|s
orderType string Triggering order type (market/limit), values: m|l
misc string Miscellaneous
channelName string Channel Name of subscription
pair string Asset pair

Example of payload

[
  0,
  [
    [
      "5541.20000",
      "0.15850568",
      "1534614057.321597",
      "s",
      "l",
      ""
    ],
    [
      "6060.00000",
      "0.02455000",
      "1534614057.324998",
      "b",
      "l",
      ""
    ]
  ],
  "trade",
  "XBT/USD"
]

spread

Publication: Spread feed to show best bid and ask price for subscribed asset pair. Bid volume and ask volume is part of the message too.

Payload

Name Type Description
channelID integer ChannelID of pair-spreads subscription
Array array
bid float Bid price
ask float Ask price
timestamp float Time, seconds since epoch
bidVolume float Bid Volume
askVolume float Ask Volume
channelName string Channel Name of subscription
pair string Asset pair

Example of payload

[
  0,
  [
    "5698.40000",
    "5700.00000",
    "1542057299.545897",
    "1.01234567",
    "0.98765432"
  ],
  "spread",
  "XBT/USD"
]

book

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 Type Description
channelID integer ChannelID of pair-order book levels subscription
(Anonymous) object
as array Array of price levels, ascending from best ask
Array array Anonymous array of level values
price float Price level
volume float Price level volume.
timestamp float Price level last updated, seconds since epoch
bs array Array of price levels, descending from best bid
Array array Anonymous array of level values
price float Price level
volume float Price level volume
timestamp float Price level last updated, seconds since epoch
channelName string Channel Name of subscription and depth as suffix
pair string Asset pair

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"
      ]
    ]
  },
  "book-100",
  "XBT/USD"
]

Update Payload

Name Type Description
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 float Price level
volume float Price level volume, for updates volume = 0 for level removal/deletion
timestamp float Price level last updated, seconds since epoch
updateType string "r" to show republish updates, optional field
b array Bid array of level updates.
Array array Anonymous array of level values
price float Price level
volume float Price level volume, for updates volume = 0 for level removal/deletion
timestamp float Price level last updated, seconds since epoch
updateType string "r" to show republish updates, optional field
channelName string Channel Name of subscription
pair string Asset pair

Examples of update payload

[
  1234,
  {"a": [
    [
      "5541.30000",
      "2.50700000",
      "1534614248.456738"
    ],
    [
      "5542.50000",
      "0.40100000",
      "1534614248.456738"
    ]
  ]},
  "book-10",
  "XBT/USD"
]
[
  1234,
  {"b": [
    [
      "5541.30000",
      "0.00000000",
      "1534614335.345903"
    ]
  ]}
  "book-10",
  "XBT/USD"
]
[
  1234,
  {"a": [
    [
      "5541.30000",
      "2.50700000",
      "1534614248.456738"
    ],
    [
      "5542.50000",
      "0.40100000",
      "1534614248.456738"
    ]
  ]
  },
  {"b": [
    [
      "5541.30000",
      "0.00000000",
      "1534614335.345903"
    ]
  ]
  },
  "book-10",
  "XBT/USD"
]

Examples of republish payload

[
  1234,
  {"a": [
    [
      "5541.30000",
      "2.50700000",
      "1534614248.456738",
      "r"
    ],
    [
      "5542.50000",
      "0.40100000",
      "1534614248.456738",
      "r"
    ]
  ]},
  "book-25",
  "XBT/USD"
]
99088