Download OpenAPI specification:Download
This document details use of Kraken's REST API for our Spot exchange. The Spot exchange Websockets API and the Kraken Futures APIs are documented separately. Our REST API is organised into publicly accessible endpoints (market data, exchange status, etc.), and private authenticated endpoints (trading, funding, user data) which require requests to be signed.
Your use of the Kraken REST API is subject to the Kraken Terms & Conditions, Privacy Notice, as well as all other applicable terms and disclosures made available on www.kraken.com.
Further information and FAQs may be found on the API section of our support pages. If you have trouble making any standard requests that our system permits, please send us a ticket with a full copy of the request(s) that you're attempting, including your IP address and all headers, so that we may investigate further.
Request payloads are form-encoded (Content-Type: application/x-www-form-urlencoded
), and all requests must specify a User-Agent
in their headers.
Responses are JSON encoded and contain one or two top-level keys (result
and error
for successful requests or those with warnings, or only error
for failed or rejected requests)
{
"error": [],
"result": {
"status": "online",
"timestamp": "2021-03-22T17:18:03Z"
}
}
{
"error": [
"EGeneral:Invalid arguments:ordertype"
]
}
HTTP status codes are generally not used by our API to convey information about the state of requests -- any errors or warnings are denoted in the error
field of the response as described above. Status codes other than 200 indicate that there was an issue with the request reaching our servers.
error
messages follow the general format <severity><category>
:<error msg>
[:add'l text
]
severity
can be either E
for error or W
for warningcategory
can be one of General
, Auth
, API
, Query
, Order
, Trade
, Funding
, or Service
error msg
can be any text string that describes the reason for the errorError | Additional Info |
---|---|
EGeneral:Invalid arguments | The request payload is malformed, incorrect or ambiguous |
EGeneral:Invalid arguments:Index unavailable | Index pricing is unavailable for stop/profit orders on this pair |
EService:Unavailable | The matching engine or API is offline |
EService:Market in cancel_only mode | Request can't be made at this time (See SystemStatus endpoint) |
EService:Market in post_only mode | Request can't be made at this time (See SystemStatus endpoint) |
EService:Deadline elapsed | The request timed out according to the default or specified deadline |
EAPI:Invalid key | An invalid API-Key header was supplied (see Authentication section) |
EAPI:Invalid signature | An invalid API-Sign header was supplied (see Authentication section) |
EAPI:Invalid nonce | An invalid nonce was supplied (see Authentication section) |
EGeneral:Permission denied | API key doesn't have permission to make this request |
EOrder:Cannot open position | User/tier is ineligible for margin trading |
EOrder:Margin allowance exceeded | User has exceeded their margin allowance |
EOrder:Margin level too low | Client has insufficient equity or collateral |
EOrder:Margin position size exceeded | Client would exceed the maximum position size for this pair |
EOrder:Insufficient margin | Exchange does not have available funds for this margin trade |
EOrder:Insufficient funds | Client does not have the necessary funds |
EOrder:Order minimum not met | Order size does not meet ordermin (See AssetPairs endpoint) |
EOrder:Cost minimum not met | Cost (price * volume) does not meet costmin (See AssetPairs endpoint) |
EOrder:Tick size check failed | Price submitted is not a valid multiple of the pair's tick_size (See AssetPairs endpoint) |
EOrder:Orders limit exceeded | (See Rate Limits section) |
EOrder:Rate limit exceeded | (See Rate Limits section) |
EOrder:Domain rate limit exceeded | (See Rate Limits section) |
EOrder:Positions limit exceeded | |
EOrder:Unknown position | |
EBM:limit exceeded:CAL | Exceeded Canadian Acquisition Limits (CAL) |
EFunding:Max fee exceeded | Processed fee exceeds max_fee set in Withdraw request |
Additional information can be found on our support center.
Authenticated requests must include both API-Key
and API-Sign
HTTP headers, and nonce
in the request payload. otp
is also required in the payload if two-factor authentication (2FA) is enabled.
nonce
Nonce must be an always increasing, unsigned 64-bit integer, for each request that is made with a particular API key. While a simple counter would provide a valid nonce, a more usual method of generating a valid nonce is to use e.g. a UNIX timestamp in milliseconds.
Note: There is no way to reset the nonce for an API key to a lower value, so be sure to use a nonce generation method that won't produce numbers less than the previous nonce. Too many requests with invalid nonces (EAPI:Invalid nonce) can result in temporary bans. Problems can arise from requests arriving out of order due to API keys being shared across processes, or from system clock drift/recalibration. An optional "nonce window" can be configured to specify a tolerance between nonce values. Additional info can be found in our support pages.
otp
If two-factor authentication (2FA) is enabled for the API key and action in question, the one time password must be specified in the payload's otp
value.
All responses will include the x-trace-id
header. This uniquely identifies your request. When contacting support, please include a trace-id where possible.
Authenticated requests should be signed with the "API-Sign" header, using a signature generated with your private key, nonce, encoded payload, and URI path according to:
HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key
The following is a specific example of a signature generated with a particular private key, nonce, and payload corresponding to a new limit order (buy 1.25 XBTUSD at $37,500). If your code is generating a different signature ("API-Sign") for this example, then there is likely an issue with your application of the above methodology. Code snippets for generating the signature in Python, Golang and Node.js follow below.
Field | Value |
---|---|
Private Key | kQH5HW/8p1uGOVjbgWA7FunAmGO8lsSUXNsu3eow76sz84Q18fWxnyRzBHCd3pd5nE9qa99HAZtuZuj6F1huXg== |
Nonce | 1616492376594 |
Encoded Payload | nonce=1616492376594&ordertype=limit&pair=XBTUSD&price=37500&type=buy&volume=1.25 |
URI Path | /0/private/AddOrder |
API-Sign | 4/dpxb3iT4tp/ZCVEwSnEsLxx0bqyhLpdfOpc6fn7OR8+UClSV5n9E6aSS8MPtnRfp32bAb0nmbRn6H8ndwLUQ== |
import urllib.parse
import hashlib
import hmac
import base64
def get_kraken_signature(urlpath, data, secret):
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce']) + postdata).encode()
message = urlpath.encode() + hashlib.sha256(encoded).digest()
mac = hmac.new(base64.b64decode(secret), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
return sigdigest.decode()
api_sec = "kQH5HW/8p1uGOVjbgWA7FunAmGO8lsSUXNsu3eow76sz84Q18fWxnyRzBHCd3pd5nE9qa99HAZtuZuj6F1huXg=="
data = {
"nonce": "1616492376594",
"ordertype": "limit",
"pair": "XBTUSD",
"price": 37500,
"type": "buy",
"volume": 1.25
}
signature = get_kraken_signature("/0/private/AddOrder", data, api_sec)
print("API-Sign: {}".format(signature))
package main
import (
"crypto/hmac"
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
"net/url"
"fmt"
)
func getKrakenSignature(url_path string, values url.Values, secret []byte) string {
sha := sha256.New()
sha.Write([]byte(values.Get("nonce") + values.Encode()))
shasum := sha.Sum(nil)
mac := hmac.New(sha512.New, secret)
mac.Write(append([]byte(url_path), shasum...))
macsum := mac.Sum(nil)
return base64.StdEncoding.EncodeToString(macsum)
}
func main() {
apiSecret := "kQH5HW/8p1uGOVjbgWA7FunAmGO8lsSUXNsu3eow76sz84Q18fWxnyRzBHCd3pd5nE9qa99HAZtuZuj6F1huXg=="
payload := url.Values{}
payload.Add("pair","XBTUSD")
payload.Add("type","buy")
payload.Add("ordertype","limit")
payload.Add("price","37500")
payload.Add("volume","1.25")
payload.Add("nonce","1616492376594")
b64DecodedSecret, _ := base64.StdEncoding.DecodeString(apiSecret)
signature := getKrakenSignature("/0/private/AddOrder", payload, b64DecodedSecret)
fmt.Printf("API-Sign: " + signature +"\n")
}
const crypto = require('crypto');
const qs = require('qs');
const getMessageSignature = (path, request, secret, nonce) => {
const message = qs.stringify(request);
const secret_buffer = new Buffer(secret, 'base64');
const hash = new crypto.createHash('sha256');
const hmac = new crypto.createHmac('sha512', secret_buffer);
const hash_digest = hash.update(nonce + message).digest('binary');
const hmac_digest = hmac.update(path + hash_digest, 'binary').digest('base64');
return hmac_digest;
};
API-Sign
We have various safeguards in place to protect against system abuse, order book manipulation, DDoS attacks, etc. For REST API requests, these are broadly organised into rate limits specific to the REST API, and rate limits which apply to any trading requests.
Note: For clients with performance sensitive applications, we strongly recommend the use of our Websockets API for minimising request latency and receiving real-time information, reducing or eliminating the need to frequently poll REST endpoints.
Every REST API user has a "call counter" which starts at 0
. Ledger/trade history calls increase the counter by 2
. All other API calls increase this counter by 1
(except AddOrder, CancelOrder which operate on a different limiter detailed further below).
Tier | Max API Counter | API Counter Decay |
---|---|---|
Starter | 15 | -0.33/sec |
Intermediate | 20 | -0.5/sec |
Pro | 20 | -1/sec |
The user's counter is reduced every couple of seconds depending on their verification tier. Each API key's counter is separate, and if the counter exceeds the maximum value, subsequent calls using that API key would be rate limited. If the rate limits are reached, additional calls will be restricted for a few seconds (or possibly longer if calls continue to be made while the rate limits are active).
Note: Master accounts and subaccounts will share the same default trading rate limits as determined by the master account's tier.
Additional information can be found on our support center.
Separate limits apply to the number of orders clients may have open in each pair at a time, and the speed with which they may add and cancel orders in each pair. These limits vary by the account verification tier:
Tier | Max Num Orders | Max Ratecount | Ratecount Decay |
---|---|---|---|
Starter | 60 | 60 | -1/sec |
Intermediate | 80 | 125 | -2.34/sec |
Pro | 225 | 180 | -3.75/sec |
The speed is controlled by a ratecounter for each (client, pair) which starts at zero, is incremented when penalties are applied, and decremented according to the decay rates above. A penalty is added to the ratecounter for each new order placed (AddOrder
) or cancelled (CancelOrder
, CancelAll
, CancelAllOrdersAfter
) on the pair. The cancellation penalty varies according to the lifetime of the order.
Action | <5sec | <10sec | <15sec | <45sec | <90sec | <300s | >300s | |
---|---|---|---|---|---|---|---|---|
Add Order | +1 | |||||||
AddOrderBatch*** | +(n/2) | |||||||
Edit Order | +6 | +5 | +4 | +2 | +1 | 0 | 0 | |
Cancel Order | +8 | +6 | +5 | +4 | +2 | +1 | 0 | |
CancelOrderBatch** | +8 | +6 | +5 | +4 | +2 | +1 | 0 |
*** n is number of orders in batch
** Rate limits penalty for CancelOrderBatch will be cumulative sum of individual orders penalty, accumulated upto max ratecount. In case, the cumulative penalty in the batch exceeds max ratecount, cancel requests in batch are still accepted.
Note: A client's exact ratecounter values can be monitored via the Websockets openOrders feed.
Additional information can be found on our support center.
WithdrawMethods
and WithdrawAddresses
endpoints, and start
, end
, and cursor
parameters to WithdrawStatus
.max_fee
parameter to Withdraw
and minimum
field in response for DepositMethods
.start
, end
, and cursor
parameters to DepositStatus
.BalanceEx
documentation.amount
parameter to DepositAddresses
, required for Bitcoin Lightning deposits. Added count
parameter to Trades
.address
parameter to Withdraw
. Added since
parameter to Spread
.originators
paramater to DepositStatus
.AssetPairs
.txid
s and userref
s for CancelOrderBatch
.DepositStatus
and WithdrawStatus
.%2b
instead of +
for URL encoding in AddOrder
starttm
and expiretm
parameters.asset
in DepositStatus
and WithdrawalStatus
.reduce_only
parameter in AddOrder
and AddOrderBatch
.consolidate_taker
to TradesHistory
, ClosedOrders
, and QueryOrders
.CreateSubaccount
and AccountTransfer
endpoints.trade_id
to private TradesHistory
.pair
parameter restriction on TradeVolume
.EditOrder
allowed on margin orders.tick_size
and status
parameters to AssetPairs
, status
and collateral_value
to Assets
, and trade_id
to public Trades
.uv
(unexecuted value) field in TradeBalance
.costmin
trading parameter to AssetPairs
.Ticker
wildcard support - pair
no longer required, no pair
parameter returns tickers for all tradeable exchange assets.AddOrder
/EditOrder
/AddOrderBatch
now support icebergs.AddOrderBatch
endpoint to send multiple new orders and CancelOrderBatch
endpoint to cancel multiple open orders.EditOrder
endpoint to edit volume and price on open orders.AddOrder
support for optional parameter trigger
and values last
(last traded price) and index
.Note: Most changes affecting our APIs or trading engine behaviour are currently being tracked on our Websockets changelog, until these documents are combined.
In order to achieve maximum performance, security and flexibility for your particular needs, we strongly encourage the implementation of this API with your own code, and to minimise reliance on third party software.
That being said, in order to aid with rapid development and prototyping, we're in the process of producing 'official' API clients in Python and Golang that will be actively maintained, coincident with the release of newer versions of both our Websockets and REST APIs. In the meantime, our Client Engagement team has compiled a number of code snippets, examples and Postman collections that many find useful.
Below are other third party API client code libraries that may be used when writing your own API client. Please keep in mind that Payward nor the third party authors are responsible for losses due to bugs or improper use of the APIs. Payward has performed an initial review of the safety of the third party code before listing them but cannot vouch for any changes added since then, or for those that may be stale. If you have concerns, please contact support.
Language | Link |
---|---|
C++ | https://github.com/voidloop/krakenapi |
Golang | https://github.com/Beldur/kraken-go-api-client |
NodeJS | https://github.com/nothingisdead/npm-kraken-api |
Python 3 | https://github.com/veox/python3-krakenex |
Python 2 | https://github.com/veox/python2-krakenex |
Other
Get the server's time.
object (ServerTime) | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Time"
{- "error": [ ],
- "result": {
- "unixtime": 1688669448,
- "rfc1123": "Thu, 06 Jul 23 18:50:48 +0000"
}
}
Get the current system status or trading mode.
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/SystemStatus"
{- "error": [ ],
- "result": {
- "status": "online",
- "timestamp": "2023-07-06T18:52:00Z"
}
}
Get information about the assets that are available for deposit, withdrawal, trading and staking.
asset | string Example: asset=XBT,ETH Comma delimited list of assets to get info on (optional, default all available assets) |
aclass | string Example: aclass=currency Asset class (optional, default: |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Assets"
{- "error": [ ],
- "result": {
- "XXBT": {
- "aclass": "currency",
- "altname": "XBT",
- "decimals": 10,
- "display_decimals": 5,
- "collateral_value": 1,
- "status": "enabled"
}, - "ZEUR": {
- "aclass": "currency",
- "altname": "EUR",
- "decimals": 4,
- "display_decimals": 2,
- "collateral_value": 1,
- "status": "enabled"
}, - "ZUSD": {
- "aclass": "currency",
- "altname": "USD",
- "decimals": 4,
- "display_decimals": 2,
- "collateral_value": 1,
- "status": "enabled"
}
}
}
Get tradable asset pairs
pair | string Example: pair=BTC/USD,ETH/BTC Asset pairs to get data for |
info | string Default: "info" Enum: "info" "leverage" "fees" "margin" Info to retrieve (optional)
|
object Pair names and their info | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/AssetPairs?pair=XXBTZUSD,XETHXXBT"
{- "error": [ ],
- "result": {
- "XETHXXBT": {
- "altname": "ETHXBT",
- "wsname": "ETH/XBT",
- "aclass_base": "currency",
- "base": "XETH",
- "aclass_quote": "currency",
- "quote": "XXBT",
- "lot": "unit",
- "cost_decimals": 6,
- "pair_decimals": 5,
- "lot_decimals": 8,
- "lot_multiplier": 1,
- "leverage_buy": [
- 2,
- 3,
- 4,
- 5
], - "leverage_sell": [
- 2,
- 3,
- 4,
- 5
], - "fees": [
- [
- 0,
- 0.26
], - [
- 50000,
- 0.24
], - [
- 100000,
- 0.22
], - [
- 250000,
- 0.2
], - [
- 500000,
- 0.18
], - [
- 1000000,
- 0.16
], - [
- 2500000,
- 0.14
], - [
- 5000000,
- 0.12
], - [
- 10000000,
- 0.1
]
], - "fees_maker": [
- [
- 0,
- 0.16
], - [
- 50000,
- 0.14
], - [
- 100000,
- 0.12
], - [
- 250000,
- 0.1
], - [
- 500000,
- 0.08
], - [
- 1000000,
- 0.06
], - [
- 2500000,
- 0.04
], - [
- 5000000,
- 0.02
], - [
- 10000000,
- 0
]
], - "fee_volume_currency": "ZUSD",
- "margin_call": 80,
- "margin_stop": 40,
- "ordermin": "0.01",
- "costmin": "0.00002",
- "tick_size": "0.00001",
- "status": "online",
- "long_position_limit": 1100,
- "short_position_limit": 400
}, - "XXBTZUSD": {
- "altname": "XBTUSD",
- "wsname": "XBT/USD",
- "aclass_base": "currency",
- "base": "XXBT",
- "aclass_quote": "currency",
- "quote": "ZUSD",
- "lot": "unit",
- "cost_decimals": 5,
- "pair_decimals": 1,
- "lot_decimals": 8,
- "lot_multiplier": 1,
- "leverage_buy": [
- 2,
- 3,
- 4,
- 5
], - "leverage_sell": [
- 2,
- 3,
- 4,
- 5
], - "fees": [
- [
- 0,
- 0.26
], - [
- 50000,
- 0.24
], - [
- 100000,
- 0.22
], - [
- 250000,
- 0.2
], - [
- 500000,
- 0.18
], - [
- 1000000,
- 0.16
], - [
- 2500000,
- 0.14
], - [
- 5000000,
- 0.12
], - [
- 10000000,
- 0.1
]
], - "fees_maker": [
- [
- 0,
- 0.16
], - [
- 50000,
- 0.14
], - [
- 100000,
- 0.12
], - [
- 250000,
- 0.1
], - [
- 500000,
- 0.08
], - [
- 1000000,
- 0.06
], - [
- 2500000,
- 0.04
], - [
- 5000000,
- 0.02
], - [
- 10000000,
- 0
]
], - "fee_volume_currency": "ZUSD",
- "margin_call": 80,
- "margin_stop": 40,
- "ordermin": "0.0001",
- "costmin": "0.5",
- "tick_size": "0.1",
- "status": "online",
- "long_position_limit": 250,
- "short_position_limit": 200
}
}
}
Note: Today's prices start at midnight UTC. Leaving the pair parameter blank will return tickers for all tradeable assets on Kraken.
pair | string Example: pair=XBTUSD Asset pair to get data for (optional, default: all tradeable exchange pairs) |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Ticker?pair=XBTUSD"
{- "error": [ ],
- "result": {
- "XXBTZUSD": {
- "a": [
- "30300.10000",
- "1",
- "1.000"
], - "b": [
- "30300.00000",
- "1",
- "1.000"
], - "c": [
- "30303.20000",
- "0.00067643"
], - "v": [
- "4083.67001100",
- "4412.73601799"
], - "p": [
- "30706.77771",
- "30689.13205"
], - "t": [
- 34619,
- 38907
], - "l": [
- "29868.30000",
- "29868.30000"
], - "h": [
- "31631.00000",
- "31631.00000"
], - "o": "30502.80000"
}
}
}
Note: the last entry in the OHLC array is for the current, not-yet-committed frame and will always be present, regardless of the value of since
.
pair required | string Example: pair=XBTUSD Asset pair to get data for |
interval | integer Default: 1 Enum: 1 5 15 30 60 240 1440 10080 21600 Example: interval=60 Time frame interval in minutes |
since | integer Example: since=1548111600 Return up to 720 OHLC data points since given timestamp |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/OHLC?pair=XBTUSD"
{- "error": [ ],
- "result": {
- "XXBTZUSD": [
- [
- 1688671200,
- "30306.1",
- "30306.2",
- "30305.7",
- "30305.7",
- "30306.1",
- "3.39243896",
- 23
], - [
- 1688671260,
- "30304.5",
- "30304.5",
- "30300.0",
- "30300.0",
- "30300.0",
- "4.42996871",
- 18
], - [
- 1688671320,
- "30300.3",
- "30300.4",
- "30291.4",
- "30291.4",
- "30294.7",
- "2.13024789",
- 25
], - [
- 1688671380,
- "30291.8",
- "30295.1",
- "30291.8",
- "30295.0",
- "30293.8",
- "1.01836275",
- 9
]
], - "last": 1688672160
}
}
pair required | string Example: pair=XBTUSD Asset pair to get data for |
count | integer [ 1 .. 500 ] Default: 100 Example: count=2 Maximum number of asks/bids |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Depth?pair=XBTUSD"
{- "error": [ ],
- "result": {
- "XXBTZUSD": {
- "asks": [
- [
- "30384.10000",
- "2.059",
- 1688671659
], - [
- "30387.90000",
- "1.500",
- 1688671380
], - [
- "30393.70000",
- "9.871",
- 1688671261
]
], - "bids": [
- [
- "30297.00000",
- "1.115",
- 1688671636
], - [
- "30296.70000",
- "2.002",
- 1688671674
], - [
- "30289.80000",
- "5.001",
- 1688671673
]
]
}
}
}
Returns the last 1000 trades by default
pair required | string Example: pair=XBTUSD Asset pair to get data for |
since | string Example: since=1616663618 Return trade data since given timestamp |
count | integer [ 1 .. 1000 ] Default: 1000 Example: count=2 Return specific number of trades, up to 1000 |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Trades?pair=XBTUSD"
{- "error": [ ],
- "result": {
- "XXBTZUSD": [
- [
- "30243.40000",
- "0.34507674",
- 1688669597.8277369,
- "b",
- "m",
- "",
- 61044952
], - [
- "30243.30000",
- "0.00376960",
- 1688669598.2804112,
- "s",
- "l",
- "",
- 61044953
], - [
- "30243.30000",
- "0.01235716",
- 1688669602.698379,
- "s",
- "m",
- "",
- 61044956
]
], - "last": "1688671969993150842"
}
}
Returns the last ~200 top-of-book spreads for a given pair
pair required | string Example: pair=XBTUSD Asset pair to get data for |
since | integer Example: since=1678219570 Returns spread data since given timestamp. Optional, intended for incremental updates within available dataset (does not contain all historical spreads). |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Spread?pair=XBTUSD"
{- "error": [ ],
- "result": {
- "XXBTZUSD": [
- [
- 1688671834,
- "30292.10000",
- "30297.50000"
], - [
- 1688671834,
- "30292.10000",
- "30296.70000"
], - [
- 1688671834,
- "30292.70000",
- "30296.70000"
]
], - "last": 1688672106
}
}
Retrieve all cash balances, net of pending withdrawals.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
object (AccountBalance) Account Balance | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/Balance" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>"
{- "error": [ ],
- "result": {
- "ZUSD": "171288.6158",
- "ZEUR": "504861.8946",
- "XXBT": "1011.1908877900",
- "XETH": "818.5500000000",
- "USDT": "500000.00000000",
- "DAI": "9999.9999999999",
- "DOT": "2.5000000000",
- "ETH2.S": "198.3970800000",
- "ETH2": "2.5885574330",
- "USD.M": "1213029.2780"
}
}
Retrieve all extended account balances, including credits and held amounts. Balance available for trading is calculated as: available balance = balance + credit - credit_used - hold_trade
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
object (ExtendedBalance) Extended Balance | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/BalanceEx" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>"
{- "error": [ ],
- "result": {
- "ZUSD": {
- "balance": 25435.21,
- "hold_trade": 8249.76
}, - "XXBT": {
- "balance": 1.2435,
- "hold_trade": 0.8423
}
}
}
Retrieve a summary of collateral balances, margin position valuations, equity and margin level.
API Key Permissions Required: Orders and trades - Query open orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Default: "ZUSD" Base asset used to determine balance |
object (AccountBalance) Account Balance | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/TradeBalance" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&asset=ZUSD"
{- "error": [ ],
- "result": {
- "eb": "1101.3425",
- "tb": "392.2264",
- "m": "7.0354",
- "n": "-10.0232",
- "c": "21.1063",
- "v": "31.1297",
- "e": "382.2032",
- "mf": "375.1678",
- "ml": "5432.57"
}
}
Retrieve information about currently open orders.
API Key Permissions Required: Orders and trades - Query open orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
trades | boolean Default: false Whether or not to include trades related to position in output |
userref | integer <int32> Restrict results to given user reference id |
object (OpenOrders) Open Orders | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/OpenOrders" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&trades=true"
{- "error": [ ],
- "result": {
- "open": {
- "OQCLML-BW3P3-BUCMWZ": {
- "refid": "None",
- "userref": 0,
- "status": "open",
- "opentm": 1688666559.8974,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTUSD",
- "type": "buy",
- "ordertype": "limit",
- "price": "30010.0",
- "price2": "0",
- "leverage": "none",
- "order": "buy 1.25000000 XBTUSD @ limit 30010.0",
- "close": ""
}, - "vol": "1.25000000",
- "vol_exec": "0.37500000",
- "cost": "11253.7",
- "fee": "0.00000",
- "price": "30010.0",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fciq",
- "trades": [
- "TCCCTY-WE2O6-P3NB37"
]
}, - "OB5VMB-B4U2U-DK2WRW": {
- "refid": "None",
- "userref": 45326,
- "status": "open",
- "opentm": 1688665899.5699,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTUSD",
- "type": "buy",
- "ordertype": "limit",
- "price": "14500.0",
- "price2": "0",
- "leverage": "5:1",
- "order": "buy 0.27500000 XBTUSD @ limit 14500.0 with 5:1 leverage",
- "close": ""
}, - "vol": "0.27500000",
- "vol_exec": "0.00000000",
- "cost": "0.00000",
- "fee": "0.00000",
- "price": "0.00000",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fciq"
}
}
}
}
Retrieve information about orders that have been closed (filled or cancelled). 50 results are returned at a time, the most recent by default.
Note: If an order's tx ID is given for start
or end
time, the order's opening time (opentm
) is used
API Key Permissions Required: Orders and trades - Query closed orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
trades | boolean Default: false Whether or not to include trades related to position in output |
userref | integer <int32> Restrict results to given user reference id |
start | integer Starting unix timestamp or order tx ID of results (exclusive) |
end | integer Ending unix timestamp or order tx ID of results (inclusive) |
ofs | integer Result offset for pagination |
closetime | string Default: "both" Enum: "open" "close" "both" Which time to use to search |
consolidate_taker | boolean Default: true Whether or not to consolidate trades by individual taker trades |
object (ClosedOrders) Closed Orders | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/ClosedOrders" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&trades=true"
{- "error": [ ],
- "result": {
- "closed": {
- "O37652-RJWRT-IMO74O": {
- "refid": "None",
- "userref": 1,
- "status": "canceled",
- "reason": "User requested",
- "opentm": 1688148493.7708,
- "closetm": 1688148610.0482,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTGBP",
- "type": "buy",
- "ordertype": "stop-loss-limit",
- "price": "23667.0",
- "price2": "0",
- "leverage": "none",
- "order": "buy 0.00100000 XBTGBP @ limit 23667.0",
- "close": ""
}, - "vol": "0.00100000",
- "vol_exec": "0.00000000",
- "cost": "0.00000",
- "fee": "0.00000",
- "price": "0.00000",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fciq",
- "trigger": "index"
}, - "O6YDQ5-LOMWU-37YKEE": {
- "refid": "None",
- "userref": 36493663,
- "status": "canceled",
- "reason": "User requested",
- "opentm": 1688148493.7708,
- "closetm": 1688148610.0477,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTEUR",
- "type": "buy",
- "ordertype": "take-profit-limit",
- "price": "27743.0",
- "price2": "0",
- "leverage": "none",
- "order": "buy 0.00100000 XBTEUR @ limit 27743.0",
- "close": ""
}, - "vol": "0.00100000",
- "vol_exec": "0.00000000",
- "cost": "0.00000",
- "fee": "0.00000",
- "price": "0.00000",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fciq",
- "trigger": "index"
}
}, - "count": 2
}
}
Retrieve information about specific orders.
API Key Permissions Required: Orders and trades - Query open orders & trades
or Orders and trades - Query closed orders & trades
, depending on status of order
nonce required | integer <int32> (nonce) Nonce used in construction of |
trades | boolean Default: false Whether or not to include trades related to position in output |
userref | integer <int32> Restrict results to given user reference id |
txid required | string Comma delimited list of transaction IDs to query info about (50 maximum) |
consolidate_taker | boolean Default: true Whether or not to consolidate trades by individual taker trades |
object | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/QueryOrders" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&trades=true"
{- "error": [ ],
- "result": {
- "OBCMZD-JIEE7-77TH3F": {
- "refid": "None",
- "userref": 0,
- "status": "closed",
- "reason": null,
- "opentm": 1688665496.7808,
- "closetm": 1688665499.1922,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTUSD",
- "type": "buy",
- "ordertype": "stop-loss-limit",
- "price": "27500.0",
- "price2": "0",
- "leverage": "none",
- "order": "buy 1.25000000 XBTUSD @ limit 27500.0",
- "close": ""
}, - "vol": "1.25000000",
- "vol_exec": "1.25000000",
- "cost": "27526.2",
- "fee": "26.2",
- "price": "27500.0",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fciq",
- "trigger": "index",
- "trades": [
- "TZX2WP-XSEOP-FP7WYR"
]
}, - "OMMDB2-FSB6Z-7W3HPO": {
- "refid": "None",
- "userref": 0,
- "status": "closed",
- "reason": null,
- "opentm": 1688592012.2317,
- "closetm": 1688592012.2335,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "XBTUSD",
- "type": "sell",
- "ordertype": "market",
- "price": "0",
- "price2": "0",
- "leverage": "none",
- "order": "sell 0.25000000 XBTUSD @ market",
- "close": ""
}, - "vol": "0.25000000",
- "vol_exec": "0.25000000",
- "cost": "7500.0",
- "fee": "7.5",
- "price": "30000.0",
- "stopprice": "0.00000",
- "limitprice": "0.00000",
- "misc": "",
- "oflags": "fcib",
- "trades": [
- "TJUW2K-FLX2N-AR2FLU"
]
}
}
}
Retrieve information about trades/fills. 50 results are returned at a time, the most recent by default.
pair_decimals
and lot_decimals
), not the individual assets' precision (decimals
).API Key Permissions Required: Orders and trades - Query closed orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
type | string Default: "all" Enum: "all" "any position" "closed position" "closing position" "no position" Type of trade |
trades | boolean Default: false Whether or not to include trades related to position in output |
start | integer Starting unix timestamp or trade tx ID of results (exclusive) |
end | integer Ending unix timestamp or trade tx ID of results (inclusive) |
ofs | integer Result offset for pagination |
consolidate_taker | boolean Default: true Whether or not to consolidate trades by individual taker trades |
object (TradeHistory) Trade History | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/TradesHistory" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&trades=true"
{- "error": [ ],
- "result": {
- "trades": {
- "THVRQM-33VKH-UCI7BS": {
- "ordertxid": "OQCLML-BW3P3-BUCMWZ",
- "postxid": "TKH2SE-M7IF5-CFI7LT",
- "pair": "XXBTZUSD",
- "time": 1688667796.8802,
- "type": "buy",
- "ordertype": "limit",
- "price": "30010.00000",
- "cost": "600.20000",
- "fee": "0.00000",
- "vol": "0.02000000",
- "margin": "0.00000",
- "misc": ""
}, - "TCWJEG-FL4SZ-3FKGH6": {
- "ordertxid": "OQCLML-BW3P3-BUCMWZ",
- "postxid": "TKH2SE-M7IF5-CFI7LT",
- "pair": "XXBTZUSD",
- "time": 1688667769.6396,
- "type": "buy",
- "ordertype": "limit",
- "price": "30010.00000",
- "cost": "300.10000",
- "fee": "0.00000",
- "vol": "0.01000000",
- "margin": "0.00000",
- "misc": ""
}
}
}
}
Retrieve information about specific trades/fills.
API Key Permissions Required: Orders and trades - Query closed orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
txid required | string Comma delimited list of transaction IDs to query info about (20 maximum) |
trades | boolean Default: false Whether or not to include trades related to position in output |
object Trade info | |
error | Array of strings (error) [ items ] |
curl -X "POST" "https://api.kraken.com/0/private/QueryTrades" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&txid=TRWCIF-3MJWU-5DYJG5,TNGJFU-5CD67-ZV3AEO"
{- "error": [ ],
- "result": {
- "THVRQM-33VKH-UCI7BS": {
- "ordertxid": "OQCLML-BW3P3-BUCMWZ",
- "postxid": "TKH2SE-M7IF5-CFI7LT",
- "pair": "XXBTZUSD",
- "time": 1688667796.8802,
- "type": "buy",
- "ordertype": "limit",
- "price": "30010.00000",
- "cost": "600.20000",
- "fee": "0.00000",
- "vol": "0.02000000",
- "margin": "0.00000",
- "misc": ""
}, - "TTEUX3-HDAAA-RC2RUO": {
- "ordertxid": "OH76VO-UKWAD-PSBDX6",
- "postxid": "TKH2SE-M7IF5-CFI7LT",
- "pair": "XXBTZEUR",
- "time": 1688082549.3138,
- "type": "buy",
- "ordertype": "limit",
- "price": "27732.00000",
- "cost": "0.20020",
- "fee": "0.00000",
- "vol": "0.00020000",
- "margin": "0.00000",
- "misc": ""
}
}
}
Get information about open margin positions.
API Key Permissions Required: Orders and trades - Query open orders & trades
nonce required | integer <int32> (nonce) Nonce used in construction of |
txid | string Comma delimited list of txids to limit output to |
docalcs | boolean Default: false Whether to include P&L calculations |
consolidation | string Value: "market" Consolidate positions by market/pair |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/OpenPositions', { "nonce": str(int(1000*time.time())), "docalcs": True }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "TF5GVO-T7ZZ2-6NBKBI": {
- "ordertxid": "OLWNFG-LLH4R-D6SFFP",
- "posstatus": "open",
- "pair": "XXBTZUSD",
- "time": 1605280097.8294,
- "type": "buy",
- "ordertype": "limit",
- "cost": "104610.52842",
- "fee": "289.06565",
- "vol": "8.82412861",
- "vol_closed": "0.20200000",
- "margin": "20922.10568",
- "value": "258797.5",
- "net": "+154186.9728",
- "terms": "0.0100% per 4 hours",
- "rollovertm": "1616672637",
- "misc": "",
- "oflags": ""
}, - "T24DOR-TAFLM-ID3NYP": {
- "ordertxid": "OIVYGZ-M5EHU-ZRUQXX",
- "posstatus": "open",
- "pair": "XXBTZUSD",
- "time": 1607943827.3172,
- "type": "buy",
- "ordertype": "limit",
- "cost": "145756.76856",
- "fee": "335.24057",
- "vol": "8.00000000",
- "vol_closed": "0.00000000",
- "margin": "29151.35371",
- "value": "240124.0",
- "net": "+94367.2314",
- "terms": "0.0100% per 4 hours",
- "rollovertm": "1616672637",
- "misc": "",
- "oflags": ""
}, - "TYMRFG-URRG5-2ZTQSD": {
- "ordertxid": "OF5WFH-V57DP-QANDAC",
- "posstatus": "open",
- "pair": "XXBTZUSD",
- "time": 1610448039.8374,
- "type": "buy",
- "ordertype": "limit",
- "cost": "0.00240",
- "fee": "0.00000",
- "vol": "0.00000010",
- "vol_closed": "0.00000000",
- "margin": "0.00048",
- "value": "0",
- "net": "+0.0006",
- "terms": "0.0100% per 4 hours",
- "rollovertm": "1616672637",
- "misc": "",
- "oflags": ""
}, - "TAFGBN-TZNFC-7CCYIM": {
- "ordertxid": "OF5WFH-V57DP-QANDAC",
- "posstatus": "open",
- "pair": "XXBTZUSD",
- "time": 1610448039.8448,
- "type": "buy",
- "ordertype": "limit",
- "cost": "2.40000",
- "fee": "0.00264",
- "vol": "0.00010000",
- "vol_closed": "0.00000000",
- "margin": "0.48000",
- "value": "3.0",
- "net": "+0.6015",
- "terms": "0.0100% per 4 hours",
- "rollovertm": "1616672637",
- "misc": "",
- "oflags": ""
}, - "T4O5L3-4VGS4-IRU2UL": {
- "ordertxid": "OF5WFH-V57DP-QANDAC",
- "posstatus": "open",
- "pair": "XXBTZUSD",
- "time": 1610448040.7722,
- "type": "buy",
- "ordertype": "limit",
- "cost": "21.59760",
- "fee": "0.02376",
- "vol": "0.00089990",
- "vol_closed": "0.00000000",
- "margin": "4.31952",
- "value": "27.0",
- "net": "+5.4133",
- "terms": "0.0100% per 4 hours",
- "rollovertm": "1616672637",
- "misc": "",
- "oflags": ""
}
}
}
Retrieve information about ledger entries. 50 results are returned at a time, the most recent by default.
API Key Permissions Required: Data - Query ledger entries
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Default: "all" Filter output by asset or comma delimited list of assets |
aclass | string Default: "currency" Filter output by asset class |
type | string Default: "all" Enum: "all" "trade" "deposit" "withdrawal" "transfer" "margin" "adjustment" "rollover" "credit" "settled" "staking" "dividend" "sale" "nft_rebate" Type of ledger to retrieve |
start | integer Starting unix timestamp or ledger ID of results (exclusive) |
end | integer Ending unix timestamp or ledger ID of results (inclusive) |
ofs | integer Result offset for pagination |
without_count | boolean Default: false If true, does not retrieve count of ledger entries. Request can be noticeably faster for users with many ledger entries as this avoids an extra database query. |
object (LedgersInfo) Ledgers Info | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/Ledgers" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>"
{- "error": [ ],
- "result": {
- "ledger": {
- "L4UESK-KG3EQ-UFO4T5": {
- "refid": "TJKLXF-PGMUI-4NTLXU",
- "time": 1688464484.1787,
- "type": "trade",
- "subtype": "",
- "aclass": "currency",
- "asset": "ZGBP",
- "amount": "-24.5000",
- "fee": "0.0490",
- "balance": "459567.9171"
}, - "LMKZCZ-Z3GVL-CXKK4H": {
- "refid": "TBZIP2-F6QOU-TMB6FY",
- "time": 1688444262.8888,
- "type": "trade",
- "subtype": "",
- "aclass": "currency",
- "asset": "ZUSD",
- "amount": "0.9852",
- "fee": "0.0010",
- "balance": "52732.1132"
}
}, - "count": 2
}
}
Retrieve information about specific ledger entries.
API Key Permissions Required: Data - Query ledger entries
nonce required | integer <int32> (nonce) Nonce used in construction of |
id required | string Comma delimited list of ledger IDs to query info about (20 maximum) |
trades | boolean Default: false Whether or not to include trades related to position in output |
object | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/QueryLedgers" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&id=LGBRJU-SQZ4L-5HLS3C,L3S26P-BHIOV-TTWYYI"
{- "error": [ ],
- "result": {
- "L4UESK-KG3EQ-UFO4T5": {
- "refid": "TJKLXF-PGMUI-4NTLXU",
- "time": 1688464484.1787,
- "type": "trade",
- "subtype": "",
- "aclass": "currency",
- "asset": "ZGBP",
- "amount": "-24.5000",
- "fee": "0.0490",
- "balance": "459567.9171"
}
}
}
Returns 30 day USD trading volume and resulting fee schedule for any asset pair(s) provided.
Note: If an asset pair is on a maker/taker fee schedule, the taker side is given in fees
and maker side in fees_maker
. For pairs not on maker/taker, they will only be given in fees
.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
pair | string Comma delimited list of asset pairs to get fee info on (optional) |
object (TradeVolume) Trade Volume | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/TradeVolume" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>&pair=XETCXETH"
{- "error": [ ],
- "result": {
- "currency": "ZUSD",
- "volume": "200709587.4223",
- "fees": {
- "XXBTZUSD": {
- "fee": "0.1000",
- "minfee": "0.1000",
- "maxfee": "0.2600",
- "nextfee": null,
- "nextvolume": null,
- "tiervolume": "10000000.0000"
}
}, - "fees_maker": {
- "XXBTZUSD": {
- "fee": "0.0000",
- "minfee": "0.0000",
- "maxfee": "0.1600",
- "nextfee": null,
- "nextvolume": null,
- "tiervolume": "10000000.0000"
}
}
}
}
Request export of trades or ledgers.
API Key Permissions Required: Data - Export data
nonce required | integer <int32> (nonce) Nonce used in construction of |
report required | string Enum: "trades" "ledgers" Type of data to export |
format | string Default: "CSV" Enum: "CSV" "TSV" File format to export |
description required | string Description for the export |
fields | string Default: "all" Comma-delimited list of fields to include
|
starttm | integer UNIX timestamp for report start time (default 1st of the current month) |
endtm | integer UNIX timestamp for report end time (default now) |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/AddExport', { "nonce": str(int(1000*time.time())), "description":"my_trades_1", "format":"CSV", "report":"trades" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "id": "TCJA"
}
}
Get status of requested data exports.
API Key Permissions Required: Data - Export data
nonce required | integer <int32> (nonce) Nonce used in construction of |
report required | string Enum: "trades" "ledgers" Type of reports to inquire about |
Array of objects | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/ExportStatus', { "nonce": str(int(1000*time.time())), "report":"trades" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": [
- {
- "id": "VSKC",
- "descr": "my_trades_1",
- "format": "CSV",
- "report": "trades",
- "subtype": "all",
- "status": "Processed",
- "flags": "0",
- "fields": "all",
- "createdtm": "1688669085",
- "expiretm": "1688878685",
- "starttm": "1688669093",
- "completedtm": "1688669093",
- "datastarttm": "1683556800",
- "dataendtm": "1688669085",
- "aclass": "forex",
- "asset": "all"
}, - {
- "id": "TCJA",
- "descr": "my_trades_1",
- "format": "CSV",
- "report": "trades",
- "subtype": "all",
- "status": "Processed",
- "flags": "0",
- "fields": "all",
- "createdtm": "1688363637",
- "expiretm": "1688573237",
- "starttm": "1688363664",
- "completedtm": "1688363664",
- "datastarttm": "1683235200",
- "dataendtm": "1688363637",
- "aclass": "forex",
- "asset": "all"
}
]
}
Retrieve a processed data export
API Key Permissions Required: Data - Export data
nonce required | integer <int32> (nonce) Nonce used in construction of |
id required | string Report ID to retrieve |
report | string <binary> Binary zip archive containing the report |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/RetrieveExport', { "nonce": str(int(1000*time.time())), "id":"TCJA" }, api_key, api_sec) # Write export to a new file 'myexport.zip' target_path = 'myexport.zip' handle = open(target_path, "wb") for chunk in resp.iter_content(chunk_size=512): if chunk: # filter out keep-alive new chunks handle.write(chunk) handle.close()
Delete exported trades/ledgers report
API Key Permissions Required: Data - Export data
nonce required | integer <int32> (nonce) Nonce used in construction of |
id required | string ID of report to delete or cancel |
type required | string Enum: "cancel" "delete"
|
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/RemoveExport', { "nonce": str(int(1000*time.time())), "id":"TCJA", "type":"delete" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "delete": true
}
}
Place a new order.
Note: See the AssetPairs endpoint for details on the available trading pairs, their price and quantity precisions, order minimums, available leverage, etc.
API Key Permissions Required: Orders and trades - Create & modify orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
userref | integer <int32> User reference id
|
ordertype required | string (ordertype) Enum: "market" "limit" "stop-loss" "take-profit" "stop-loss-limit" "take-profit-limit" "settle-position" Order type |
type required | string Enum: "buy" "sell" Order direction (buy/sell) |
volume required | string Order quantity in terms of the base asset
|
displayvol | string Used to create an iceberg order, this is the visible order quantity in terms of the base asset. The rest of the order will be hidden, although the full |
pair required | string Asset pair |
price | string Price:
|
price2 | string Secondary Price:
|
trigger | string Default: "last" Enum: "index" "last" Price signal used to trigger
|
leverage | string Amount of leverage desired (default: none) |
reduce_only | boolean Default: false If |
stptype | string Default: "cancel-newest" Enum: "cancel-newest" "cancel-oldest" "cancel-both" Self trade prevention behavior definition:
|
oflags | string (oflags) Comma delimited list of order flags
|
timeinforce | string Default: "GTC" Enum: "GTC" "IOC" "GTD" Time-in-force of the order to specify how long it should remain in the order book before being cancelled. GTC (Good-'til-cancelled) is default if the parameter is omitted. IOC (immediate-or-cancel) will immediately execute the amount possible and cancel any remaining balance rather than resting in the book. GTD (good-'til-date), if specified, must coincide with a desired |
starttm | string Scheduled start time, can be specified as an absolute timestamp or as a number of seconds in the future:
|
expiretm | string Expiration time, also can be specified as an absolute timestamp or as a number of seconds in the future:
|
close[ordertype] | string Enum: "limit" "stop-loss" "take-profit" "stop-loss-limit" "take-profit-limit" Conditional close order type
|
close[price] | string Conditional close order |
close[price2] | string Conditional close order |
deadline | string RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) after which the matching engine should reject the new order request, in presence of latency or order queueing: min now() + 2 seconds, max now() + 60 seconds. |
validate | boolean Default: false Validate inputs only. Do not submit order. |
object (OrderAdded) | |
error | Array of strings (error) [ items ] |
// buy 2.1234 XBTUSD @ limit $45,000.1 // with 2:1 leverage, with a follow up stop loss curl -X "POST" "https://api.kraken.com/0/private/AddOrder" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" --data-urlencode "pair=XXBTZUSD" \ --data-urlencode "type=buy" \ --data-urlencode "ordertype=limit" \ --data-urlencode "price=45000.1" \ --data-urlencode "volume=2.1234" \ --data-urlencode "leverage=2:1" \ --data-urlencode "close[ordertype]=stop-loss-limit" \ --data-urlencode "close[price]=38000" \ --data-urlencode "close[price2]=36000"
{- "error": [ ],
- "result": {
- "descr": {
- "order": "buy 1.25000000 XBTUSD @ limit 27500.0"
}, - "txid": [
- "OU22CG-KLAF2-FWUDD7"
]
}
}
Send an array of orders (max: 15). Any orders rejected due to order validations, will be dropped and the rest of the batch is processed. All orders in batch should be limited to a single pair. The order of returned txid's in the response array is the same as the order of the order list sent in request.
Note: See the AssetPairs endpoint for details on the available trading pairs, their price and quantity precisions, order minimums, available leverage, etc.
API Key Permissions Required: Orders and trades - Create & modify orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
required | Array of objects |
pair required | string Asset pair |
deadline | string RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) after which the matching engine should reject the new order request, in presence of latency or order queueing. min now() + 2 seconds, max now() + 60 seconds. |
validate | boolean Default: false Validate inputs only. Do not submit order. |
object (Result) | |
error | Array of strings (error) [ items ] |
// Send buy and sell BTC/USD curl -X "POST" "https://api.kraken.com/0/private/AddOrderBatch" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/json' \ { "deadline": "2022-05-24T14:15:22Z", "nonce": "<YOUR-NOUNCE>", "orders": [ { "close": {"ordertype": "stop-loss-limit", "price": "37000", "price2": "36000"}, "ordertype": "limit", "price": "40000", "price2": "string", "timeinforce": "GTC", "type": "buy", "userref": "345", "volume": "1.2" }, { "ordertype": "limit", "price": "42000", "starttm": "string", "timeinforce": "GTC", "type": "sell", "userref": "123", "volume": "1.2" } ], "pair": "BTC/USD", "validate": "false" }
{- "error": [ ],
- "result": {
- "orders": [
- {
- "txid": "65LRD3-AHGRA-YAH8E5",
- "descr": {
- "order": "buy 1.02010000 XBTUSD @ limit 29000.0"
}
}, - {
- "txid": "OK8HFF-5J2PL-XLR17S",
- "descr": {
- "order": "sell 0.14000000 XBTUSD @ limit 40000.0"
}
}
]
}
}
Edit volume and price on open orders. Uneditable orders include triggered stop/profit orders, orders with conditional close terms attached, those already cancelled or filled, and those where the executed volume is greater than the newly supplied volume. post-only flag is not retained from original order after successful edit. post-only needs to be explicitly set on edit request.
Note: See the AssetPairs endpoint for details on the available trading pairs, their price and quantity precisions, order minimums, available leverage, etc.
API Key Permissions Required: Orders and trades - Create & modify orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
userref | integer <int32> User reference id
|
required | string (string) or integer (integer) Original Order ID or User Reference Id (userref) which is user-specified integer id used with the original order. If userref is not unique and was used with multiple order, edit request is denied with an error. |
volume | string Order quantity in terms of the base asset. |
displayvol | string Used to edit an iceberg order, this is the visible order quantity in terms of the base asset. The rest of the order will be hidden, although the full |
pair required | string Asset pair |
price | string Price
|
price2 | string Secondary Price
|
oflags | any Comma delimited list of order flags. Only these flags can be changed: - post post-only order (available when ordertype = limit). All the flags from the parent order are retained except post-only. post-only needs to be explicitly mentioned on edit request. |
deadline | string RFC3339 timestamp (e.g. 2021-04-01T00:18:45Z) after which the matching engine should reject the new order request, in presence of latency or order queueing. min now() + 2 seconds, max now() + 60 seconds. |
cancel_response | boolean Used to interpret if client wants to receive pending replace, before the order is completely replaced |
validate | boolean Default: false Validate inputs only. Do not submit order. |
object (OrderEdited) | |
error | Array of strings (error) [ items ] |
curl -X "POST" "https://api.kraken.com/0/private/EditOrder" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" --data-urlencode "pair=XXBTZUSD" \ --data-urlencode "txid=OHYO67-6LP66-HMQ437" \ --data-urlencode "ordertype=limit" \ --data-urlencode "price=45000.1" \ --data-urlencode "price2=46000.1" \ --data-urlencode "volume=2.1234" \
{- "error": [ ],
- "result": {
- "descr": {
- "order": "buy 1.25000000 XBTUSD @ limit 27500.0"
}, - "txid": "OU22CG-KLAF2-FWUDD7"
}
}
Cancel a particular open order (or set of open orders) by txid
or userref
API Key Permissions Required: Orders and trades - Create & modify orders
and Orders and trades - Cancel & close orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
required | string (string) or integer (integer) Open order transaction ID (txid) or user reference (userref) |
object (OrderCancelled) | |
error | Array of strings (error) [ items ] |
curl -X "POST" "https://api.kraken.com/0/private/CancelOrder" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" --data-urlencode "txid=OYVGEW-VYV5B-UUEXSK"
{- "error": [ ],
- "result": {
- "count": 1
}
}
Cancel all open orders
API Key Permissions Required: Orders and trades - Create & modify orders
and Orders and trades - Cancel & close orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
object (OrderCancelled) | |
error | Array of strings (error) [ items ] |
curl -X "POST" "https://api.kraken.com/0/private/CancelAll" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>"
{- "error": [ ],
- "result": {
- "count": 4
}
}
CancelAllOrdersAfter provides a "Dead Man's Switch" mechanism to protect the client from network malfunction, extreme latency or unexpected matching engine downtime. The client can send a request with a timeout (in seconds), that will start a countdown timer which will cancel all client orders when the timer expires. The client has to keep sending new requests to push back the trigger time, or deactivate the mechanism by specifying a timeout of 0. If the timer expires, all orders are cancelled and then the timer remains disabled until the client provides a new (non-zero) timeout.
The recommended use is to make a call every 15 to 30 seconds, providing a timeout of 60 seconds. This allows the client to keep the orders in place in case of a brief disconnection or transient delay, while keeping them safe in case of a network breakdown. It is also recommended to disable the timer ahead of regularly scheduled trading engine maintenance (if the timer is enabled, all orders will be cancelled when the trading engine comes back from downtime - planned or otherwise).
API Key Permissions Required: Orders and trades - Create & modify orders
and Orders and trades - Cancel & close orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
timeout required | integer Duration (in seconds) to set/extend the timer by |
object | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/CancelAllOrdersAfter" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "timeout=60"
{- "error": [ ],
- "result": {
- "currentTime": "2023-03-24T17:41:56Z",
- "triggerTime": "2023-03-24T17:42:56Z"
}
}
Cancel multiple open orders by txid
or userref
(maximum 50 total unique IDs/references)
API Key Permissions Required: Orders and trades - Create & modify orders
and Orders and trades - Cancel & close orders
nonce required | integer <int32> (nonce) Nonce used in construction of |
required | Array of objects |
curl -X "POST" "https://api.kraken.com/0/private/CancelOrderBatch" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/json' \ { "nonce": "string", "orders": ["OG5V2Y-RYKVL-DT3V3B","OP5V2Y-RYKVL-ET3V3B"], }
{- "error": [ ],
- "result": {
- "count": 2
}
}
Retrieve methods available for depositing a particular asset.
API Key Permissions Required: Funds permissions - Query
and Funds permissions - Deposit
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being deposited |
aclass | string Default: "currency" Asset class being deposited (optional) |
Array of objects (depositMethod) | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/DepositMethods" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "asset=XBT"
{- "error": [ ],
- "result": [
- {
- "method": "Bitcoin",
- "limit": false,
- "fee": "0.0000000000",
- "gen-address": true,
- "minimum": "0.00010000"
}, - {
- "method": "Bitcoin Lightning",
- "limit": false,
- "fee": "0.00000000",
- "minimum": "0.00010000"
}
]
}
Retrieve (or generate a new) deposit addresses for a particular asset and method.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being deposited |
method required | string Name of the deposit method |
new | boolean Default: false Whether or not to generate a new address |
string (string) or integer (integer) or number (number) Amount you wish to deposit (only required for |
Array of objects (depositAddress) | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/DepositAddresses" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "asset=XBT" \ --data-urlencode "method=Bitcoin"
{- "error": [ ],
- "result": [
- {
- "address": "2N9fRkx5JTWXWHmXzZtvhQsufvoYRMq9ExV",
- "expiretm": "0",
- "new": true
}, - {
- "address": "2NCpXUCEYr8ur9WXM1tAjZSem2w3aQeTcAo",
- "expiretm": "0",
- "new": true
}, - {
- "address": "2Myd4eaAW96ojk38A2uDK4FbioCayvkEgVq",
- "expiretm": "0"
}, - {
- "address": "rLHzPsX3oXdzU2qP17kHCH2G4csZv1rAJh",
- "expiretm": "0",
- "new": true,
- "tag": "1361101127"
}, - {
- "address": "krakenkraken",
- "expiretm": "0",
- "memo": "4150096490"
}
]
}
Retrieve information about recent deposits. Any deposits initiated in the past 90 days will be included in the response, up to a maximum of 25 results, sorted by recency.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter for specific asset being deposited |
aclass | string Default: "currency" Filter for specific asset class being deposited |
method | string Filter for specific name of deposit method |
start | string Start timestamp, deposits created strictly before will not be included in the response |
end | string End timestamp, deposits created strictly after will be not be included in the response |
boolean or string true/false to enable/disable paginated response (boolean) or cursor for next page of results (string), default false |
deposit (object) or object | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/DepositStatus" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "asset=XBT" \ --data-urlencode "method=Bitcoin"
{- "error": [ ],
- "result": [
- {
- "method": "Bitcoin",
- "aclass": "currency",
- "asset": "XXBT",
- "refid": "FTQcuak-V6Za8qrWnhzTx67yYHz8Tg",
- "txid": "6544b41b607d8b2512baf801755a3a87b6890eacdb451be8a94059fb11f0a8d9",
- "info": "2Myd4eaAW96ojk38A2uDK4FbioCayvkEgVq",
- "amount": "0.78125000",
- "fee": "0.0000000000",
- "time": 1688992722,
- "status": "Success",
- "status-prop": "return"
}, - {
- "method": "Ether (Hex)",
- "aclass": "currency",
- "asset": "XETH",
- "refid": "FTQcuak-V6Za8qrPnhsTx47yYLz8Tg",
- "txid": "0x339c505eba389bf2c6bebb982cc30c6d82d0bd6a37521fa292890b6b180affc0",
- "info": "0xca210f4121dc891c9154026c3ae3d1832a005048",
- "amount": "0.1383862742",
- "time": 1688992722,
- "status": "Settled",
- "status-prop": "onhold",
- "originators": [
- "0x70b6343b104785574db2c1474b3acb3937ab5de7346a5b857a78ee26954e0e2d",
- "0x5b32f6f792904a446226b17f607850d0f2f7533cdc35845bfe432b5b99f55b66"
]
}
]
}
Retrieve a list of withdrawal methods available for the user.
API Key Permissions Required: Funds permissions - Query
and Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter methods for specific asset |
aclass | string Default: "currency" Filter methods for specific asset class |
network | string Filter methods for specific network |
Array of objects (withdrawalMethods) Withdrawal Methods | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/WithdrawMethods" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "asset=XBT"
{- "error": [ ],
- "result": [
- {
- "asset": "XXBT",
- "method": "Bitcoin",
- "network": "Bitcoin",
- "minimum": "0.0004"
}, - {
- "asset": "XXBT",
- "method": "Bitcoin Lightning",
- "network": "Lightning",
- "minimum": "0.00001"
}
]
}
Retrieve a list of withdrawal addresses available for the user.
API Key Permissions Required: Funds permissions - Query
and Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter addresses for specific asset |
aclass | string Default: "currency" Filter addresses for specific asset class |
method | string Filter addresses for specific method |
key | string Find address for by withdrawal key name, as set up on your account |
verified | boolean Filter by verification status of the withdrawal address. Withdrawal addresses successfully completing email confirmation will have a verification status of true. |
Array of objects (withdrawalAddresses) Withdrawal Addresses | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/WithdrawAddresses" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>" \ --data-urlencode "asset=XBT"
{- "error": [ ],
- "result": [
- {
- "address": "bc1qxdsh4sdd29h6ldehz0se5c61asq8cgwyjf2y3z",
- "asset": "XBT",
- "method": "Bitcoin",
- "key": "btc-wallet-1",
- "verified": true
}
]
}
Retrieve fee information about potential withdrawals for a particular asset, key and amount.
API Key Permissions Required: Funds permissions - Query
and Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being withdrawn |
key required | string Withdrawal key name, as set up on your account |
amount required | string Amount to be withdrawn |
object (withdrawalInfo) Withdrawal Info | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/WithdrawInfo', { "nonce": str(int(1000*time.time())), "asset": "XBT", "key": "btc_testnet_with1", "amount": 0.725 }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "method": "Bitcoin",
- "limit": "332.00956139",
- "amount": "0.72480000",
- "fee": "0.00020000"
}
}
Make a withdrawal request.
API Key Permissions Required: Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being withdrawn |
key required | string Withdrawal key name, as set up on your account |
address | string Optional, crypto address that can be used to confirm address matches key (will return |
amount required | string Amount to be withdrawn |
max_fee | string Optional, if the processed withdrawal fee is higher than |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Withdraw', { "nonce": str(int(1000*time.time())), "asset": "XBT", "key": "btc_testnet_with1", "address": "bc1kar0ssrr7xf3vy5l6d3lydnwkre5og2zz3f5ldq", "amount": 0.725 }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "FTQcuak-V6Za8qrWnhzTx67yYHz8Tg"
}
}
Retrieve information about recent withdrawals. Any withdrawals initiated in the past 90 days will be included in the response, up to a maximum of 500 results, sorted by recency.
API Key Permissions Required: Funds permissions - Withdraw
or Data - Query ledger entries
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter for specific asset being withdrawn |
aclass | string Default: "currency" Filter for specific asset class being withdrawn |
method | string Filter for specific name of withdrawal method |
start | string Start timestamp, withdrawals created strictly before will not be included in the response |
end | string End timestamp, withdrawals created strictly after will be not be included in the response |
boolean or string true/false to enable/disable paginated response (boolean) or cursor for next page of results (string), default false |
Array of objects (Withdrawal) | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/WithdrawStatus', { "nonce": str(int(1000*time.time())) }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": [
- {
- "method": "Bitcoin",
- "aclass": "currency",
- "asset": "XXBT",
- "refid": "FTQcuak-V6Za8qrWnhzTx67yYHz8Tg",
- "txid": "THVRQM-33VKH-UCI7BS",
- "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
- "amount": "0.72485000",
- "fee": "0.00020000",
- "time": 1688014586,
- "status": "Pending",
- "key": "btc-wallet-1"
}, - {
- "method": "Bitcoin",
- "aclass": "currency",
- "asset": "XXBT",
- "refid": "FTQcuak-V6Za8qrPnhsTx47yYLz8Tg",
- "txid": "KLETXZ-33VKH-UCI7BS",
- "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
- "amount": "0.72485000",
- "fee": "0.00020000",
- "time": 1688015423,
- "status": "Failure",
- "status-prop": "canceled",
- "key": "btc-wallet-2"
}
]
}
Cancel a recently requested withdrawal, if it has not already been successfully processed.
API Key Permissions Required: Funds permissions - Withdraw
, unless withdrawal is a WalletTransfer
, then no permissions are required.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being withdrawn |
refid required | string Withdrawal reference ID |
result | boolean Whether cancellation was successful or not. |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/WithdrawCancel', { "nonce": str(int(1000*time.time())), "asset": "XBT", "refid": "FTQcuak-V6Za8qrWnhzTx67yYHz8Tg" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": true
}
Transfer from a Kraken spot wallet to a Kraken Futures wallet. Note that a transfer in the other direction must be requested via the Kraken Futures API endpoint for withdrawals to Spot wallets.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset to transfer (asset ID or |
from required | string Value: "Spot Wallet" Source wallet |
to required | string Value: "Futures Wallet" Destination wallet |
amount required | string Amount to transfer |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/WalletTransfer', { "nonce": str(int(1000*time.time())), "asset": "ETH", "amount": 0.100, "from":"Spot Wallet", "to":"Futures Wallet" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "FTQcuak-V6Za8qrWnhzTx67yYHz8Tg"
}
}
Subaccounts are currently only available to institutional clients. Please contact your Account Manager for more details.
Create a trading subaccount.
nonce required | integer <int32> (nonce) Nonce used in construction of |
username required | string Username for the subaccount |
email required | string Email address for the subaccount |
result | boolean Whether subaccount creation was successful or not. |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/CreateSubaccount', { "nonce": str(int(1000*time.time())), "username": "abc123", "email": "abc123@gmail.com" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": true
}
Transfer funds to and from master and subaccounts. Note: AccountTransfer
must be called by the master account.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being transferred |
amount required | string Amount of asset to transfer |
from required | string IIBAN of the source account |
to required | string IIBAN of the destination account |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/AccountTransfer', { "nonce": str(int(1000*time.time())), "asset": "XBT", "amount": 1.0, "from": "ABCD 1234 EFGH 5678" "to": "IJKL 0987 MNOP 6543" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "transfer_id": "TOH3AS2-LPCWR8-JDQGEU",
- "status": "complete"
}
}
The earn API allows interacting with all of Kraken's yield generating products. It replaces the old /staking
part of the API.
The different available earn products are represented by earn strategies. This corresponds to the legacy Staking/Assets
. Stake
/Unstake
are replaced by Allocate
/Deallocate
.
/Earn
:Strategies
- list all earn strategies for which you are eligible or have a balance.Allocations
- lists the balance in your earn account for each strategy. Requires the Query Funds
API key permission.Allocate
/Deallocate
- allocate/deallocate to an earn strategy through an async operation. Requires the Earn Funds
API key permission.AllocateStatus
/DeallocateStatus
- verifies the state of the last allocation/deallocation. Requires the Earn Funds
or Query Funds
API key permission.Strategies
to obtain information about the relevant strategy. The lock_type
field shows whether bonding/unbonding funds are earning yield. The relevant fields are bonding_rewards
/unbonding_rewards
.Allocations
for the relevant strategy. From the previous step, for strategies where bonding/unbonding does not earn yield, substract these balances from amount_allocated.total
to determine which balances are currently earning.Call /0/private/BalanceEx
, subtract hold_trading
amount. Remaining balance is available for allocation to a strategy.
Some earn strategies are not available in all geographic regions. Strategies
will return only strategies available to the caller.
Allocate funds to the Strategy.
Requires the Earn Funds
API key permission.
The amount must always be defined.
This method is asynchronous. A couple of preflight checks are
performed synchronously on behalf of the method before it is dispatched
further. The client is required to poll
the result using the /0/private/Earn/AllocateStatus
endpoint.
There can be only one (de)allocation request in progress for given user and strategy at any time. While the operation is in progress:
pending
attribute in /Earn/Allocations
response for the strategy
indicates that funds are being allocated,pending
attribute in /Earn/AllocateStatus
response will be true.Following specific errors within Earnings
class can be returned by this
method:
EEarnings:Below min:(De)allocation operation amount less than minimum
EEarnings:Busy:Another (de)allocation for the same strategy is in progress
EEarnings:Busy
. Try again in a few minutes.EEarnings:Permission denied:The user's tier is not high enough
EGeneral:Invalid arguments:Invalid strategy ID
nonce required | integer <int32> (nonce) Nonce used in construction of |
amount required | string The amount to allocate. |
strategy_id required | string A unique identifier of the chosen earn strategy, as returned from |
error | Array of strings (error) |
result | boolean or null Will return |
{- "amount": "4.3",
- "nonce": 30295839,
- "strategy_id": "ESRFUO3-Q62XD-WIOIL7"
}
{- "error": [ ],
- "result": true
}
Deallocate funds from a strategy.
Requires the Earn Funds
API key permission.
The amount must always be defined.
This method is asynchronous. A couple of preflight checks are
performed synchronously on behalf of the method before it is dispatched
further. If the method returns HTTP 202 code, the client is required to poll
the result using the /Earn/DeallocateStatus
endpoint.
There can be only one (de)allocation request in progress for given user and strategy. While the operation is in progress:
pending
attribute in Allocations
response for the strategy will hold
the amount that is being deallocated (negative amount)pending
attribute in DeallocateStatus
response will be true.Following specific errors within Earnings
class can be returned by this
method:
EEarnings:Below min:(De)allocation operation amount less than minimum
allowedEEarnings:Busy:Another (de)allocation for the same strategy is in progress
EGeneral:Invalid arguments:Invalid strategy ID
nonce required | integer <int32> (nonce) Nonce used in construction of |
amount required | string The amount to deallocate. This field is required. |
strategy_id required | string A unique identifier per earn strategy. |
error | Array of strings (error) |
result | boolean or null Will return |
{- "amount": "4.3",
- "nonce": 30295839,
- "strategy_id": "ESRFUO3-Q62XD-WIOIL7"
}
{- "error": [ ],
- "result": true
}
Get the status of the last allocation request.
Requires either the Earn Funds
or Query Funds
API key permission.
(De)allocation operations are asynchronous and this endpoint allows client to retrieve the status of the last dispatched operation. There can be only one (de)allocation request in progress for given user and strategy.
The pending
attribute in the response indicates if the previously
dispatched operation is still in progress (true) or has successfully
completed (false). If the dispatched request failed with an error, then
HTTP error is returned to the client as if it belonged to the original
request.
Following specific errors within Earnings
class can be returned by this
method:
EEarnings:Insufficient funds:Insufficient funds to complete the (de)allocation request
EEarnings:Above max:The allocation exceeds user limit for the strategy
EEarnings:Above max:The allocation exceeds the total strategy limit
EEarnings:Below min:(De)allocation operation amount less than minimum
nonce required | integer <int32> (nonce) Nonce used in construction of |
strategy_id required | string ID of the earn strategy, call |
error | Array of strings (error) |
object or null Status of async earn operation |
{- "nonce": 30295839,
- "strategy_id": "ESRFUO3-Q62XD-WIOIL7"
}
{- "error": [ ],
- "result": {
- "pending": false
}
}
Get the status of the last deallocation request.
Requires either the Earn Funds
or Query Funds
API key permission.
(De)allocation operations are asynchronous and this endpoint allows client to retrieve the status of the last dispatched operation. There can be only one (de)allocation request in progress for given user and strategy.
The pending
attribute in the response indicates if the previously
dispatched operation is still in progress (true) or has successfully
completed (false). If the dispatched request failed with an error, then
HTTP error is returned to the client as if it belonged to the original
request.
Following specific errors within Earnings
class can be returned by this
method:
EEarnings:Insufficient funds:Insufficient funds to complete the (de)allocation request
EEarnings:Below min:(De)allocation operation amount less than minimum
nonce required | integer <int32> (nonce) Nonce used in construction of |
strategy_id required | string ID of the earn strategy, call |
error | Array of strings (error) |
object or null Status of async earn operation |
{- "nonce": 30295839,
- "strategy_id": "ESRFUO3-Q62XD-WIOIL7"
}
{- "error": [ ],
- "result": {
- "pending": false
}
}
List earn strategies along with their parameters.
Requires a valid API key but not specific permission is required.
Returns only strategies that are available to the user based on geographic region.
When the user does not meet the tier restriction, can_allocate
will be
false and allocation_restriction_info
indicates Tier
as the restriction
reason. Earn products generally require Intermediate tier. Get your account verified
to access earn.
Paging isn't yet implemented, so it the endpoint always returns all data in the first page.
nonce required | integer <int32> (nonce) Nonce used in construction of |
ascending | boolean or null
|
asset | string or null Filter strategies by asset name |
cursor | string or null None to start at beginning/end, otherwise next page ID |
limit | integer or null <uint16> How many items to return per page. Note that the limit may be cap'd to lower value in the application code. |
lock_type | Array of strings or null Enum: "flex" "bonded" "timed" "instant" Filter strategies by lock type |
error | Array of strings (error) |
object or null |
{- "nonce": 30295839,
- "asset": "DOT"
}
{- "error": [ ],
- "result": {
- "next_cursor": "2",
- "items": [
- {
- "id": "ESRFUO3-Q62XD-WIOIL7",
- "asset": "DOT",
- "lock_type": {
- "type": "instant",
- "payout_frequency": 604800
}, - "apr_estimate": {
- "low": "8.0000",
- "high": "12.0000"
}, - "user_min_allocation": "0.01",
- "allocation_fee": "0.0000",
- "deallocation_fee": "0.0000",
- "auto_compound": {
- "type": "enabled"
}, - "yield_source": {
- "type": "staking"
}, - "can_allocate": true,
- "can_deallocate": true,
- "allocation_restriction_info": [ ]
}
]
}
}
List all allocations for the user.
Requires the Query Funds
API key permission.
By default all allocations are returned, even for strategies that have been
used in the past and have zero balance now. That is so that the user can see
how much was earned with given strategy in the past.
hide_zero_allocations
parameter can be used to remove zero balance entries
from the output. Paging hasn't been implemented for this method as we don't
expect the result for a particular user to be overwhelmingly large.
All amounts in the output can be denominated in a currency of user's choice
(the converted_asset
parameter).
Information about when the next reward will be paid to the client is also provided in the output.
Allocated funds can be in up to 4 states:
Any funds in total
not in bonding
/unbonding
are simply allocated and
earning rewards. Depending on the strategy funds in the other 3 states can
also be earning rewards. Consult the output of /Earn/Strategies
to know
whether bonding
/unbonding
earn rewards. ETH
in exit_queue
still
earns rewards.
Note that for ETH
, when the funds are in the exit_queue
state, the
expires
time given is the time when the funds will have finished
unbonding, not when they go from exit queue to unbonding.
(Un)bonding time estimate can be inaccurate right after having (de)allocated the funds. Wait 1-2 minutes after (de)allocating to get an accurate result.
nonce required | integer <int32> (nonce) Nonce used in construction of |
ascending | boolean or null
|
converted_asset | string or null A secondary currency to express the value of your allocations (the default is USD). |
hide_zero_allocations | boolean or null Omit entries for strategies that were used in the past but now they don't hold any allocation (the default is |
error | Array of strings (error) |
object or null Page response |
{- "nonce": 30295839,
- "converted_asset": "EUR",
- "hide_zero_allocations": true
}
{- "error": [ ],
- "result": {
- "converted_asset": "USD",
- "total_allocated": "49.2398",
- "total_rewarded": "0.0675",
- "next_cursor": "2",
- "items": [
- {
- "strategy_id": "ESDQCOL-WTZEU-NU55QF",
- "native_asset": "ETH",
- "amount_allocated": {
- "bonding": {
- "native": "0.0210000000",
- "converted": "39.0645",
- "allocation_count": 2,
- "allocations": [
- {
- "created_at": "2023-07-06T10:52:05Z",
- "expires": "2023-08-19T02:34:05.807Z",
- "native": "0.0010000000",
- "converted": "1.8602"
}, - {
- "created_at": "2023-08-01T11:25:52Z",
- "expires": "2023-09-06T07:55:52.648Z",
- "native": "0.0200000000",
- "converted": "37.2043"
}
]
}, - "total": {
- "native": "0.0210000000",
- "converted": "39.0645"
}
}, - "total_rewarded": {
- "native": "0",
- "converted": "0.0000"
}
}
]
}
}
Deprecated: Please use the Earn
endpoints instead.
Stake an asset from your spot wallet.
API Key Permissions Required: Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset to stake (asset ID or |
amount required | string Amount of the asset to stake |
method required | string Name of the staking option to use (refer to the Staking Assets endpoint for the correct method names for each asset) |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Stake', { "nonce": str(int(1000*time.time())), "asset": "XXBT", "amount": 0.1, "method": "xbt-staked" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "BOG5AE5-KSCNR4-VPNPEV"
}
}
Deprecated: Please use the Earn
endpoints instead.
Unstake an asset from your staking wallet.
API Key Permissions Required: Funds permissions - Withdraw
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset to unstake (asset ID or |
amount required | string Amount of the asset to stake |
object | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Unstake', { "nonce": str(int(1000*time.time())), "asset": "XXBT", "amount": 0.1 }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "BOG5AE5-KSCNR4-VPNPEV"
}
}
Deprecated: Please use the Earn
endpoints instead.
Returns the list of assets that the user is able to stake.
nonce required | integer <int32> (nonce) Nonce used in construction of |
Array of objects (Staking Asset Information) | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Staking/Assets', { "nonce": str(int(1000*time.time())) }, api_key, api_sec) print(resp.json())
{- "result": [
- {
- "method": "polkadot-staked",
- "asset": "DOT",
- "staking_asset": "DOT.S",
- "rewards": {
- "reward": "12.00",
- "type": "percentage"
}, - "on_chain": true,
- "can_stake": true,
- "can_unstake": true,
- "minimum_amount": {
- "staking": "0.0000000000",
- "unstaking": "0.0000000000"
}
}, - {
- "method": "kusama-staked",
- "asset": "KSM",
- "staking_asset": "KSM.S",
- "rewards": {
- "reward": "12.00",
- "type": "percentage"
}, - "on_chain": true,
- "can_stake": true,
- "can_unstake": true,
- "minimum_amount": {
- "staking": "0.0000000000",
- "unstaking": "0.0000000000"
}
}
], - "error": [ ]
}
Deprecated: Please use the Earn
endpoints instead.
Returns the list of pending staking transactions. Once resolved, these transactions
will appear on the List of Staking Transactions
endpoint.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
Array of objects (Staking Transaction Info) | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Staking/Pending', { "nonce": str(int(1000*time.time())) }, api_key, api_sec) print(resp.json())
{- "result": [
- {
- "method": "ada-staked",
- "aclass": "currency",
- "asset": "ADA.S",
- "refid": "RUSB7W6-ESIXUX-K6PVTM",
- "amount": "0.34844300",
- "fee": "0.00000000",
- "time": 1688967367,
- "status": "Initial",
- "type": "bonding"
}, - {
- "method": "xtz-staked",
- "aclass": "currency",
- "asset": "XTZ.S",
- "refid": "RUCXX7O-6MWQBO-CQPGAX",
- "amount": "0.00746900",
- "fee": "0.00000000",
- "time": 1688074402,
- "status": "Initial",
- "type": "bonding"
}
], - "error": [ ]
}
Deprecated: Please use the Earn
endpoints instead.
Returns the list of 1000 recent staking transactions from past 90 days.
API Key Permissions Required: Funds permissions - Query
nonce required | integer <int32> (nonce) Nonce used in construction of |
Array of objects (Staking Transaction Info) | |
error | Array of strings (error) |
import time import os import requests # Read Kraken API key and secret stored in environment variables api_url = "https://api.kraken.com" api_key = os.environ['API_KEY_KRAKEN'] api_sec = os.environ['API_SEC_KRAKEN'] # Attaches auth headers and returns results of a POST request def kraken_request(uri_path, data, api_key, api_sec): headers = {} headers['API-Key'] = api_key # get_kraken_signature() as defined in the 'Authentication' section headers['API-Sign'] = get_kraken_signature(uri_path, data, api_sec) req = requests.post((api_url + uri_path), headers=headers, data=data) return req # Construct the request and print the result resp = kraken_request('/0/private/Staking/Transactions', { "nonce": str(int(1000*time.time())) }, api_key, api_sec) print(resp.json())
{- "result": [
- {
- "method": "xbt-staked",
- "aclass": "currency",
- "asset": "XBT.M",
- "refid": "RWBL2YD-SJYHBZ-VBB3RD",
- "amount": "0.0038634900",
- "fee": "0.0000000000",
- "time": 1688971496,
- "status": "Success",
- "type": "bonding",
- "bond_start": 1688971496,
- "bond_end": 1688971496
}, - {
- "method": "ada-staked",
- "aclass": "currency",
- "asset": "ADA.S",
- "refid": "RUSB7W6-ESIXUX-K6PVTM",
- "amount": "0.34844300",
- "fee": "0.00000000",
- "time": 1688967367,
- "status": "Success",
- "type": "bonding",
- "bond_start": 16288967367,
- "bond_end": 1688967367
}, - {
- "method": "eth2-staked",
- "aclass": "currency",
- "asset": "ETH2",
- "refid": "RUOCJP3-TWUJOE-L4EEG3",
- "amount": "0.0001943480",
- "fee": "0.0000000000",
- "time": 1688943004,
- "status": "Success",
- "type": "bonding",
- "bond_start": 1688943004,
- "bond_end": 1688943004
}
], - "error": [ ]
}
An authentication token must be requested via this REST API endpoint in order to connect to and authenticate with our Websockets API. The token should be used within 15 minutes of creation, but it does not expire once a successful Websockets connection and private subscription has been made and is maintained.
API Key Permissions Required: WebSocket interface - On
nonce required | integer <int32> (nonce) Nonce used in construction of |
object | |
error | Array of strings (error) |
curl -X "POST" "https://api.kraken.com/0/private/GetWebSocketsToken" \ -H 'API-Key: <YOUR-API-KEY>' \ -H 'API-Sign: <YOUR-MSG-SIGNATURE>' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \ --data-urlencode "nonce=<YOUR-NONCE>"
{- "error": [ ],
- "result": {
- "token": "1Dwc4lzSwNWOAwkMdqhssNNFhs1ed606d1WcF3XfEMw",
- "expires": 900
}
}