General Usage

This document details use of Kraken's REST API for our spot exchange. The Websockets API and Kraken Futures API 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.

Support

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 full copy of the request(s) that you're attempting, including your IP address and all headers, so that we may investigate further.

Requests, Responses and Errors

Requests

Request payloads are form-encoded (Content-Type: application/x-www-form-urlencoded), and all requests must specify a User-Agent in their headers.

Responses

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)

Example Successful Response

{
  "error": [],
  "result": {
    "status": "online",
    "timestamp": "2021-03-22T17:18:03Z"
  }
}

GET https://api.kraken.com/0/public/SystemStatus

Example Rejection

{
  "error": [
    "EGeneral:Invalid arguments:ordertype"
  ]
}

Error Details

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 warning
  • category 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 error

Some Common Examples

Error Additional Info
EGeneral:Invalid arguments The request payload is malformed, incorrect or ambiguous.
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.)
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:Orders limit exceeded (See Rate Limits section)
EOrder:Rate limit exceeded (See Rate Limits section)
EOrder:Positions limit exceeded
EOrder:Unknown position

Additional information can be found on our support center.

Authentication

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 and 2FA

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.

Headers and Signature

API-Key

The "API-Key" header should contain your API key.

Security Scheme Type API Key
Header parameter name: API-Key

API-Sign

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

Example Signature

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 thie 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==

Code Examples

Python

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")
}

Node JS

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;
};
Security Scheme Type API Key
Header parameter name: API-Sign

Rate Limits

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.

REST API Rate Limits

Limits

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).

Errors

  • "EAPI:Rate limit exceeded" if the REST API counter exceeds the user's maximum.
  • "EService: Throttled: [UNIX timestamp]" if there are too many concurrent requests. Try again after [timestamp].

Additional information can be found on our support center.

Matching Engine Rate Limits

Limits

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

Penalties

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
Cancel Order +8 +6 +5 +4 +2 +1 0

Note: A client's exact ratecounter values can be monitored via the Websockets openOrders feed.

Errors

  • "EOrder:Orders limit exceeded" if the number of open orders in a given pair is exceeded
  • "EOrder:Rate limit exceeded" if the user's max ratecount is exceeded for a given pair

Additional information can be found on our support center.

Changelog

  • Sep 2021 - Add REST AddOrder support for optional parameter timeinforce and value ioc (Immediate-or-cancel)
  • July 2021 - Allow querying of WithdrawStatus with read-only API key permission "Query Ledgers".

Note: Most changes affecting our APIs or trading engine behaviour are currently being tracked on our Websockets changelog, until these documents are combined.

Example API Clients

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.

Third Party Software

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

Market Data

Get Server Time

Get the server's time.

Responses

Response Schema: application/json
object (ServerTime)
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Time"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "unixtime": 1616336594,
    • "rfc1123": "Sun, 21 Mar 21 14:23:14 +0000"
    }
}

Get System Status

Get the current system status or trading mode.

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/SystemStatus"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "status": "online",
    • "timestamp": "2021-03-21T15:33:02Z"
    }
}

Get Asset Info

Get information about the assets that are available for deposit, withdrawal, trading and staking.

query Parameters
asset
string
Example: asset=XBT,ETH

Comma delimited list of assets to get info on.

aclass
string
Example: aclass=currency

Asset class. (optional, default: currency)

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Assets"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBT": {
      • "aclass": "currency",
      • "altname": "XBT",
      • "decimals": 10,
      • "display_decimals": 5
      },
    • "ZEUR": {
      • "aclass": "currency",
      • "altname": "EUR",
      • "decimals": 4,
      • "display_decimals": 2
      },
    • "ZUSD": {
      • "aclass": "currency",
      • "altname": "USD",
      • "decimals": 4,
      • "display_decimals": 2
      }
    }
}

Get Tradable Asset Pairs

Get tradable asset pairs

query Parameters
pair
string
Example: pair=XXBTCZUSD,XETHXXBT

Asset pairs to get data for

info
string
Default: "info"
Enum: "info" "leverage" "fees" "margin"

Info to retrieve. (optional)

  • info = all info
  • leverage = leverage info
  • fees = fees schedule
  • margin = margin info

Responses

Response Schema: application/json
object

