python-kraken-sdk
raw JSON → 3.2.8 verified Mon Apr 27 auth: no python
A comprehensive Python SDK for the Kraken cryptocurrency exchange, providing both REST and WebSocket clients for Spot and Futures trading. Version 3.2.8 requires Python >=3.11. Released monthly.
pip install python-kraken-sdk Common errors
error ModuleNotFoundError: No module named 'kraken' ↓
cause Package not installed or wrong import path.
fix
Run
pip install python-kraken-sdk and use from kraken.spot import KrakenSpot. error AttributeError: module 'kraken' has no attribute 'Market' ↓
cause Trying to import Market from top-level kraken, which was valid in v2.x but not in v3.x.
fix
Use
from kraken.spot import Market. error kraken.exceptions.KrakenException: EGeneral:Invalid arguments ↓
cause Missing or incorrect API parameters (e.g., 'stp_type' instead of 'stptype' in older versions).
fix
Check parameter names against Kraken API documentation. For v<3.2.2, use 'stptype' explicitly.
Warnings
breaking In v3.x, the package structure changed: all modules are under `kraken.spot` and `kraken.futures`. Previously, top-level imports like `from kraken import Market` no longer work. ↓
fix Use `from kraken.spot import Market` instead.
gotcha WebSocket clients (KrakenSpotWS, KrakenFuturesWS) require explicit connection and disconnection. Using them without calling `connect()` or forgetting `stop()` can cause resource leaks. ↓
fix Always use context managers or try/finally to connect and disconnect.
deprecated Methods `async_close` and `stop` on websocket clients are deprecated in v3.1.6+. Use `disconnect()` instead. ↓
fix Replace `async_close()` or `stop()` with `disconnect()`.
gotcha The `create_order` parameter `stp_type` must be sent as `stptype` to the API. In v3.2.2, the SDK incorrectly used `stp_type`. This was fixed in v3.2.2+. ↓
fix Upgrade to >=3.2.2 or pass `stptype` manually if using older version.
breaking In v3.0.0, the minimum Python version was raised to 3.11. Python 3.10 and below are no longer supported. ↓
fix Use Python 3.11 or later.
Imports
- KrakenSpot
from kraken.spot import KrakenSpot - KrakenFutures
from kraken.futures import KrakenFutures - KrakenSpotWS
from kraken.spot import KrakenSpotWS - Market wrong
from kraken import Marketcorrectfrom kraken.spot import Market
Quickstart
import os
from kraken.spot import KrakenSpot
api_key = os.environ.get('KRAKEN_API_KEY', '')
secret_key = os.environ.get('KRAKEN_SECRET_KEY', '')
client = KrakenSpot(api_key=api_key, secret_key=secret_key)
print(client.get_account_balance())