Moving from a working integration to a production-grade one involves a handful of deliberate choices that pay compounding dividends over time. The patterns below reflect what matters most when your code is running live, where a silent assumption or a poorly handled reconnect can translate directly into missed fills, duplicate orders, or exposure you didn’t intend. Work through them before your first live trade.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sieblyio/kraken-api/llms.txt
Use this file to discover all available pages before exploring further.
Use client-generated order IDs
Every order you place should carry a client-assigned ID that your system generates before the request leaves your process. This makes retries idempotent: if a request times out and you don’t know whether Kraken received it, you can query by your own ID rather than guessing. It also gives you a durable correlation key across REST responses, WebSocket execution events, and your own internal records. The SDK exposesgenerateNewOrderID() on both SpotClient and DerivativesClient. The parameter name differs between products:
- Spot REST / WebSocket API:
cl_ord_id - Futures (Derivatives):
cliOrdId
Handle reconnects gracefully
WebSocket connections drop. This happens more frequently during high-volatility market sessions, exchange maintenance windows, or transient network interruptions. The SDK detects disconnections via heartbeat timeouts and handles reconnection automatically — reopening the connection, re-authenticating if needed, and resubscribing to all previously active topics. Your job is to keep your application state coherent across the gap. The SDK emits two events that bracket the reconnect window:reconnecting → reconnected cycle is a normal operating condition, not an error. Design your backfill logic to be fast and reliable: query open orders, current positions, and recent fills via REST as soon as reconnected fires, hydrate your internal state, and only then re-enable order placement.
Rollout strategy
Introducing a new integration to a live system is safest when done in layers. Each layer validates the previous one before you increase surface area or financial exposure:Public REST APIs
Start with unauthenticated endpoints: server time, system status, tickers, order books. This confirms your network routing, proxy configuration (if any), and basic response parsing without any credential risk.
Public WebSocket streams
Subscribe to public topics (
ticker, book, trade) and confirm that events flow correctly, reconnect handling fires as expected, and your message processing logic handles the data shape correctly.Private account streams
Add credentials and subscribe to private topics (
executions, balances). Confirm authentication succeeds, the authenticated event fires, and account state updates arrive correctly. Do not place any orders yet.Validated orders
Use
validate: true on Spot orders to test your order construction logic without submitting live orders. For Futures, use testnet: true on DerivativesClient to route to Kraken’s demo environment.Symbol conventions
Spot and Futures use different symbol formats, and they are not interchangeable. Mixing them up silently produces wrong results — your code may accept the string without complaining but route the request to the wrong instrument or fail with a confusing exchange error.| Product | Context | Format | Examples |
|---|---|---|---|
| Spot | REST API | Kraken pair notation | XBTUSD, ETHUSD, XBTZEUR |
| Spot | WebSocket V2 | BASE/QUOTE slash notation | BTC/USD, ETH/USD, XBT/EUR |
| Futures | REST & WebSocket | Prefixed instrument names | PF_XBTUSD (perpetual), PI_ETHUSD (inverse perpetual), FF_XBTUSD (fixed-date) |
Credential security
Minimum required permissions
Kraken API keys support granular permission sets. Grant only what each key actually needs:| Use case | Required permissions |
|---|---|
| Market data only | None (public endpoints) |
| Account balance queries | Query funds |
| Order queries | Query open orders & trades |
| Order placement | Orders and trades |
| Withdrawals | Withdraw funds — only if explicitly required |
IP whitelisting
Lock each API key to the IP address (or CIDR range) of the server that uses it. Kraken supports this in the API key management panel. A stolen key that cannot originate requests from your server’s IP is useless to an attacker.Key rotation
Treat API keys like passwords: rotate them periodically, and immediately upon any suspicion of compromise. The rotation process is:- Create a new key with the same permissions as the one being replaced.
- Update your environment variables or secrets manager with the new credentials.
- Restart your service to pick up the new credentials.
- Revoke the old key in the Kraken API management panel.
Environment variables, not hardcoded strings
Never place API credentials in source code or commit them to version control. Use environment variables and a secrets manager in production:--env-file loads a .env file without a third-party dependency:
.env file out of version control with a .gitignore entry.
Proxy support
If your production environment requires outbound HTTP traffic to route through a proxy — common in corporate networks, VPCs with restricted egress, or compliance-controlled environments — passproxy (or a fully configured httpsAgent) via the networkOptions second argument to any REST client constructor:
axios as AxiosRequestConfig, so any configuration option supported by axios (custom httpsAgent, per-request timeouts, custom headers) is available here.