Pair names and their info

error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/AssetPairs?pair=XXBTZUSD,XETHXXBT"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XETHXXBT": {
      • "altname": "ETHXBT",
      • "wsname": "ETH/XBT",
      • "aclass_base": "currency",
      • "base": "XETH",
      • "aclass_quote": "currency",
      • "quote": "XXBT",
      • "lot": "unit",
      • "pair_decimals": 5,
      • "lot_decimals": 8,
      • "lot_multiplier": 1,
      • "leverage_buy": [
        ],
      • "leverage_sell": [
        ],
      • "fees": [
        ],
      • "fees_maker": [
        ],
      • "fee_volume_currency": "ZUSD",
      • "margin_call": 80,
      • "margin_stop": 40,
      • "ordermin": "0.005"
      },
    • "XXBTZUSD": {
      • "altname": "XBTUSD",
      • "wsname": "XBT/USD",
      • "aclass_base": "currency",
      • "base": "XXBT",
      • "aclass_quote": "currency",
      • "quote": "ZUSD",
      • "lot": "unit",
      • "pair_decimals": 1,
      • "lot_decimals": 8,
      • "lot_multiplier": 1,
      • "leverage_buy": [
        ],
      • "leverage_sell": [
        ],
      • "fees": [
        ],
      • "fees_maker": [
        ],
      • "fee_volume_currency": "ZUSD",
      • "margin_call": 80,
      • "margin_stop": 40,
      • "ordermin": "0.0002"
      }
    }
}

Get Ticker Information

Note: Today's prices start at midnight UTC

query Parameters
pair
required
string
Example: pair=XBTUSD

Asset pair to get data for

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Ticker?pair=XBTUSD"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBTZUSD": {
      • "a": [
        ],
      • "b": [
        ],
      • "c": [
        ],
      • "v": [
        ],
      • "p": [
        ],
      • "t": [
        ],
      • "l": [
        ],
      • "h": [
        ],
      • "o": "52280.40000"
      }
    }
}

Get OHLC Data

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.

query Parameters
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 committed OHLC data since given ID

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/OHLC?pair=XBTUSD"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBTZUSD": [
      • [
        ],
      • [
        ],
      • [
        ],
      • [
        ],
      • [
        ]
      ],
    • "last": 1616662920
    }
}

Get Order Book

query Parameters
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

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Depth?pair=XBTUSD"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBTZUSD": {
      • "asks": [
        ],
      • "bids": [
        ]
      }
    }
}

Get Recent Trades

Returns the last 1000 trades by default

query Parameters
pair
required
string
Example: pair=XBTUSD

Asset pair to get data for

since
string
Example: since=1616663618

Return trade data since given timestamp

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Trades?pair=XBTUSD"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBTZUSD": [
      • [
        ],
      • [
        ],
      • [
        ]
      ],
    • "last": "1616663622136576459"
    }
}

Get Recent Spreads

query Parameters
pair
required
string
Example: pair=XBTUSD

Asset pair to get data for

since
integer
Example: since=1548122302

Return spread data since given ID

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl "https://api.kraken.com/0/public/Spread?pair=XBTUSD"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "XXBTZUSD": [
      • [
        ],
      • [
        ],
      • [
        ]
      ],
    • "last": 1548122302
    }
}

User Data

Get Account Balance

Retrieve all cash balances, net of pending withdrawals.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
object (AccountBalance)

Account Balance

error
Array of strings

