Kraken API - LabMazurokCom/Blockchain GitHub Wiki
Intro
Website: https://www.kraken.com
Documentation: https://www.kraken.com/help/api
Limits: Tier 2 users have a maximum of 15 and their count gets reduced by 1 every 3 seconds.
Fee used in bot: 0.26% (taker fee for monthly volume less than 50K USD)
List of symbols
https://api.kraken.com/0/public/AssetPairs
Order book
https://api.kraken.com/0/public/Depth?pair=XBTEUR&count=50
Request keys
Parameter | Meaning |
---|---|
pair | asset pair to get market depth for |
count | maximum number of asks/bids (optional) |
Response
{
"error": [],
"result": {
"XXBTZEUR": {
"asks": [
["7590.00000", "0.013", 1525271993],
["7592.30000", "0.100", 1525271993],
["7592.40000", "0.300", 1525271995]
],
"bids": [
["7589.90000", "0.500", 1525271991],
["7589.80000", "3.941", 1525271983],
["7589.00000", "0.821", 1525271991]
]
}
}
}
Parameter | Meaning |
---|---|
asks | ask side array of array entries(price, volume, timestamp) |
bids | bid side array of array entries(price, volume, timestamp) |
Ticker
https://api.kraken.com/0/public/Ticker?pair=XBTEUR
N.B. Today's prices start at 00:00:00 UTC
Response
{
"error": [],
"result": {
"XXBTZEUR": {
"a": ["7592.00000", "1", "1.000"],
"b": ["7590.80000", "1", "1.000"],
"c": ["7592.00000", "0.00249660"],
"v": ["2944.26372773", "4960.34928458"],
"p": ["7589.95666", "7554.16852"],
"t": [17281, 27218],
"l": ["7477.00000", "7402.20000"],
"h": ["7655.50000", "7655.50000"],
"o": "7541.10000"
}
}
}
Parameter | Meaning |
---|---|
a | ask array(price, whole lot volume, lot volume), |
b | bid array(price, whole lot volume, lot volume), |
c | last trade closed array(price, lot volume), |
v | volume array(today, last 24 hours), |
p | volume weighted average price array(today, last 24 hours), |
t | number of trades array(today, last 24 hours), |
l | low array(today, last 24 hours), |
h | high array(today, last 24 hours), |
o | today's opening price |
Order types
Market order
Buy (or sell) at the best average market price.
Limit order
Buy (or sell) at a fixed price (or better). Can be executed partially
Currency limits
Currency | Order minimum |
---|---|
Augur (REP) | 0.3 |
Bitcoin (XBT) | 0.002 |
Bitcoin Cash (BCH) | 0.002 |
Dash (DASH) | 0.03 |
Dogecoin (DOGE) | 3000 |
EOS (EOS) | 3 |
Ethereum (ETH) | 0.02 |
Ethereum Classic (ETC) | 0.3 |
Gnosis (GNO) | 0.03 |
Iconomi (ICN) | 2 |
Litecoin (LTC) | 0.1 |
Melon (MLN) | 0.1 |
Monero (XMR) | 0.1 |
Ripple (XRP) | 30 |
Stellar Lumens (XLM) | 30 |
Zcash (ZEC) | 0.03 |
Tether (USDT) | 5 |
Fees
https://api.kraken.com/0/public/AssetPairs
Response:
fees = fee schedule array in [volume, percent fee] tuples
fees_maker = maker fee schedule array in [volume, percent fee] tuples (if on maker/taker)
Private API request example
import requests
import hashlib
import hmac
import time
import urllib
import base64
api_key='API_KEY'
api_secret='API_SECRET'
nonce = int(1000 * time.time())
endpoint = "https://api.kraken.com"
req = "/0/private/Balance"
data = {}
data['nonce'] = nonce
url = endpoint + req
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce']) + postdata).encode()
msg = req.encode() + hashlib.sha256(encoded).digest()
H = hmac.new(base64.b64decode(api_secret), msg, hashlib.sha512)
sign = (base64.b64encode(H.digest())).decode()
headers = {
'API-key': api_key,
'API-sign': sign
}
r = requests.post(url, data=data, headers=headers)
print(r.text)