Kraken API Bot Integration
Kraken — one of the oldest and most regulated cryptocurrency exchanges. The API is well-documented, stable, with support for advanced orders. Key feature: non-standard pair names (XXBTZUSD instead of BTC/USDT) and specific nonce requirement for REST requests.
Kraken API Specifics
Authentication: each private request is signed with HMAC-SHA512. Kraken requires nonce — a monotonically increasing number (usually timestamp in milliseconds). Important: nonce must be strictly greater than the previous one, otherwise EAPI:Invalid nonce.
import ccxt
exchange = ccxt.kraken({
'apiKey': API_KEY,
'secret': API_SECRET,
})
# CCXT handles nonce and signature automatically
ticker = exchange.fetch_ticker('BTC/USD')
print(f"Last price: {ticker['last']}")
# Place limit order
order = exchange.create_order(
symbol='BTC/USD',
type='limit',
side='buy',
amount=0.001,
price=60000,
params={'oflags': 'post'} # post-only flag
)
WebSocket API v2
Kraken has WebSocket API v2 for real-time data:
import websockets
import json
async def subscribe_kraken():
async with websockets.connect('wss://ws.kraken.com/v2') as ws:
await ws.send(json.dumps({
"method": "subscribe",
"params": {
"channel": "ticker",
"symbol": ["BTC/USD", "ETH/USD"]
}
}))
async for message in ws:
data = json.loads(message)
if data.get('channel') == 'ticker':
process_ticker(data['data'])
Rate Limits
Kraken uses tier-based rate limiting. Basic tier: 15 units, recovery 0.33/sec. Different calls cost different units (order placement = 1, cancel = 0). When exceeded — EAPI:Rate limit exceeded.
Mitigation: CCXT built-in rate limiter, plus separate logic for critical operations.
Kraken API integration for trading bot: 1–2 weeks including testing on sandbox and handling exchange-specific errors.