Request samples

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>"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "ZUSD": "171288.6158",
    • "ZEUR": "504861.8946",
    • "ZGBP": "459567.9171",
    • "ZAUD": "500000.0000",
    • "ZCAD": "500000.0000",
    • "CHF": "500000.0000",
    • "XXBT": "1011.1908877900",
    • "XXRP": "100000.00000000",
    • "XLTC": "2000.0000000000",
    • "XETH": "818.5500000000",
    • "XETC": "1000.0000000000",
    • "XREP": "1000.0000000000",
    • "XXMR": "1000.0000000000",
    • "USDT": "500000.00000000",
    • "DASH": "1000.0000000000",
    • "GNO": "1000.0000000000",
    • "EOS": "1000.0000000000",
    • "BCH": "1016.6005000000",
    • "ADA": "100000.00000000",
    • "QTUM": "1000.0000000000",
    • "XTZ": "100000.00000000",
    • "ATOM": "100000.00000000",
    • "SC": "9999.9999999999",
    • "LSK": "1000.0000000000",
    • "WAVES": "1000.0000000000",
    • "ICX": "1000.0000000000",
    • "BAT": "1000.0000000000",
    • "OMG": "1000.0000000000",
    • "LINK": "1000.0000000000",
    • "DAI": "9999.9999999999",
    • "PAXG": "1000.0000000000",
    • "ALGO": "100000.00000000",
    • "USDC": "100000.00000000",
    • "TRX": "100000.00000000",
    • "DOT": "2.5000000000",
    • "OXT": "1000.0000000000",
    • "ETH2.S": "198.3970800000",
    • "ETH2": "2.5885574330",
    • "USD.M": "1213029.2780"
    }
}

Get Trade Balance

Retrieve a summary of collateral balances, margin position valuations, equity and margin level.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
string
Default: "ZUSD"

Base asset used to determine balance

Responses

Response Schema: application/json
object (AccountBalance)

Account Balance

error
Array of strings

Request samples

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"

Response samples

Content type
application/json
{
  • "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"
    }
}

Get Open Orders

Retrieve information about currently open orders.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object (OpenOrders)

Open Orders

error
Array of strings

Request samples

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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "open": {
      • "OQCLML-BW3P3-BUCMWZ": {
        },
      • "OB5VMB-B4U2U-DK2WRW": {
        },
      • "OXHXGL-F5ICS-6DIC67": {
        },
      • "OLQCVY-B27XU-MBPCL5": {
        },
      • "OQCGAF-YRMIQ-AMJTNJ": {
        }
      }
    }
}

Get Closed Orders

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

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object (ClosedOrders)

Closed Orders

error
Array of strings

Request samples

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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "closed": {
      • "O37652-RJWRT-IMO74O": {
        },
      • "O6YDQ5-LOMWU-37YKEE": {
        }
      },
    • "count": 2
    }
}

Query Orders Info

Retrieve information about specific orders.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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 (20 maximum)

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "OBCMZD-JIEE7-77TH3F": {
      • "refid": null,
      • "userref": 0,
      • "status": "closed",
      • "reason": null,
      • "opentm": 1616665496.7808,
      • "closetm": 1616665499.1922,
      • "starttm": 0,
      • "expiretm": 0,
      • "descr": {
        },
      • "vol": "1.25000000",
      • "vol_exec": "1.25000000",
      • "cost": "37526.2",
      • "fee": "37.5",
      • "price": "30021.0",
      • "stopprice": "0.00000",
      • "limitprice": "0.00000",
      • "misc": "",
      • "oflags": "fciq",
      • "trades": [
        ]
      },
    • "OMMDB2-FSB6Z-7W3HPO": {
      • "refid": null,
      • "userref": 0,
      • "status": "closed",
      • "reason": null,
      • "opentm": 1616592012.2317,
      • "closetm": 1616592012.2335,
      • "starttm": 0,
      • "expiretm": 0,
      • "descr": {
        },
      • "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": [
        ]
      }
    }
}

Get Trades History

Retrieve information about trades/fills. 50 results are returned at a time, the most recent by default.

  • Unless otherwise stated, costs, fees, prices, and volumes are specified with the precision for the asset pair (pair_decimals and lot_decimals), not the individual assets' precision (decimals).
Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object (TradeHistory)

Trade History

