2. Call the REST API GetWebSocketsToken endpoint to retrieve a new WebSocket authentication token, which will look similar to the following:
WOg6IVQ5RfogMzkhH25WOg6IVQ5RqhP+U3ZprQVnh7f
Authentication tokens have an initial validity of 15 minutes (900 seconds), but once a token is used to subscribe to a private feed, the token will remain valid as long as the subscription remains active.
Our Python 3 example shows how to retrieve a WebSocket authentication token from the REST API GetWebSocketsToken endpoint in just a few lines of code.
3. Connect to the WebSocket API via the private feed URL wss://ws-auth.kraken.com/ and subscribe to either the openOrders feed, the ownTrades feed or both feeds.
The WebSocket authentication token must be provided in the subscription message as the value of the token field: