kraken-sockets kraken-sockets

kraken-sockets

Overview

kraken-sockets is a Python library that provides a clean, decorator-based interface to Kraken’s WebSocket API v2. It handles real-time market data subscriptions including tickers, trades, order books, OHLC data, and more — as well as authenticated private endpoints for orders, balances, and executions.

Rationale

Kraken’s WebSocket API is powerful but working with raw WebSocket connections requires significant boilerplate — connection management, message parsing, authentication token handling, and subscription lifecycle management. kraken-sockets wraps all of this into a simple decorator pattern where you define handler functions for specific response types and the library handles the rest.

Technicals

  • Language: Python
  • Architecture: Async event loop with decorator-based trigger system
  • Dependencies: asyncio, websockets, Pydantic schemas for request/response validation
  • Auth: Environment variable-based API key configuration for private endpoints
  • Distribution: Published on PyPI as kraken-sockets

Features

  • WebSocket v2 API connection management
  • Decorator-based trigger system (@kraken.trigger)
  • Market data subscriptions (ticker, trades, book, OHLC, instruments)
  • Typed request/response schemas with Pydantic
  • Custom logging handler support
  • Custom async task injection
  • Private endpoint authentication
  • Order placement and management via WebSocket
  • Reconnection and retry logic

Lessons Learned

Coming soon.

Future

Coming soon.


← Back to projects