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 |
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.
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.
address
parameter to Withdraw
.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
and QueryTrades
.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": 1616336594,
- "rfc1123": "Sun, 21 Mar 21 14:23:14 +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": "2021-03-21T15:33:02Z"
}
}
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 |
aclass | string Example: aclass=currency Asset class (optional, default: |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Assets"
{- "result": {
- "asset1": {
- "aclass": "string",
- "altname": "string",
- "decimals": 0,
- "display_decimals": 0,
- "collateral_value": 0,
- "status": "string"
}, - "asset2": {
- "aclass": "string",
- "altname": "string",
- "decimals": 0,
- "display_decimals": 0,
- "collateral_value": 0,
- "status": "string"
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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": 550,
- "short_position_limit": 470
}, - "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": 270,
- "short_position_limit": 180
}
}
}
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"
{- "result": {
- "pair1": {
- "a": [
- "string"
], - "b": [
- "string"
], - "c": [
- "string"
], - "v": [
- "string"
], - "p": [
- "string"
], - "t": [
- 0
], - "l": [
- "string"
], - "h": [
- "string"
], - "o": "string"
}, - "pair2": {
- "a": [
- "string"
], - "b": [
- "string"
], - "c": [
- "string"
], - "v": [
- "string"
], - "p": [
- "string"
], - "t": [
- 0
], - "l": [
- "string"
], - "h": [
- "string"
], - "o": "string"
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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"
{- "result": {
- "last": 0,
- "pair1": [
- [
- [
- 1548115200,
- "3533.4",
- "3543.7",
- "3530.7",
- "3539.4",
- "3539.8",
- "83.09287787",
- 232
]
]
], - "pair2": [
- [
- [
- 1548115200,
- "3533.4",
- "3543.7",
- "3530.7",
- "3539.4",
- "3539.8",
- "83.09287787",
- 232
]
]
]
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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"
{- "result": {
- "pair1": {
- "asks": [
- [
- "3539.90000",
- "0.801",
- 1548119951
]
], - "bids": [
- [
- "3538.70000",
- "0.798",
- 1548119924
]
]
}, - "pair2": {
- "asks": [
- [
- "3539.90000",
- "0.801",
- 1548119951
]
], - "bids": [
- [
- "3538.70000",
- "0.798",
- 1548119924
]
]
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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 |
object | |
error | Array of strings (error) |
curl "https://api.kraken.com/0/public/Trades?pair=XBTUSD"
{- "result": {
- "last": "string",
- "pair1": [
- [
- "1205.00000",
- "2.28253070",
- 1668714225.5189962,
- "b",
- "l",
- "",
- 41557503
]
], - "pair2": [
- [
- "1205.00000",
- "2.28253070",
- 1668714225.5189962,
- "b",
- "l",
- "",
- 41557503
]
]
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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"
{- "result": {
- "last": 0,
- "pair1": [
- [
- 1548120550,
- "3538.70000",
- "3541.50000"
]
], - "pair2": [
- [
- 1548120550,
- "3538.70000",
- "3541.50000"
]
]
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve all cash balances, net of pending withdrawals.
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>"
{- "result": {
- "ZUSD": "2970172.7962"
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve a summary of collateral balances, margin position valuations, equity and margin level.
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"
{- "result": {
- "eb": "3224744.0162",
- "tb": "3224744.0162",
- "m": "0.0000",
- "n": "0.0000",
- "c": "0.0000",
- "v": "0.0000",
- "e": "3224744.0162",
- "mf": "3224744.0162",
- "ml": "0.0000",
- "uv": "0.0000"
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve information about currently open orders.
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"
{- "result": {
- "open": {
- "txid1": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
]
}, - "txid2": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
]
}
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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
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 |
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"
{- "result": {
- "closed": {
- "txid1": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
], - "closetm": 0,
- "reason": "string"
}, - "txid2": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
], - "closetm": 0,
- "reason": "string"
}
}, - "count": 0
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve information about specific orders.
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"
{- "result": {
- "txid1": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
]
}, - "txid2": {
- "refid": "string",
- "userref": "string",
- "status": "pending",
- "opentm": 0,
- "starttm": 0,
- "expiretm": 0,
- "descr": {
- "pair": "string",
- "type": "buy",
- "ordertype": "market",
- "price": "string",
- "price2": "string",
- "leverage": "string",
- "order": "string",
- "close": "string"
}, - "vol": "string",
- "vol_exec": "string",
- "cost": "string",
- "fee": "string",
- "price": "string",
- "stopprice": "string",
- "limitprice": "string",
- "trigger": "last",
- "misc": "string",
- "oflags": "string",
- "trades": [
- "string"
]
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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
).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"
{- "result": {
- "count": 0,
- "trades": {
- "txid1": {
- "ordertxid": "string",
- "postxid": "string",
- "pair": "string",
- "time": 0,
- "type": "string",
- "ordertype": "string",
- "price": "string",
- "cost": "string",
- "fee": "string",
- "vol": "string",
- "margin": "string",
- "leverage": "string",
- "misc": "string",
- "trade_id": 0,
- "posstatus": "string",
- "cprice": null,
- "ccost": null,
- "cfee": null,
- "cvol": null,
- "cmargin": null,
- "net": null,
- "trades": [
- "string"
]
}, - "txid2": {
- "ordertxid": "string",
- "postxid": "string",
- "pair": "string",
- "time": 0,
- "type": "string",
- "ordertype": "string",
- "price": "string",
- "cost": "string",
- "fee": "string",
- "vol": "string",
- "margin": "string",
- "leverage": "string",
- "misc": "string",
- "trade_id": 0,
- "posstatus": "string",
- "cprice": null,
- "ccost": null,
- "cfee": null,
- "cvol": null,
- "cmargin": null,
- "net": null,
- "trades": [
- "string"
]
}
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve information about specific trades/fills.
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": 1616667796.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": 1614082549.3138,
- "type": "buy",
- "ordertype": "limit",
- "price": "1001.00000",
- "cost": "0.20020",
- "fee": "0.00000",
- "vol": "0.00020000",
- "margin": "0.00000",
- "misc": ""
}
}
}
Get information about open margin positions.
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.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Default: "all" Comma delimited list of assets to restrict output to |
aclass | string Default: "currency" Asset class |
type | string Default: "all" Enum: "all" "deposit" "withdrawal" "trade" "margin" "rollover" "credit" "transfer" "settled" "staking" "sale" 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>"
{- "result": {
- "ledger": {
- "ledger_id1": {
- "refid": "string",
- "time": 0,
- "type": "trade",
- "subtype": "string",
- "aclass": "string",
- "asset": "string",
- "amount": "string",
- "fee": "string",
- "balance": "string"
}, - "ledger_id2": {
- "refid": "string",
- "time": 0,
- "type": "trade",
- "subtype": "string",
- "aclass": "string",
- "asset": "string",
- "amount": "string",
- "fee": "string",
- "balance": "string"
}
}, - "count": 0
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve information about specific ledger entries.
nonce required | integer <int32> (nonce) Nonce used in construction of |
id | 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"
{- "result": {
- "ledger_id1": {
- "refid": "string",
- "time": 0,
- "type": "trade",
- "subtype": "string",
- "aclass": "string",
- "asset": "string",
- "amount": "string",
- "fee": "string",
- "balance": "string"
}, - "ledger_id2": {
- "refid": "string",
- "time": 0,
- "type": "trade",
- "subtype": "string",
- "aclass": "string",
- "asset": "string",
- "amount": "string",
- "fee": "string",
- "balance": "string"
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
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
.
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"
{- "result": {
- "currency": "string",
- "volume": "string",
- "fees": {
- "pair1": {
- "fee": "string",
- "min_fee": "string",
- "max_fee": "string",
- "next_fee": "string",
- "tier_volume": "string",
- "next_volume": "string"
}, - "pair2": {
- "fee": "string",
- "min_fee": "string",
- "max_fee": "string",
- "next_fee": "string",
- "tier_volume": "string",
- "next_volume": "string"
}
}, - "fees_maker": {
- "pair1": {
- "fee": "string",
- "min_fee": "string",
- "max_fee": "string",
- "next_fee": "string",
- "tier_volume": "string",
- "next_volume": "string"
}, - "pair2": {
- "fee": "string",
- "min_fee": "string",
- "max_fee": "string",
- "next_fee": "string",
- "tier_volume": "string",
- "next_volume": "string"
}
}
}, - "error": [
- "EGeneral:Invalid arguments"
]
}
Request export of trades or ledgers.
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.
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": "1616669085",
- "expiretm": "1617878685",
- "starttm": "1616669093",
- "completedtm": "1616669093",
- "datastarttm": "1614556800",
- "dataendtm": "1616669085",
- "aclass": "forex",
- "asset": "all"
}, - {
- "id": "TCJA",
- "descr": "my_trades_1",
- "format": "CSV",
- "report": "trades",
- "subtype": "all",
- "status": "Processed",
- "flags": "0",
- "fields": "all",
- "createdtm": "1617363637",
- "expiretm": "1618573237",
- "starttm": "1617363664",
- "completedtm": "1617363664",
- "datastarttm": "1617235200",
- "dataendtm": "1617363637",
- "aclass": "forex",
- "asset": "all"
}
]
}
Retrieve a processed data export
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
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.
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 Order quantity in terms of the base asset. This is used to create an iceberg order, with display_volume as visible quantity, hiding rest of the order. This can only be used with |
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 2.12340000 XBTUSD @ limit 45000.1 with 2:1 leverage",
- "close": "close position @ stop loss 38000.0 -> limit 36000.0"
}, - "txid": [
- "OUF4EM-FRGI2-MQMWZD"
]
}
}
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.
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": [
- {
- "order": "buy 1.2 BTCUSD @ limit 40000 ",
- "txid": "OUF4EM-FRGI2-MQMWZD",
- "close": "close position @ stop loss 37000.0 -> limit 36000.0"
}, - {
- "order": "sell 1.2 BTCUSD @ limit 42000 ",
- "txid": "OCF5EM-FRGI2-MQWEDD"
}
]
}
}
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.
nonce required | integer <int32> (nonce) Nonce used in construction of |
userref | integer <int32> User reference id
|
required | string or 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 Order quantity in terms of the base asset, used to create an iceberg order. |
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": {
- "status": "ok",
- "txid": "OFVXHJ-KPQ3B-VS7ELA",
- "originaltxid": "OHYO67-6LP66-HMQ437",
- "volume": "0.00030000",
- "price": "19500.0",
- "price2": "32500.0",
- "orders_cancelled": 1,
- "descr": {
- "order": "buy 0.00030000 XXBTZGBP @ limit 19500.0"
}
}
}
Cancel a particular open order (or set of open orders) by txid
or userref
nonce required | integer <int32> (nonce) Nonce used in construction of |
required | string or integer Open order transaction ID (txid) or user reference (userref) |
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
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/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).
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": "2021-03-24T17:41:56Z",
- "triggerTime": "2021-03-24T17:42:56Z"
}
}
Cancel multiple open orders by txid
or userref
(maximum 50 total unique IDs/references)
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.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset required | string Asset being deposited |
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"
{- "result": [
- {
- "method": "string",
- "limit": null,
- "fee": "string",
- "address-setup-fee": "string",
- "gen-address": true
}
], - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve (or generate a new) deposit addresses for a particular asset and method.
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 |
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"
}
]
}
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.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter for specific asset being deposited |
method | string Filter for specific name of deposit method |
Array of objects (Deposit) | |
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"
{- "result": [
- {
- "method": "string",
- "aclass": "string",
- "asset": "string",
- "refid": "string",
- "txid": "string",
- "info": "string",
- "amount": "string",
- "fee": null,
- "time": 0,
- "status": null,
- "status-prop": "return",
- "originators": [
- "string"
]
}
], - "error": [
- "EGeneral:Invalid arguments"
]
}
Retrieve fee information about potential withdrawals for a particular asset, key and amount.
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.72485000",
- "fee": "0.00015000"
}
}
Make a withdrawal request.
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 than can be used to confirm address matches key (will return |
amount required | string Amount to be withdrawn |
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": "AGBSO6T-UFMTTQ-I7KGS6"
}
}
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.
nonce required | integer <int32> (nonce) Nonce used in construction of |
asset | string Filter for specific asset being withdrawn |
method | string Filter for specific name of withdrawal method |
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": "AGBZNBO-5P2XSB-RFVF6J",
- "txid": "THVRQM-33VKH-UCI7BS",
- "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
- "amount": "0.72485000",
- "fee": "0.00015000",
- "time": 1617014586,
- "status": "Pending"
}, - {
- "method": "Bitcoin",
- "aclass": "currency",
- "asset": "XXBT",
- "refid": "AGBSO6T-UFMTTQ-I7KGS6",
- "txid": "KLETXZ-33VKH-UCI7BS",
- "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
- "amount": "0.72485000",
- "fee": "0.00015000",
- "time": 1617015423,
- "status": "Failure",
- "status-prop": "canceled"
}
]
}
Cancel a recently requested withdrawal, if it has not already been successfully processed.
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": "AGBSO6T-UFMTTQ-I7KGS6" }, 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": "BOG5AE5-KSCNR4-VPNPEV"
}
}
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"
}
}
Stake an asset from your spot wallet. This operation requires an API key with Withdraw funds
permission.
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": "staked-xbt" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "BOG5AE5-KSCNR4-VPNPEV"
}
}
Unstake an asset from your staking wallet. This operation requires an API key with Withdraw funds
permission.
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, "method": "staked-xbt" }, api_key, api_sec) print(resp.json())
{- "error": [ ],
- "result": {
- "refid": "BOG5AE5-KSCNR4-VPNPEV"
}
}
Returns the list of assets that the user is able to stake. This operation
requires an API key with both Withdraw funds
and Query funds
permission.
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": [ ]
}
Returns the list of pending staking transactions. Once resolved, these transactions
will appear on the List of Staking Transactions
endpoint.
This operation requires an API key with both Query funds
and Withdraw funds
permissions.
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": 1622967367,
- "status": "Initial",
- "type": "bonding"
}, - {
- "method": "xtz-staked",
- "aclass": "currency",
- "asset": "XTZ.S",
- "refid": "RUCXX7O-6MWQBO-CQPGAX",
- "amount": "0.00746900",
- "fee": "0.00000000",
- "time": 1623074402,
- "status": "Initial",
- "type": "bonding"
}
], - "error": [ ]
}
Returns the list of 1000 recent staking transactions from past 90 days.
This operation requires an API key with Query funds
permissions.
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": 1622971496,
- "status": "Success",
- "type": "bonding",
- "bond_start": 1622971496,
- "bond_end": 1622971496
}, - {
- "method": "ada-staked",
- "aclass": "currency",
- "asset": "ADA.S",
- "refid": "RUSB7W6-ESIXUX-K6PVTM",
- "amount": "0.34844300",
- "fee": "0.00000000",
- "time": 1622967367,
- "status": "Success",
- "type": "bonding",
- "bond_start": 1622967367,
- "bond_end": 1622967367
}, - {
- "method": "eth2-staked",
- "aclass": "currency",
- "asset": "ETH2",
- "refid": "RUOCJP3-TWUJOE-L4EEG3",
- "amount": "0.0001943480",
- "fee": "0.0000000000",
- "time": 1622943004,
- "status": "Success",
- "type": "bonding",
- "bond_start": 1622943004,
- "bond_end": 1622943004
}
], - "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.
The 'Access WebSockets API' permission must be enabled for the API key in order to generate the authentication token.
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
}
}