Spot is covered over REST and WebSocket v2. Derivatives is covered over the Unified WebSocket only: public and private streams, and order entry. There are no Derivatives REST methods.
Requirements
Requires Rust 1.88 or later and the tokio async runtime.Install
What it covers
Spot
- Spot REST — complete public market data, plus authenticated account and trading endpoints
- Spot WebSocket v2 — public data streams and the authenticated
executionsandbalanceschannels - Order operations: add, amend, cancel, batch add, batch cancel, cancel-all, and a dead man’s switch
- Order routing over REST or authenticated WebSocket, selectable per call
- Real-time order book construction with CRC32 checksum validation and automatic reseeding on mismatch
Derivatives (Futures)
- Public Unified WebSocket streams — system status, instrument, ticker, trade, OHLC and order book (maintained with CRC32 validation, or raw deltas)
- Private Unified WebSocket streams —
executions,positions,balances,marginandpreferences - Order operations over the authenticated Unified WebSocket: place, amend, cancel by client order id or venue order id, batch place (2–15 orders on one symbol), batch cancel (2–50 orders), cancel-all, and a dead man’s switch that is independent of Spot’s
- Rejects orders the venue would refuse before sending them
- Uses the same API key as Spot
Both
- Authentication and automatic WebSocket token refresh
- Automatic reconnect with subscription replay
- Typed errors carrying a stable code, category, retryable flag and request id
- An event bus for connection state, rate-limit warnings, order book gaps and order lifecycle
Example
Derivatives example
Stream a Futures order book, then place a limit order. Futures orders always travel on the authenticated Unified WebSocket, so callclient.ready() before the first WebSocket operation.
Notes for developers coming from other Kraken SDKs
- Spot symbols use the modern format only.
BTC/USD, notXBTUSDorXXBTZUSD. Legacy codes return a typed error rather than being silently translated. Asset codes in responses are normalised the same way, so balances are keyedBTCandUSD. - Derivatives symbols are the native venue strings.
PF_XBTUSD,PF_ETHUSDand dated contracts such asFI_XBTUSD_251226. A Spot pair sent to a Futures method is rejected before anything is sent. - Prices and quantities are decimals, not floats. Parse them from strings (
"0.01".parse()?). The API does not acceptf64. - A WebSocket subscription is two steps: register a handler, then subscribe. The
on_*_forhelpers do both in one call and unsubscribe when dropped. - Rate limits are reported, not enforced. For Spot, the SDK emits a warning event as you approach your tier limit and never sleeps on your behalf, so pacing stays under your control. It does not track Derivatives orders. A venue throttle comes back as a retryable
RateLimitederror. - Derivatives has no REST path.
.via(Transport::Rest)on a Futures order returns a typedUnsupportedTransporterror. - Dead man’s switches are per product. The Spot and Derivatives timers are independent, and
cancel_allon one does not touch the other’s orders.