Home
Kraken
Kraken Spot WebSocket API v2
Kraken · AsyncAPI Specification
Kraken Spot WebSocket API v2
Version 2.0.0
Public WebSocket API for the Kraken cryptocurrency exchange (Spot v2). Provides real-time market data through subscribe/unsubscribe semantics over JSON. Channels documented here are restricted to the public surface confirmed by https://docs.kraken.com/api/docs/websocket-v2/ (ticker, book, ohlc, trade, instrument) plus the connection-level methods (ping/pong, subscribe, unsubscribe). Authenticated channels are intentionally out of scope.
Channels
ticker
publish
Subscribe or unsubscribe from the ticker channel.
Level 1 market data: best bid/ask, last trade, 24h volume/VWAP/high/low, and price change metrics for one or more currency pairs.
book
publish
Subscribe or unsubscribe from the book channel.
Level 2 order book channel. Emits an initial snapshot of bids/asks followed by incremental updates. Includes a CRC32 checksum for the top 10 levels.
ohlc
publish
Subscribe or unsubscribe from the ohlc channel.
Open/High/Low/Close candle data for a configured interval (1, 5, 15, 30, 60, 240, 1440, 10080, or 21600 minutes). Updates are trade-triggered.
trade
publish
Subscribe or unsubscribe from the trade channel.
Stream of individual trade executions. Optional initial snapshot returns the most recent 50 trades for each subscribed symbol.
instrument
publish
Subscribe or unsubscribe from the instrument channel.
Reference data feed for all active assets and tradeable pairs, including precisions, trading limits, and margin parameters.
ping
publish
Send a ping to the server.
Application-level keepalive. Distinct from the WebSocket protocol-level ping frames. Server replies with a pong message echoing req_id and including time_in/time_out timestamps.
Messages
✉
SubscribeTicker
Subscribe to ticker
✉
UnsubscribeTicker
Unsubscribe from ticker
✉
TickerMessage
Ticker snapshot or update
✉
SubscribeBook
Subscribe to book
✉
UnsubscribeBook
Unsubscribe from book
✉
BookMessage
Book snapshot or update
✉
SubscribeOHLC
Subscribe to OHLC
✉
UnsubscribeOHLC
Unsubscribe from OHLC
✉
OHLCMessage
OHLC snapshot or update
✉
SubscribeTrade
Subscribe to trade
✉
UnsubscribeTrade
Unsubscribe from trade
✉
TradeMessage
Trade snapshot or update
✉
SubscribeInstrument
Subscribe to instrument
✉
UnsubscribeInstrument
Unsubscribe from instrument
✉
InstrumentMessage
Instrument snapshot or update
✉
SubscriptionStatus
Subscribe/Unsubscribe acknowledgement
Servers
wss
public
ws.kraken.com/v2
Public market data WebSocket endpoint. No authentication required. Carries ticker, book, ohlc, trade, and instrument channels.
wss
authenticated
ws-auth.kraken.com/v2
Authenticated WebSocket endpoint used for private channels and trading methods (out of scope for this document; included here only because it is a documented separate host). Connecting requires a token obtained from the REST GetWebSocketsToken endpoint.
AsyncAPI Specification
asyncapi: 2.6.0
info:
title: Kraken Spot WebSocket API v2
version: '2.0.0'
description: >
Public WebSocket API for the Kraken cryptocurrency exchange (Spot v2).
Provides real-time market data through subscribe/unsubscribe semantics over JSON.
Channels documented here are restricted to the public surface confirmed by
https://docs.kraken.com/api/docs/websocket-v2/ (ticker, book, ohlc, trade,
instrument) plus the connection-level methods (ping/pong, subscribe,
unsubscribe). Authenticated channels are intentionally out of scope.
contact:
name: Kraken API Support
url: https://support.kraken.com/
license:
name: Kraken Terms of Service
url: https://www.kraken.com/legal
defaultContentType: application/json
servers:
public:
url: ws.kraken.com/v2
protocol: wss
description: >
Public market data WebSocket endpoint. No authentication required. Carries
ticker, book, ohlc, trade, and instrument channels.
authenticated:
url: ws-auth.kraken.com/v2
protocol: wss
description: >
Authenticated WebSocket endpoint used for private channels and trading
methods (out of scope for this document; included here only because it is
a documented separate host). Connecting requires a token obtained from the
REST GetWebSocketsToken endpoint.
channels:
ticker:
description: >
Level 1 market data: best bid/ask, last trade, 24h volume/VWAP/high/low,
and price change metrics for one or more currency pairs.
subscribe:
summary: Receive ticker snapshot and updates from the server.
message:
oneOf:
- $ref: '#/components/messages/TickerMessage'
- $ref: '#/components/messages/SubscriptionStatus'
publish:
summary: Subscribe or unsubscribe from the ticker channel.
message:
oneOf:
- $ref: '#/components/messages/SubscribeTicker'
- $ref: '#/components/messages/UnsubscribeTicker'
book:
description: >
Level 2 order book channel. Emits an initial snapshot of bids/asks
followed by incremental updates. Includes a CRC32 checksum for the top
10 levels.
subscribe:
summary: Receive book snapshot and update messages.
message:
oneOf:
- $ref: '#/components/messages/BookMessage'
- $ref: '#/components/messages/SubscriptionStatus'
publish:
summary: Subscribe or unsubscribe from the book channel.
message:
oneOf:
- $ref: '#/components/messages/SubscribeBook'
- $ref: '#/components/messages/UnsubscribeBook'
ohlc:
description: >
Open/High/Low/Close candle data for a configured interval (1, 5, 15, 30,
60, 240, 1440, 10080, or 21600 minutes). Updates are trade-triggered.
subscribe:
summary: Receive OHLC snapshot and update messages.
message:
oneOf:
- $ref: '#/components/messages/OHLCMessage'
- $ref: '#/components/messages/SubscriptionStatus'
publish:
summary: Subscribe or unsubscribe from the ohlc channel.
message:
oneOf:
- $ref: '#/components/messages/SubscribeOHLC'
- $ref: '#/components/messages/UnsubscribeOHLC'
trade:
description: >
Stream of individual trade executions. Optional initial snapshot returns
the most recent 50 trades for each subscribed symbol.
subscribe:
summary: Receive trade snapshot and update messages.
message:
oneOf:
- $ref: '#/components/messages/TradeMessage'
- $ref: '#/components/messages/SubscriptionStatus'
publish:
summary: Subscribe or unsubscribe from the trade channel.
message:
oneOf:
- $ref: '#/components/messages/SubscribeTrade'
- $ref: '#/components/messages/UnsubscribeTrade'
instrument:
description: >
Reference data feed for all active assets and tradeable pairs, including
precisions, trading limits, and margin parameters.
subscribe:
summary: Receive instrument snapshot and update messages.
message:
oneOf:
- $ref: '#/components/messages/InstrumentMessage'
- $ref: '#/components/messages/SubscriptionStatus'
publish:
summary: Subscribe or unsubscribe from the instrument channel.
message:
oneOf:
- $ref: '#/components/messages/SubscribeInstrument'
- $ref: '#/components/messages/UnsubscribeInstrument'
ping:
description: >
Application-level keepalive. Distinct from the WebSocket protocol-level
ping frames. Server replies with a pong message echoing req_id and
including time_in/time_out timestamps.
subscribe:
summary: Receive pong response from the server.
message:
$ref: '#/components/messages/Pong'
publish:
summary: Send a ping to the server.
message:
$ref: '#/components/messages/Ping'
components:
messages:
SubscribeTicker:
name: subscribeTicker
title: Subscribe to ticker
payload:
$ref: '#/components/schemas/SubscribeTickerRequest'
UnsubscribeTicker:
name: unsubscribeTicker
title: Unsubscribe from ticker
payload:
$ref: '#/components/schemas/UnsubscribeTickerRequest'
TickerMessage:
name: tickerMessage
title: Ticker snapshot or update
payload:
$ref: '#/components/schemas/TickerEnvelope'
SubscribeBook:
name: subscribeBook
title: Subscribe to book
payload:
$ref: '#/components/schemas/SubscribeBookRequest'
UnsubscribeBook:
name: unsubscribeBook
title: Unsubscribe from book
payload:
$ref: '#/components/schemas/UnsubscribeBookRequest'
BookMessage:
name: bookMessage
title: Book snapshot or update
payload:
$ref: '#/components/schemas/BookEnvelope'
SubscribeOHLC:
name: subscribeOHLC
title: Subscribe to OHLC
payload:
$ref: '#/components/schemas/SubscribeOHLCRequest'
UnsubscribeOHLC:
name: unsubscribeOHLC
title: Unsubscribe from OHLC
payload:
$ref: '#/components/schemas/UnsubscribeOHLCRequest'
OHLCMessage:
name: ohlcMessage
title: OHLC snapshot or update
payload:
$ref: '#/components/schemas/OHLCEnvelope'
SubscribeTrade:
name: subscribeTrade
title: Subscribe to trade
payload:
$ref: '#/components/schemas/SubscribeTradeRequest'
UnsubscribeTrade:
name: unsubscribeTrade
title: Unsubscribe from trade
payload:
$ref: '#/components/schemas/UnsubscribeTradeRequest'
TradeMessage:
name: tradeMessage
title: Trade snapshot or update
payload:
$ref: '#/components/schemas/TradeEnvelope'
SubscribeInstrument:
name: subscribeInstrument
title: Subscribe to instrument
payload:
$ref: '#/components/schemas/SubscribeInstrumentRequest'
UnsubscribeInstrument:
name: unsubscribeInstrument
title: Unsubscribe from instrument
payload:
$ref: '#/components/schemas/UnsubscribeInstrumentRequest'
InstrumentMessage:
name: instrumentMessage
title: Instrument snapshot or update
payload:
$ref: '#/components/schemas/InstrumentEnvelope'
SubscriptionStatus:
name: subscriptionStatus
title: Subscribe/Unsubscribe acknowledgement
payload:
$ref: '#/components/schemas/SubscriptionStatusResponse'
Ping:
name: ping
title: Ping request
payload:
$ref: '#/components/schemas/PingRequest'
Pong:
name: pong
title: Pong response
payload:
$ref: '#/components/schemas/PongResponse'
schemas:
# ---------- Common envelopes ----------
SubscribeRequestBase:
type: object
required:
- method
- params
properties:
method:
type: string
enum: [subscribe]
req_id:
type: integer
description: Optional client-originated request identifier echoed in the response.
UnsubscribeRequestBase:
type: object
required:
- method
- params
properties:
method:
type: string
enum: [unsubscribe]
req_id:
type: integer
SubscriptionStatusResponse:
type: object
description: Standard server acknowledgement for subscribe/unsubscribe requests.
properties:
method:
type: string
enum: [subscribe, unsubscribe]
req_id:
type: integer
success:
type: boolean
result:
type: object
description: Echo of the parameters of a successful subscription.
error:
type: string
description: Error message when success is false.
time_in:
type: string
format: date-time
description: RFC3339 timestamp the request was received on the wire.
time_out:
type: string
format: date-time
description: RFC3339 timestamp the response was sent on the wire.
warnings:
type: array
items:
type: string
# ---------- Ticker ----------
SubscribeTickerRequest:
allOf:
- $ref: '#/components/schemas/SubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [ticker]
symbol:
type: array
items:
type: string
example: ["BTC/USD", "MATIC/GBP"]
event_trigger:
type: string
enum: [bbo, trades]
default: trades
description: bbo emits on best-bid/offer change; trades emits on trade events.
snapshot:
type: boolean
default: true
UnsubscribeTickerRequest:
allOf:
- $ref: '#/components/schemas/UnsubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [ticker]
symbol:
type: array
items:
type: string
TickerEnvelope:
type: object
required: [channel, type, data]
properties:
channel:
type: string
enum: [ticker]
type:
type: string
enum: [snapshot, update]
data:
type: array
items:
$ref: '#/components/schemas/Ticker'
Ticker:
type: object
properties:
symbol:
type: string
bid:
type: number
format: double
description: Best bid price.
bid_qty:
type: number
format: double
description: Quantity at best bid.
ask:
type: number
format: double
description: Best ask price.
ask_qty:
type: number
format: double
description: Quantity at best ask.
last:
type: number
format: double
description: Last traded price.
volume:
type: number
format: double
description: 24-hour volume in the base currency.
vwap:
type: number
format: double
description: 24-hour volume weighted average price.
low:
type: number
format: double
description: 24-hour low price.
high:
type: number
format: double
description: 24-hour high price.
change:
type: number
format: double
description: 24-hour absolute price change.
change_pct:
type: number
format: double
description: 24-hour percentage price change.
# ---------- Book ----------
SubscribeBookRequest:
allOf:
- $ref: '#/components/schemas/SubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [book]
symbol:
type: array
items:
type: string
depth:
type: integer
enum: [10, 25, 100, 500, 1000]
default: 10
snapshot:
type: boolean
default: true
UnsubscribeBookRequest:
allOf:
- $ref: '#/components/schemas/UnsubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [book]
symbol:
type: array
items:
type: string
depth:
type: integer
enum: [10, 25, 100, 500, 1000]
BookEnvelope:
type: object
required: [channel, type, data]
properties:
channel:
type: string
enum: [book]
type:
type: string
enum: [snapshot, update]
data:
type: array
items:
$ref: '#/components/schemas/BookData'
BookData:
type: object
properties:
symbol:
type: string
bids:
type: array
items:
$ref: '#/components/schemas/PriceLevel'
asks:
type: array
items:
$ref: '#/components/schemas/PriceLevel'
checksum:
type: integer
format: int64
description: CRC32 checksum of the top 10 bids and asks.
timestamp:
type: string
format: date-time
PriceLevel:
type: object
properties:
price:
type: number
format: double
qty:
type: number
format: double
# ---------- OHLC ----------
SubscribeOHLCRequest:
allOf:
- $ref: '#/components/schemas/SubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [ohlc]
symbol:
type: array
items:
type: string
interval:
type: integer
enum: [1, 5, 15, 30, 60, 240, 1440, 10080, 21600]
snapshot:
type: boolean
default: true
UnsubscribeOHLCRequest:
allOf:
- $ref: '#/components/schemas/UnsubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [ohlc]
symbol:
type: array
items:
type: string
interval:
type: integer
enum: [1, 5, 15, 30, 60, 240, 1440, 10080, 21600]
OHLCEnvelope:
type: object
required: [channel, type, data]
properties:
channel:
type: string
enum: [ohlc]
type:
type: string
enum: [snapshot, update]
data:
type: array
items:
$ref: '#/components/schemas/Candle'
Candle:
type: object
properties:
symbol:
type: string
open:
type: number
format: double
high:
type: number
format: double
low:
type: number
format: double
close:
type: number
format: double
vwap:
type: number
format: double
trades:
type: integer
description: Number of trades in the interval.
volume:
type: number
format: double
description: Total traded volume in the base currency.
interval_begin:
type: string
format: date-time
description: RFC3339 timestamp of interval start.
interval:
type: integer
description: Interval length in minutes.
# ---------- Trade ----------
SubscribeTradeRequest:
allOf:
- $ref: '#/components/schemas/SubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [trade]
symbol:
type: array
items:
type: string
snapshot:
type: boolean
default: false
description: When true, returns the most recent 50 trades on subscribe.
UnsubscribeTradeRequest:
allOf:
- $ref: '#/components/schemas/UnsubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel, symbol]
properties:
channel:
type: string
enum: [trade]
symbol:
type: array
items:
type: string
TradeEnvelope:
type: object
required: [channel, type, data]
properties:
channel:
type: string
enum: [trade]
type:
type: string
enum: [snapshot, update]
data:
type: array
items:
$ref: '#/components/schemas/Trade'
Trade:
type: object
properties:
symbol:
type: string
side:
type: string
enum: [buy, sell]
description: Taker order direction.
qty:
type: number
format: double
price:
type: number
format: double
ord_type:
type: string
enum: [limit, market]
description: Taker order type.
trade_id:
type: integer
format: int64
description: Sequence number unique per trading book.
timestamp:
type: string
format: date-time
# ---------- Instrument ----------
SubscribeInstrumentRequest:
allOf:
- $ref: '#/components/schemas/SubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel]
properties:
channel:
type: string
enum: [instrument]
execution_venue:
type: string
enum: [international, bitnomial-exchange]
default: international
include_tokenized_assets:
type: boolean
default: false
snapshot:
type: boolean
default: true
UnsubscribeInstrumentRequest:
allOf:
- $ref: '#/components/schemas/UnsubscribeRequestBase'
- type: object
properties:
params:
type: object
required: [channel]
properties:
channel:
type: string
enum: [instrument]
InstrumentEnvelope:
type: object
required: [channel, type, data]
properties:
channel:
type: string
enum: [instrument]
type:
type: string
enum: [snapshot, update]
data:
type: object
properties:
assets:
type: array
items:
$ref: '#/components/schemas/Asset'
pairs:
type: array
items:
$ref: '#/components/schemas/Pair'
Asset:
type: object
properties:
id:
type: string
status:
type: string
precision:
type: integer
precision_display:
type: integer
borrowable:
type: boolean
collateral_value:
type: number
format: double
margin_rate:
type: number
format: double
multiplier:
type: number
format: double
Pair:
type: object
properties:
symbol:
type: string
base:
type: string
quote:
type: string
status:
type: string
marginable:
type: boolean
has_index:
type: boolean
qty_min:
type: string
qty_increment:
type: string
qty_precision:
type: integer
price_increment:
type: string
price_precision:
type: integer
cost_precision:
type: integer
cost_min:
type: string
margin_initial:
type: number
format: double
position_limit_long:
type: integer
position_limit_short:
type: integer
# ---------- Ping / Pong ----------
PingRequest:
type: object
required: [method]
properties:
method:
type: string
enum: [ping]
req_id:
type: integer
PongResponse:
type: object
required: [method]
properties:
method:
type: string
enum: [pong]
req_id:
type: integer
success:
type: boolean
time_in:
type: string
format: date-time
time_out:
type: string
format: date-time
result:
type: object
error:
type: string
warnings:
type: array
items:
type: string