error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "trades": {
      • "THVRQM-33VKH-UCI7BS": {
        },
      • "TCWJEG-FL4SZ-3FKGH6": {
        },
      • "TCCCTY-WE2O6-P3NB37": {
        },
      • "TZX2WP-XSEOP-FP7WYR": {
        },
      • "TJUW2K-FLX2N-AR2FLU": {
        },
      • "TKTFJU-O5OIY-63ZBF4": {
        },
      • "TRJPJP-6VYIP-5XLJZA": {
        },
      • "TSALPW-Q3HPI-LEPCOA": {
        },
      • "TQ7WSQ-U3R7T-ZUMFIY": {
        },
      • "T42BLA-LGJHI-LPVTTD": {
        },
      • "TUI2JG-VOE36-SW7UJQ": {
        },
      • "TXSFI3-5CTX5-LPTJHK": {
        },
      • "TDRIF6-7SGNJ-IAXFCN": {
        },
      • "T2PT3E-H6OGF-F5UABV": {
        },
      • "TJPO67-7TNED-Y2BRWM": {
        },
      • "TYYGJC-KEK4Q-L42ZQ4": {
        },
      • "TKK7S7-ZMT6O-AGOP6D": {
        },
      • "TP5XQL-ZN5PG-L6VSNV": {
        },
      • "TTIWU5-NQ4VO-JC5BQN": {
        },
      • "TMBTRV-FTDNZ-P3HUV5": {
        },
      • "TY44ZN-AIYOJ-SDR7GK": {
        },
      • "T5NRGS-AKQZV-ZHG4E4": {
        },
      • "T7CBB7-AQ5O7-P5GQSK": {
        },
      • "TENBB5-7BZEQ-TNBE66": {
        },
      • "TVLXY3-C6N3I-T25754": {
        },
      • "TJH4MR-DOYCR-5555SK": {
        },
      • "TXQ36N-GN7IZ-5PKY7L": {
        },
      • "T6LBB6-IFMBI-4YPXBX": {
        },
      • "T4M6VU-EECSP-MELY5T": {
        },
      • "TQA5B5-EZLVE-KTM4M5": {
        },
      • "TKSIRP-ZUYPW-62FLMV": {
        },
      • "TUEHX7-FFLNW-JMFAR7": {
        },
      • "TJKYBR-A5AYL-24MXFU": {
        },
      • "TRKPR4-GWUOY-CHPNRN": {
        },
      • "T37GPE-X26FG-5ZSIIB": {
        },
      • "TQM3FZ-THK6L-XSHSBX": {
        },
      • "TVDJWV-BADZ2-CV2THT": {
        },
      • "T3TO6H-GZ3UQ-SFA567": {
        },
      • "TQVOXK-5MOHP-SI5VAV": {
        },
      • "T4H46E-SDKQ2-MN47XT": {
        },
      • "TQMMMA-2OWI3-REGYSF": {
        },
      • "TJXDW4-C2AL5-MVS4S7": {
        },
      • "TW7OM6-3AZPP-KHOCDH": {
        },
      • "TVLE6Y-7THFG-DEWRL2": {
        },
      • "TTEUX3-HDAAA-RC2RUO": {
        },
      • "TK5SLP-HK2DZ-HJAQ3P": {
        },
      • "TB27WI-UMAET-QOYYZL": {
        },
      • "TEFPZR-SAZHO-HCT2LJ": {
        },
      • "TS6BLY-CYHBC-35B2WE": {
        },
      • "TUBIJ2-LJD26-EW3WKN": {
        }
      },
    • "count": 2346
    }
}

Query Trades Info

Retrieve information about specific trades/fills.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

txid
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

Responses

Response Schema: application/json
object

Trade info

error
Array of Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "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 Open Positions

Get information about open margin positions.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/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": ""
      }
    }
}

Get Ledgers Info

Retrieve information about ledger entries. 50 results are returned at a time, the most recent by default.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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"

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

Responses

Response Schema: application/json
object (LedgersInfo)

Ledgers Info

error
Array of strings

Request samples

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>"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "ledger": {
      • "L4UESK-KG3EQ-UFO4T5": {
        },
      • "LMKZCZ-Z3GVL-CXKK4H": {
        },
      • "L62PIO-H6GVL-RU7P2V": {
        },
      • "LYMXD5-CQXKP-YBJUC5": {
        },
      • "LTS2VY-3V54Z-UYMBJE": {
        },
      • "LBPAFZ-VIWB4-3LEIZK": {
        },
      • "L6FQNL-X2KVP-EK3B6P": {
        },
      • "LI25LJ-HGRV5-3XTQ4S": {
        },
      • "LOZQ2J-KQMA7-ONUKJQ": {
        },
      • "L27TEO-QPDH4-O5FHKS": {
        },
      • "LIXT22-MNMIS-AILGP7": {
        },
      • "L3DSXB-EDXWW-FWGY6E": {
        },
      • "LTIAS4-WQEAS-4VEU5O": {
        },
      • "LBXAYN-2PKLC-5HQYUP": {
        },
      • "L77IRV-V5QGW-XFIVFT": {
        }
      },
    • "count": 15
    }
}

