### List funding networks (Python) Source: https://docs.kraken.com/exchange/guides/rest/funding Python example using a funding_request helper to GET /funding/v1/networks and print network group IDs and names. ```python networks = funding_request("GET", "/funding/v1/networks") for group in networks["network_groups"]: print(group["name"], group["network_group_id"]) ``` -------------------------------- ### List funding networks response Source: https://docs.kraken.com/exchange/guides/rest/funding Example JSON response from GET /funding/v1/networks, showing network_groups and networks arrays with IDs and names. ```json { "network_groups": [ { "network_group_id": "f95acdb7-48fb-4441-b5b4-843d3bf60e61", "name": "EVM", "network_ids": [ "d9d375da-44b7-4be1-8a00-8b281acfe366", "9637bc15-ec8a-43de-8310-887f0a02a9ed", ] } ], "networks": [ { "network_id": "d9d375da-44b7-4be1-8a00-8b281acfe366", "name": "Ethereum" }, { "network_id": "9637bc15-ec8a-43de-8310-887f0a02a9ed", "name": "Base" }, ] } ``` -------------------------------- ### Get WebSocket Token in Go Source: https://docs.kraken.com/exchange/guides/websockets/authentication Go example using net/http to call the GetWebSocketsToken endpoint. It signs the request with HMAC-SHA512 and prints the token. Replace YOUR_API_KEY and YOUR_API_SECRET with your credentials. ```go package main import ( "crypto/hmac" "crypto/sha256" "crypto/sha512" "encoding/base64" "encoding/json" "fmt" "io" "net/http" "net/url" "strings" "time" ) func getKrakenSignature(urlPath string, data url.Values, secret string) (string, error) { nonce := data.Get("nonce") encoded := nonce + data.Encode() sha := sha256.Sum256([]byte(encoded)) message := append([]byte(urlPath), sha[:]...) secretDecoded, err := base64.StdEncoding.DecodeString(secret) if err != nil { return "", err } mac := hmac.New(sha512.New, secretDecoded) mac.Write(message) return base64.StdEncoding.EncodeToString(mac.Sum(nil)), nil } func main() { apiKey := "YOUR_API_KEY" apiSecret := "YOUR_API_SECRET" nonce := fmt.Sprintf("%d", time.Now().UnixMilli()) data := url.Values{"nonce": {nonce}} sig, err := getKrakenSignature("/0/private/GetWebSocketsToken", data, apiSecret) if err != nil { panic(err) } req, _ := http.NewRequest("POST", "https://api.kraken.com/0/private/GetWebSocketsToken", strings.NewReader(data.Encode())) req.Header.Set("API-Key", apiKey) req.Header.Set("API-Sign", sig) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) var result struct { Result struct { Token string `json:"token"` } `json:"result"` } json.Unmarshal(body, &result) fmt.Printf("Token: %s\n", result.Result.Token) } ``` -------------------------------- ### Go nonce generation Source: https://docs.kraken.com/exchange/guides/rest/authentication Generate a millisecond-resolution nonce in Go using the time package. The example uses time.Now().UnixMilli() to get the current time in milliseconds and formats it as a string. ```go import ( "fmt" "time" ) apiNonce := fmt.Sprintf("%d", time.Now().UnixMilli()) ``` -------------------------------- ### Order Examples Source: https://docs.kraken.com/exchange/api-reference/unified-fix/nos Example FIX messages for different order types: Limit (GTC), Market, IOC, FOK, GTD, and Post-Only. ```APIDOC ## Order Examples ### Limit (GTC) ``` 8=FIX.4.4|9=148|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036325000000|55=BTC/USD|54=1|40=2|44=84000|38=0.001|59=1|60=20260407-14:32:05.000|10=141| ``` ### Market ``` 8=FIX.4.4|9=139|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036325200000|55=BTC/USD|54=1|40=1|38=0.001|59=1|60=20260407-14:32:05.000|10=236| ``` ### IOC ``` 8=FIX.4.4|9=148|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036325300000|55=BTC/USD|54=1|40=2|44=84000|38=0.001|59=3|60=20260407-14:32:05.000|10=146| ``` ### FOK ``` 8=FIX.4.4|9=148|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036335000000|55=BTC/USD|54=1|40=2|44=84000|38=0.001|59=4|60=20260407-14:32:05.000|10=145| ``` ### GTD ``` 8=FIX.4.4|9=170|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036325400000|55=BTC/USD|54=1|40=2|44=84000|38=0.001|59=6|126=20260408-14:32:05|60=20260407-14:32:05.000|10=206| ``` ### Post-Only ``` 8=FIX.4.4|9=153|35=D|34=2|49=CLIENT|56=KRAKEN-TRD|52=20260407-14:32:05.000|11=1744036326000000|55=BTC/USD|54=1|40=2|44=83000|38=0.001|59=1|18=P|60=20260407-14:32:05.000|10=128| ``` ``` -------------------------------- ### Book snapshot input example Source: https://docs.kraken.com/exchange/guides/websockets/book-checksum-v2 Example book snapshot message used to illustrate the checksum calculation. Contains top 10 bid and ask levels with string prices and quantities, plus the expected checksum value 3310070434. ```json { "channel": "book", "type": "snapshot", "data": [{ "symbol": "BTC/USD", "bids": [ {"price": "45283.5", "qty": "0.10000000"}, {"price": "45283.4", "qty": "1.54582015"}, {"price": "45282.1", "qty": "0.10000000"}, {"price": "45281.0", "qty": "0.10000000"}, {"price": "45280.3", "qty": "1.54592586"}, {"price": "45279.0", "qty": "0.07990000"}, {"price": "45277.6", "qty": "0.03310103"}, {"price": "45277.5", "qty": "0.30000000"}, {"price": "45277.3", "qty": "1.54602737"}, {"price": "45276.6", "qty": "0.15445238"} ], "asks": [ {"price": "45285.2", "qty": "0.00100000"}, {"price": "45286.4", "qty": "1.54571953"}, {"price": "45286.6", "qty": "1.54571109"}, {"price": "45289.6", "qty": "1.54560911"}, {"price": "45290.2", "qty": "0.15890660"}, {"price": "45291.8", "qty": "1.54553491"}, {"price": "45294.7", "qty": "0.04454749"}, {"price": "45296.1", "qty": "0.35380000"}, {"price": "45297.5", "qty": "0.09945542"}, {"price": "45299.5", "qty": "0.18772827"} ], "checksum": 3310070434 }] } ``` -------------------------------- ### Example instruments response with makerProtectionMillis Source: https://docs.kraken.com/exchange/guides/futures/maker-protection Example JSON response from the instruments endpoint showing the `makerProtectionMillis` field set to 20 for the PF_ATOMUSD market. The field is omitted entirely when no Maker Protection is configured. ```json { "symbol": "PF_ATOMUSD", "type": "flexible_futures", "tradeable": true, "makerProtectionMillis": 20 } ``` -------------------------------- ### Spot L2 Market Data Snapshot Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/mdsfr Example of a FIX Market Data Snapshot/Full Refresh message for a spot L2 order book. It contains two entries: an offer (MDEntryType=1) and a bid (MDEntryType=0) for BTC/USD, with prices, sizes, and times. ```plaintext 8=FIX.4.4|9=208|35=W|34=21|49=KRAKEN-MD|52=20230707-13:49:11.245|56=MYCOMPID|55=BTC/USD|262=3|268=2|269=1|278=O30300.0|270=30300.0|271=8.44867022|273=13:49:07.307|269=0|278=B30299.9|270=30299.9|271=0.67373926|273=13:49:10.179|10=254| ``` -------------------------------- ### Raw HTTP GET request to /affiliate/v1/daily-activity Source: https://docs.kraken.com/exchange/guides/affiliate/rest Shows the equivalent HTTP GET request with query parameters for IIBANs, start and end dates, and a limit. This is the raw request format for the endpoint. ```http GET /affiliate/v1/daily-activity?iiban=AA45N84GQK2VUN7A,CC34N84GQK2VUN7C&start_date=2026-08-20&end_date=2026-09-16&limit=50 ``` -------------------------------- ### Go Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/logon Go implementation of the FIX Logon password generation function. ```go ```go package main import ( "crypto/hmac" "crypto/sha256" "crypto/sha512" "encoding/base64" "fmt" "strconv" "time" ) const SOH = "\x01" func getPassword(msgSeqNum, senderCompID, apiKey, apiSecret string) (password, nonce string, err error) { nonce = strconv.FormatInt(time.Now().UnixMilli(), 10) messageInput := "35=A" + SOH + "34=" + msgSeqNum + SOH + "49=" + senderCompID + SOH + "56=KRAKEN-TRD" + SOH + "553=" + apiKey + SOH sha256Hash := sha256.Sum256([]byte(messageInput + nonce)) secretBytes, err := base64.StdEncoding.DecodeString(apiSecret) if err != nil { return "", "", fmt.Errorf("failed to decode API secret: %w", err) } mac := hmac.New(sha512.New, secretBytes) mac.Write(sha256Hash[:]) password = base64.StdEncoding.EncodeToString(mac.Sum(nil)) return password, nonce, nil } ``` ``` -------------------------------- ### Java Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/logon Java implementation of the FIX Logon password generation function. ```java ```java import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.security.MessageDigest; import java.util.Base64; public class FIXAuth { private static final char SOH = '\u0001'; public static String[] getPassword( String msgSeqNum, String senderCompId, String apiKey, String apiSecret) throws Exception { String nonce = String.valueOf(System.currentTimeMillis()); String messageInput = "35=A" + SOH + "34=" + msgSeqNum + SOH + "49=" + senderCompId + SOH + "56=KRAKEN-TRD" + SOH + "553=" + apiKey + SOH; byte[] sha256Hash = MessageDigest .getInstance("SHA-256") .digest((messageInput + nonce).getBytes("UTF-8")); Mac hmac = Mac.getInstance("HmacSHA512"); hmac.init(new SecretKeySpec(Base64.getDecoder().decode(apiSecret), "HmacSHA512")); String password = Base64.getEncoder().encodeToString(hmac.doFinal(sha256Hash)); return new String[]{ password, nonce }; } } ``` ``` -------------------------------- ### Get WebSocket Token in Node.js Source: https://docs.kraken.com/exchange/guides/websockets/authentication Node.js example using fetch to call the GetWebSocketsToken endpoint. It signs the request with HMAC-SHA512 and returns the token. Replace YOUR_API_KEY and YOUR_API_SECRET with your credentials. ```javascript const crypto = require('crypto'); const querystring = require('querystring'); function getKrakenSignature(urlPath, data, secret) { const encoded = data.nonce + querystring.stringify(data); const sha256Hash = crypto.createHash('sha256').update(encoded).digest(); const message = urlPath + sha256Hash.toString('binary'); const secretBuffer = Buffer.from(secret, 'base64'); const hmac = crypto.createHmac('sha512', secretBuffer); hmac.update(message, 'binary'); return hmac.digest('base64'); } async function getWebSocketToken(apiKey, apiSecret) { const nonce = Date.now().toString(); const data = { nonce }; const signature = getKrakenSignature('/0/private/GetWebSocketsToken', data, apiSecret); const response = await fetch('https://api.kraken.com/0/private/GetWebSocketsToken', { method: 'POST', headers: { 'API-Key': apiKey, 'API-Sign': signature, 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(data), }); const result = await response.json(); return result.result.token; } const token = await getWebSocketToken('YOUR_API_KEY', 'YOUR_API_SECRET'); console.log('Token:', token); ``` -------------------------------- ### Python Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/logon Python implementation of the FIX Logon password generation function. ```python ```python import base64 import hashlib import hmac import time SOH = "\x01" def get_password(msg_seq_num: str, sender_comp_id: str, api_key: str, api_secret: str): nonce = str(int(time.time() * 1000)) message_input = ( f"35=A{SOH}" f"34={msg_seq_num}{SOH}" f"49={sender_comp_id}{SOH}" f"56=KRAKEN-TRD{SOH}" f"553={api_key}{SOH}" ) sha256_hash = hashlib.sha256((message_input + nonce).encode("utf-8")).digest() hmac_hash = hmac.new(base64.b64decode(api_secret), sha256_hash, hashlib.sha512) password = base64.b64encode(hmac_hash.digest()).decode("utf-8") return password, nonce ``` ``` -------------------------------- ### C# Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/logon C# implementation of the FIX Logon password generation function. ```csharp ```csharp using System; using System.Security.Cryptography; using System.Text; public static class FIXAuth { private const char SOH = '\x01'; public static (string Password, string Nonce) GetPassword( string msgSeqNum, string senderCompId, string apiKey, string apiSecret) { string nonce = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); string messageInput = $"35=A{SOH}" + $"34={msgSeqNum}{SOH}" + $"49={senderCompId}{SOH}" + $"56=KRAKEN-TRD{SOH}" + $"553={apiKey}{SOH}"; byte[] sha256Hash = SHA256.HashData(Encoding.UTF8.GetBytes(messageInput + nonce)); using var hmac = new HMACSHA512(Convert.FromBase64String(apiSecret)); string password = Convert.ToBase64String(hmac.ComputeHash(sha256Hash)); return (password, nonce); } } ``` ``` -------------------------------- ### Get WebSocket Token in Python Source: https://docs.kraken.com/exchange/guides/websockets/authentication Python example using requests to call the GetWebSocketsToken endpoint. It signs the request with HMAC-SHA512 and prints the token. Replace YOUR_API_KEY and YOUR_API_SECRET with your credentials. ```python import urllib.parse import hashlib import hmac import base64 import time import requests def get_kraken_signature(urlpath, data, secret): encoded = (str(data["nonce"]) + urllib.parse.urlencode(data)).encode() message = urlpath.encode() + hashlib.sha256(encoded).digest() mac = hmac.new(base64.b64decode(secret), message, hashlib.sha512) return base64.b64encode(mac.digest()).decode() api_key = "YOUR_API_KEY" api_secret = "YOUR_API_SECRET" nonce = str(int(time.time() * 1000)) data = {"nonce": nonce} headers = { "API-Key": api_key, "API-Sign": get_kraken_signature("/0/private/GetWebSocketsToken", data, api_secret), } response = requests.post( "https://api.kraken.com/0/private/GetWebSocketsToken", headers=headers, data=data, ) token = response.json()["result"]["token"] print(f"Token: {token}") ``` -------------------------------- ### Example JSON response from /affiliate/v1/daily-activity Source: https://docs.kraken.com/exchange/guides/affiliate/rest Shows a sample response containing dated activity for one trader and an undated stub for an opted-out user. The response includes currency, generated_at, items, and limit. Note that opted-out stubs omit the iiban and activity_date. ```json { "currency": "USD", "generated_at": "2026-09-17T12:01:04Z", "items": [ { "masked_iiban": "UN7A", "referee_reference": "jsd6ggr6qjrzmemn", "plans": [ { "referral_code": "EXAMPLE1", "referral_level": 1, "enrolled_at": "2026-03-14T09:00:00Z", "status": "active", "earning": true, "products": { "spot_trading": { "volume": "42110.20", "fees": "38.20", "commission": "11.46", "event_count": 12 } } } ], "iiban": "AA45N84GQK2VUN7A", "activity_date": "2026-09-16" }, { "referee_reference": "example_opted_out_user", "opted_out": true, "enrolled_at": "2026-08-20T09:00:00Z", "plans": [ { "referral_code": "EXAMPLE1" } ] } ], "limit": 50 } ``` -------------------------------- ### Node.js Example Source: https://docs.kraken.com/exchange/api-reference/unified-fix/logon Node.js implementation of the FIX Logon password generation function. ```javascript ```javascript const crypto = require('crypto'); const SOH = '\x01'; function getPassword(msgSeqNum, senderCompId, apiKey, apiSecret) { const nonce = Date.now().toString(); const messageInput = `35=A${SOH}` + `34=${msgSeqNum}${SOH}` + `49=${senderCompId}${SOH}` + `56=KRAKEN-TRD${SOH}` + `553=${apiKey}${SOH}`; const sha256Hash = crypto .createHash('sha256') .update(messageInput + nonce, 'utf8') .digest(); const password = crypto .createHmac('sha512', Buffer.from(apiSecret, 'base64')) .update(sha256Hash) .digest('base64'); return { password, nonce }; } ``` ``` -------------------------------- ### Fetch OHLCV candles with GET /0/public/OHLC Source: https://docs.kraken.com/exchange/guides/general/historical-data Fetches OHLCV candles for the XBTUSD pair with a daily interval starting from the given Unix timestamp. The `since` parameter is optional and defaults to the oldest available candle. ```http GET /0/public/OHLC?pair=XBTUSD&interval=1440&since=1700000000 ``` -------------------------------- ### Python: Query full referral roster with all_users=true Source: https://docs.kraken.com/exchange/guides/affiliate/rest Python helper call to retrieve the full roster. Pass the query value as the lowercase string "true". The response includes active_users, totals, and revision for trading activity; quiet users do not increase them. ```python page = signed_rest_request( "GET", "/affiliate/v1/daily-activity", {"activity_date": "2026-09-16", "all_users": "true", "limit": 50}, ) ``` -------------------------------- ### Resend Request (server → client) FIX message Source: https://docs.kraken.com/exchange/api-reference/unified-fix/resend-request Example of a Resend Request message (35=2) sent from the server to the client. It requests retransmission of messages starting from sequence number 8 to the end (EndSeqNo=0). ```plaintext 8=FIX.4.4|9=58|35=2|34=114|49=KRAKEN-MD|56=damien|52=20260407-20:23:52.000|7=8|16=0|10=142| ``` -------------------------------- ### HTTP GET: Full referral roster request with all_users=true Source: https://docs.kraken.com/exchange/guides/affiliate/rest Add all_users=true to include quiet users enrolled by the activity date, even if they signed up more than 90 days ago. The activity date must still be within the last 90 UTC days. Use the same date and all_users=true when following next_cursor. ```http GET /affiliate/v1/daily-activity?activity_date=2026-09-16&all_users=true&limit=50 ``` -------------------------------- ### Asks string (low to high) Source: https://docs.kraken.com/exchange/guides/websockets/book-checksum-v2 The asks string built from the example snapshot: for each of the top 10 ask levels sorted by price low to high, remove '.' and leading zeros from price and qty, then append price+qty. ```text 45285210000045286415457195345286615457110945289615456091145290215890660452918154553491452947445474945296135380000452975994554245299518772827 ``` -------------------------------- ### Error Message Format Example Source: https://docs.kraken.com/exchange/guides/rest/introduction Example of an error message format, showing severity 'E' for error, category 'General', and a description. ```text i.e., "EGeneral: Invalid arguments:ordertype" ``` -------------------------------- ### Status update example Source: https://docs.kraken.com/exchange/api-reference/spot-websocket-v2/status Example of a status update message received on the status channel. The system field reports the current status, here "online". ```json { "channel": "status", "data": [ { "api_version": "v2", "connection_id": 13834774380200032777, "system": "online", "version": "2.0.0" } ], "type": "update" } ``` -------------------------------- ### cancel_order Request Example Source: https://docs.kraken.com/exchange/api-reference/spot-websocket-v2/cancel_order Example request to cancel two orders by their Kraken order_id identifiers. Requires an authentication token. The req_id is optional and echoed in the response. ```json { "method": "cancel_order", "params": { "order_id": [ "OM5CRX-N2HAL-GFGWE9", "OLUMT4-UTEGU-ZYM7E9" ], "token": "zGXT1dUQQjJjy5VmGXMegdDQngXXehNo5qbMBVolwEQ" }, "req_id": 123456789 } ``` -------------------------------- ### Python: Query daily activity with signed_rest_request Source: https://docs.kraken.com/exchange/guides/affiliate/rest Use this Python helper to fetch daily activity for a specific date. The date must be today or within the previous 89 UTC days; otherwise a 400 error is returned. The response includes activity_date, active_users, currency, and items with referee_reference, masked_iiban, and opted_out flags. ```python page = signed_rest_request( "GET", "/affiliate/v1/daily-activity", {"activity_date": "2026-09-16", "limit": 50}, ) print(page["activity_date"], page.get("active_users", 0), page["currency"]) for item in page.get("items", []): print(item["referee_reference"], item.get("masked_iiban"), item.get("opted_out", False)) ``` -------------------------------- ### Error Response Example Source: https://docs.kraken.com/exchange/api-reference/futures-websocket/ticker Example JSON response for an error event. The event field is 'error' and the message field contains an error message such as 'Invalid product id'. ```json { "event": "error", "message": "Invalid product id" } ```