The following Python code implements a command line API client for our exchange WebSocket API v1. The code can be used as a standalone API client, or can be called from other interpreted or compiled programming languages (Bash, C++, etc.).
The standard Python WebSocket library (websocket-client) is required for the WebSocket networking, but no other API libraries/modules are required.
The WebSocket API command line client can also be downloaded as krakenws.py.
All public market data feeds (ticker, book, spread, ohlc, trade), private account management feeds (openOrders and ownTrades), and trading endpoints (addOrder, cancelOrder, cancelAll) are supported.
For the private feeds/endpoints, a WebSocket authentication token must be provided by retrieving the token from the REST API GetWebSocketsToken endpoint, and then copying/pasting the token value into a text file named WS_Token (in the same directory/folder as the command line API client).