Query Ledgers

Retrieve information about specific ledger entries.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "L4UESK-KG3EQ-UFO4T5": {
      • "refid": "TJKLXF-PGMUI-4NTLXU",
      • "time": 1610464484.1787,
      • "type": "trade",
      • "subtype": "",
      • "aclass": "currency",
      • "asset": "ZGBP",
      • "amount": "-24.5000",
      • "fee": "0.0490",
      • "balance": "459567.9171"
      }
    }
}

Get Trade Volume

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.

Authorizations:
query Parameters
pair
required
string
Example: pair=XBTUSD

Asset pair to get data for

Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

pair
string

Comma delimited list of asset pairs to get fee info on (optional)

fee-info
boolean

Whether or not to include fee info in results (optional)

Responses

Response Schema: application/json
object (TradeVolume)

Trade Volume

error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "currency": "ZUSD",
    • "volume": "200709587.4223",
    • "fees": {
      • "XXBTZUSD": {
        }
      },
    • "fees_maker": {
      • "XXBTZUSD": {
        }
      }
    }
}

Request Export Report

Request export of trades or ledgers.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

  • trades: ordertxid, time, ordertype, price, cost, fee, vol, margin, misc, ledgers
  • ledgers: refid, time, type, aclass, asset, amount, fee, balance
starttm
integer

UNIX timestamp for report start time (default 1st of the current month)

endtm
integer

UNIX timestamp for report end time (default now)

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "id": "TCJA"
    }
}

Get Export Report Status

Get status of requested data exports.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

report
required
string
Enum: "trades" "ledgers"

Type of reports to inquire about

Responses

Response Schema: application/json
Array of objects
error
Array of strings

Request samples

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())

Response samples

Content type
application/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 Data Export

Retrieve a processed data export

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

id
required
string

Report ID to retrieve

Responses

Response Schema: application/octet-stream
report
string <binary>

Binary zip archive containing the report

Request samples

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 Export Report

Delete exported trades/ledgers report

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

id
required
string

ID of report to delete or cancel

type
required
string
Enum: "cancel" "delete"

delete can only be used for reports that have already been processed. Use cancel for queued or processing reports.

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "delete": true
    }
}

User Trading

Add Order

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.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

userref
integer <int32>

User reference id

userref is an optional user-specified integer id that can be associated with any number of orders. Many clients choose a userref corresponding to a unique integer id generated by their systems (e.g. a timestamp). However, because we don't enforce uniqueness on our side, it can also be used to easily group orders by pair, side, strategy, etc. This allows clients to more readily cancel or query information about orders in a particular group, with fewer API calls by using userref instead of our txid, where supported.

ordertype
required
string
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
string

Order quantity in terms of the base asset

Note: Volume can be specified as 0 for closing margin orders to automatically fill the requisite quantity.

pair
required
string

Asset pair id or altname

price
string

Price

  • Limit price for limit orders
  • Trigger price for stop-loss, stop-loss-limit, take-profit and take-profit-limit orders
price2
string

Secondary Price

  • Limit price for stop-loss-limit and take-profit-limit orders

Note: Either price or price2 can be preceded by +, -, or # to specify the order price as an offset relative to the last traded price. + adds the amount to, and - subtracts the amount from the last traded price. # will either add or subtract the amount to the last traded price, depending on the direction and order type used. Relative prices can be suffixed with a % to signify the relative amount as a percentage.

leverage
string

Amount of leverage desired (default = none)

oflags
string

Comma delimited list of order flags

  • post post-only order (available when ordertype = limit)
  • fcib prefer fee in base currency (default if selling)
  • fciq prefer fee in quote currency (default if buying, mutually exclusive with fcib)
  • nompp disable market price protection for market orders
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 expiretm.

starttm
string

Scheduled start time. Can be specified as an absolute timestamp or as a number of seconds in the future.

  • 0 now (default)
  • +<n> schedule start time seconds from now
  • <n> = unix timestamp of start time
expiretm
string

