Authenticated connection. Connect to:
wss://wss.prime.kraken.com/ws/v1Connection Headers
- Header Schema
- Signature Generation
- Python Example
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Authenticate WebSocket connections to the Kraken Prime API using HMAC-SHA256 signed headers.
wss://wss.prime.kraken.com/ws/v1| Header | Type | Description |
|---|---|---|
| ApiKey | string | Your Kraken API key |
| ApiSign | string | base64-encoded signature |
| ApiTimestamp | string | An ISO-8601 UTC string of the form 2019-02-13T05:17:32.000000Z |
GET\n<ApiTimestamp>\n<host>\n<path>
GET\n2019-02-13T05:17:32.000000Z\nwss.sandbox.prime.kraken.com\n/ws/v1
# to install websocket lib:
# $ pip install websocket-client
from websocket import create_connection
import datetime
import hmac
import hashlib
import base64
api_key = "<apikey>"
api_secret = "<apisecret>"
utc_now = datetime.datetime.utcnow()
utc_datetime = utc_now.strftime("%Y-%m-%dT%H:%M:%S.000000Z")
host = "<websocket host>" # wss.sandbox.prime.kraken.com, for example
path = "/ws/v1"
params = "\n".join([
"GET",
utc_datetime,
host,
path,
])
hash = hmac.new(
api_secret.encode('ascii'), params.encode('ascii'), hashlib.sha256)
hash.hexdigest()
signature = base64.urlsafe_b64encode(hash.digest()).decode()
header = {
"ApiKey": api_key,
"ApiSign": signature,
"ApiTimestamp": utc_datetime,
}
ws = create_connection("wss://" + host + path, header=header)
while True:
print(ws.recv())
| Environment | WebSocket Endpoint |
|---|---|
| Sandbox | wss://wss.sandbox.prime.kraken.com/ws/v1 |
| Production | wss://wss.prime.kraken.com/ws/v1 |