Expiration time

  • 0 no expiration (default)
  • +<n> = expire seconds from now, minimum 5 seconds
  • <n> = unix timestamp of expiration time
close[ordertype]
string
Enum: "limit" "stop-loss" "take-profit" "stop-loss-limit" "take-profit-limit"

Conditional close order type.

Note: Conditional close orders are triggered by execution of the primary order in the same quantity and opposite direction, but once triggered are independent orders that may reduce or increase net position.

close[price]
string

Conditional close order price

close[price2]
string

Conditional close order price2

validate
boolean
Default: false

Validate inputs only. Do not submit order.

Responses

Response Schema: application/json
object (OrderAdded)
error
Array of Array of strings

Request samples

// 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"

Response samples

Content type
application/json
Example
{
  • "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"
      ]
    }
}

Cancel Order

Cancel a particular open order (or set of open orders) by txid or userref

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

required
string or integer

Open order transaction ID (txid) or user reference (userref)

Responses

Response Schema: application/json
object (OrderCancelled)
error
Array of Array of strings

Request samples

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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "count": 1
    }
}

Cancel All Orders

Cancel all open orders

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl -X "POST" "http://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>"  

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "count": 4
    }
}

Cancel All Orders After X

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).

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

timeout
required
integer

Duration (in seconds) to set/extend the timer by

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl -X "POST" "http://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" 

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "currentTime": "2021-03-24T17:41:56Z",
    • "triggerTime": "2021-03-24T17:42:56Z"
    }
}

User Funding

Get Deposit Methods

Retrieve methods available for depositing a particular asset.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset being deposited

Responses

Response Schema: application/json
Array of objects (depositMethod)
error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": [
    • {
      • "method": "Bitcoin",
      • "limit": false,
      • "fee": "0.0000000000",
      • "gen-address": true
      }
    ]
}

Get Deposit Addresses

Retrieve (or generate a new) deposit addresses for a particular asset and method.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
Array of objects (depositAddress)
error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": [
    • {
      • "address": "2N9fRkx5JTWXWHmXzZtvhQsufvoYRMq9ExV",
      • "expiretm": "0",
      • "new": true
      },
    • {
      • "address": "2NCpXUCEYr8ur9WXM1tAjZSem2w3aQeTcAo",
      • "expiretm": "0",
      • "new": true
      },
    • {
      • "address": "2Myd4eaAW96ojk38A2uDK4FbioCayvkEgVq",
      • "expiretm": "0"
      }
    ]
}

Get Status of Recent Deposits

Retrieve information about recent deposits made.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset being deposited

method
string

Name of the deposit method

Responses

Response Schema: application/json
Array of objects (Deposit)
error
Array of strings

Request samples

curl -X "POST" "http://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"

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": [
    • {
      • "method": "Bitcoin",
      • "aclass": "currency",
      • "asset": "XXBT",
      • "refid": "QGBCOYA-UNP53O-F2JDNS",
      • "txid": "6544b41b607d8b2512baf801755a3a87b6890eacdb451be8a94059fb11f0a8d9",
      • "info": "2Myd4eaAW96ojk38A2uDK4FbioCayvkEgVq",
      • "amount": "0.78125000",
      • "fee": "0.0000000000",
      • "time": 1546992722,
      • "status": "Success"
      },
    • {
      • "method": "Bitcoin",
      • "aclass": "currency",
      • "asset": "XXBT",
      • "refid": "QGBHU3O-73ARA5-IFCFZT",
      • "txid": "fe12122222fe7fb1bc756a10ecd25f93015e959810ff1daf56535b9b01a803af",
      • "info": "2Myd4eaAW96ojk38A2uDK4FbioCayvkEgVq",
      • "amount": "0.78125000",
      • "time": 1546992722,
      • "status": "Settled"
      }
    ]
}

Get Withdrawal Information

Retrieve fee information about potential withdrawals for a particular asset, key and amount.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object (withdrawalInfo)

Withdrawal Info

error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "method": "Bitcoin",
    • "limit": "332.00956139",
    • "amount": "0.72485000",
    • "fee": "0.00015000"
    }
}

Withdraw Funds

Make a withdrawal request.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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",
    "amount": 0.725
}, api_key, api_sec)

print(resp.json())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "refid": "AGBSO6T-UFMTTQ-I7KGS6"
    }
}

Get Status of Recent Withdrawals

Retrieve information about recently requests withdrawals.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset being withdrawn

method
string

Name of the withdrawal method

Responses

Response Schema: application/json
Array of objects (Withdrawal)
error
Array of strings

Request samples

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())),
    "asset": "XBT"
}, api_key, api_sec)

print(resp.json())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": [
    • {
      • "method": "Bitcoin",
      • "aclass": "currency",
      • "asset": "XXBT",
      • "refid": "AGBZNBO-5P2XSB-RFVF6J",
      • "txid": null,
      • "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
      • "amount": "0.72485000",
      • "fee": "0.00015000",
      • "time": 1617014586,
      • "status": "Pending"
      },
    • {
      • "method": "Bitcoin",
      • "aclass": "currency",
      • "asset": "XXBT",
      • "refid": "AGBSO6T-UFMTTQ-I7KGS6",
      • "txid": null,
      • "info": "mzp6yUVMRxfasyfwzTZjjy38dHqMX7Z3GR",
      • "amount": "0.72485000",
      • "fee": "0.00015000",
      • "time": 1617015423,
      • "status": "Failure",
      • "status-prop": "canceled"
      }
    ]
}

Request Withdrawal Cancelation

Cancel a recently requested withdrawal, if it has not already been successfully processed.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset being withdrawn

refid
required
string

Withdrawal reference ID

Responses

Response Schema: application/json
result
boolean

Whether cancellation was successful or not.

error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": true
}

Request Wallet Transfer

Transfer from Kraken spot wallet to Kraken Futures holding wallet. Note that a transfer in the other direction must be requested via the Kraken Futures API endpoint.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset to transfer (asset ID or altname)

from
required
string
Value: "Spot Wallet"

Source wallet

to
required
string
Value: "Futures Wallet"

Destination wallet

amount
required
string

Amount to transfer

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "refid": "BOG5AE5-KSCNR4-VPNPEV"
    }
}

User Staking

Stake Asset

Stake an asset from your spot wallet. This operation requires an API key with Withdraw funds permission.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset to stake (asset ID or altname)

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)

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "refid": "BOG5AE5-KSCNR4-VPNPEV"
    }
}

Unstake Asset

Unstake an asset from your staking wallet. This operation requires an API key with Withdraw funds permission.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

asset
required
string

Asset to unstake (asset ID or altname). Must be a valid staking asset (e.g. XBT.M, XTZ.S, ADA.S)

amount
required
string

Amount of the asset to stake

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "refid": "BOG5AE5-KSCNR4-VPNPEV"
    }
}

List of Stakeable Assets

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.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
Array of objects (Staking Asset Information)
error
Array of strings

Request samples

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())

Response samples

Content type
application/json
{
  • "result": [
    • {
      • "method": "polkadot-staked",
      • "asset": "DOT",
      • "staking_asset": "DOT.S",
      • "rewards": {
        },
      • "on_chain": true,
      • "can_stake": true,
      • "can_unstake": true,
      • "minimum_amount": {
        }
      },
    • {
      • "method": "kusama-staked",
      • "asset": "KSM",
      • "staking_asset": "KSM.S",
      • "rewards": {
        },
      • "on_chain": true,
      • "can_stake": true,
      • "can_unstake": true,
      • "minimum_amount": {
        }
      }
    ],
  • "error": [ ]
}

Get Pending Staking Transactions

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.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
Array of objects (Staking Transaction Info)
error
Array of strings

Request samples

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())

Response samples

Content type
application/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": [ ]
}

List of Staking Transactions

Returns the list of all staking transactions. This endpoint can only return up to 1000 of the most recent transactions.

This operation requires an API key with Query funds permissions.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
Array of objects (Staking Transaction Info)
error
Array of strings

Request samples

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())

Response samples

Content type
application/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": [ ]
}

Websockets Authentication

Get Websockets Token

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.

Authorizations:
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32>

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
object
error
Array of strings

Request samples

curl -X "POST" "http://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>" 

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "token": "1Dwc4lzSwNWOAwkMdqhssNNFhs1ed606d1WcF3XfEMw",
    • "expires": 900
    }
}