REST API (1.1.0)

Download OpenAPI specification:Download

General Usage

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.

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

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

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

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

Note: Master accounts and subaccounts will share the same default trading rate limits as determined by the master account's tier.

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

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

  • May 2023 - Added address parameter to Withdraw.
  • Mar 2023 - Added originators paramater to DepositStatus.
  • Feb 2023 - Added long and short margin position limits to AssetPairs.
  • Feb 2023 - Specified minimum and maximum number of txids and userrefs for CancelOrderBatch.
  • Feb 2023 - Specified maximum number of responses for DepositStatus and WithdrawStatus.
  • Feb 2023 - Note to use %2b instead of + for URL encoding in AddOrder starttm and expiretm parameters.
  • Jan 2023 - Removed requirement for asset in DepositStatus and WithdrawalStatus.
  • Jan 2023 - Documented reduce_only parameter in AddOrder and AddOrderBatch.
  • Jan 2023 - Added consolidate_taker to TradesHistory and QueryTrades.
  • Jan 2023 - Added User Subaccounts section with CreateSubaccount and AccountTransfer endpoints.
  • Jan 2023 - Added trade_id to private TradesHistory.
  • Dec 2022 - Fixed pair parameter restriction on TradeVolume.
  • Dec 2022 - EditOrder allowed on margin orders.
  • Nov 2022 - Added tick_size and status parameters to AssetPairs, status and collateral_value to Assets, and trade_id to public Trades.
  • Oct 2022 - Documented uv (unexecuted value) field in TradeBalance.
  • Oct 2022 - Added costmin trading parameter to AssetPairs.
  • Oct 2022 - Ticker wildcard support - pair no longer required, no pair parameter returns tickers for all tradeable exchange assets.
  • Sep 2022 - AddOrder/EditOrder/AddOrderBatch now support icebergs.
  • July 2022 - Added support for restricting API keys to specified IP address(es)/range.
  • June 2022 - Added custom self trade prevention options.
  • May 2022 - New REST AddOrderBatch endpoint to send multiple new orders and CancelOrderBatch endpoint to cancel multiple open orders.
  • Mar 2022 - New REST EditOrder endpoint to edit volume and price on open orders.
  • Dec 2021 - Add REST 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.

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

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

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

Request samples

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

Response samples

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

Get tradable asset pairs

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

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

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",
      • "cost_decimals": 6,
      • "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.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": [
        ],
      • "leverage_sell": [
        ],
      • "fees": [
        ],
      • "fees_maker": [
        ],
      • "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
      }
    }
}

Get Ticker Information

Note: Today's prices start at midnight UTC. Leaving the pair parameter blank will return tickers for all tradeable assets on Kraken.

query Parameters
pair
string
Example: pair=XBTUSD

Asset pair to get data for (optional, default: all tradeable exchange pairs)

Responses

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

Request samples

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

Response samples

Content type
application/json
{
  • "result": {
    • "pair1": {
      • "a": [
        ],
      • "b": [
        ],
      • "c": [
        ],
      • "v": [
        ],
      • "p": [
        ],
      • "t": [
        ],
      • "l": [
        ],
      • "h": [
        ],
      • "o": "string"
      },
    • "pair2": {
      • "a": [
        ],
      • "b": [
        ],
      • "c": [
        ],
      • "v": [
        ],
      • "p": [
        ],
      • "t": [
        ],
      • "l": [
        ],
      • "h": [
        ],
      • "o": "string"
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

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 up to 720 OHLC data points since given timestamp

Responses

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

Request samples

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

Response samples

Content type
application/json
{
  • "result": {
    • "last": 0,
    • "pair1": [
      • [
        ]
      ],
    • "pair2": [
      • [
        ]
      ]
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

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

Request samples

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

Response samples

Content type
application/json
{
  • "result": {
    • "pair1": {
      • "asks": [
        ],
      • "bids": [
        ]
      },
    • "pair2": {
      • "asks": [
        ],
      • "bids": [
        ]
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

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

Request samples

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

Response samples

Content type
application/json
{
  • "result": {
    • "last": "string",
    • "pair1": [
      • [
        ]
      ],
    • "pair2": [
      • [
        ]
      ]
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Get Recent Spreads

Returns the last ~200 top-of-book spreads for a given pair

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

Responses

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

Request samples

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

Response samples

Content type
application/json
{
  • "result": {
    • "last": 0,
    • "pair1": [
      • [
        ]
      ],
    • "pair2": [
      • [
        ]
      ]
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

User Data

Get Account Balance

Retrieve all cash balances, net of pending withdrawals.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

Response Schema: application/json
object (AccountBalance)

Account Balance

error
Array of strings (error)

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
{
  • "result": {
    • "ZUSD": "2970172.7962"
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Get Trade Balance

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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
{
  • "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"
    ]
}

Get Open Orders

Retrieve information about currently open orders.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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
{
  • "result": {
    • "open": {
      • "txid1": {
        },
      • "txid2": {
        }
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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
{
  • "result": {
    • "closed": {
      • "txid1": {
        },
      • "txid2": {
        }
      },
    • "count": 0
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Query Orders Info

Retrieve information about specific orders.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

consolidate_taker
boolean
Default: true

Whether or not to consolidate trades by individual taker trades

Responses

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

Request samples

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"

Response samples

Content type
application/json
{
  • "result": {
    • "txid1": {
      • "refid": "string",
      • "userref": "string",
      • "status": "pending",
      • "opentm": 0,
      • "starttm": 0,
      • "expiretm": 0,
      • "descr": {
        },
      • "vol": "string",
      • "vol_exec": "string",
      • "cost": "string",
      • "fee": "string",
      • "price": "string",
      • "stopprice": "string",
      • "limitprice": "string",
      • "trigger": "last",
      • "misc": "string",
      • "oflags": "string",
      • "trades": [
        ]
      },
    • "txid2": {
      • "refid": "string",
      • "userref": "string",
      • "status": "pending",
      • "opentm": 0,
      • "starttm": 0,
      • "expiretm": 0,
      • "descr": {
        },
      • "vol": "string",
      • "vol_exec": "string",
      • "cost": "string",
      • "fee": "string",
      • "price": "string",
      • "stopprice": "string",
      • "limitprice": "string",
      • "trigger": "last",
      • "misc": "string",
      • "oflags": "string",
      • "trades": [
        ]
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

consolidate_taker
boolean
Default: true

Whether or not to consolidate trades by individual taker trades

Responses

Response Schema: application/json
object (TradeHistory)

Trade History

error
Array of strings (error)

Request samples

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"

Response samples

Content type
application/json
{
  • "result": {
    • "count": 0,
    • "trades": {
      • "txid1": {
        },
      • "txid2": {
        }
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Query Trades Info

Retrieve information about specific trades/fills.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

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

Responses

Response Schema: application/json
object

Trade info

error
Array of strings (error) [ items ]

Request samples

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"

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

Responses

Response Schema: application/json
object (LedgersInfo)

Ledgers Info

error
Array of strings (error)

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
{
  • "result": {
    • "ledger": {
      • "ledger_id1": {
        },
      • "ledger_id2": {
        }
      },
    • "count": 0
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Query Ledgers

Retrieve information about specific ledger entries.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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
{
  • "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"
    ]
}

Get Trade Volume

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.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

pair
string

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

Responses

Response Schema: application/json
object (TradeVolume)

Trade Volume

error
Array of strings (error)

Request samples

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"

Response samples

Content type
application/json
{
  • "result": {
    • "currency": "string",
    • "volume": "string",
    • "fees": {
      • "pair1": {
        },
      • "pair2": {
        }
      },
    • "fees_maker": {
      • "pair1": {
        },
      • "pair2": {
        }
      }
    },
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Request Export Report

Request export of trades or ledgers.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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

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 limit order type.

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.

trigger
string
Default: "last"
Enum: "index" "last"

Price signal used to trigger stop-loss, stop-loss-limit, take-profit and take-profit-limit orders

Note: This trigger type will as well be used for associated conditional close orders.

leverage
string

Amount of leverage desired (default: none)

reduce_only
boolean
Default: false

If true, order will only reduce a currently open position, not increase it or open a new position.

stptype
string
Default: "cancel-newest"
Enum: "cancel-newest" "cancel-oldest" "cancel-both"

Self trade prevention behavior definition:

  • cancel-newest - if self trade is triggered, arriving order will be canceled
  • cancel-oldest - if self trade is triggered, resting order will be canceled
  • cancel-both - if self trade is triggered, both arriving and resting orders will be canceled
oflags
string (oflags)

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
  • viqc order volume expressed in quote currency. This is supported only 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> = unix timestamp of start time
  • +<n> = schedule start time <n> seconds from now
    • Note that URL encoding of the + character changes it to a space, so please use %2b followed by the number of seconds instead of +
expiretm
string

Expiration time, also can be specified as an absolute timestamp or as a number of seconds in the future:

  • 0 no expiration (default)
  • <n> = unix timestamp of expiration time
  • +<n> = expire <n> seconds from now, minimum 5 seconds
    • Note that URL encoding of the + character changes it to a space, so please use %2b followed by the number of seconds instead of +
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

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.

Responses

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

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

Add Order Batch

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.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

required
Array of objects
pair
required
string

Asset pair id or altname

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.

Responses

Response Schema: application/json
object (Result)
error
Array of strings (error) [ items ]

Request samples

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

Response samples

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

Edit Order

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.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

userref
integer <int32>

User reference id

userref is an optional user-specified integer id associated with edit request.

Note: userref from parent order will not be retained on the new order after edit.

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

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.

Responses

Response Schema: application/json
object (OrderEdited)
error
Array of strings (error) [ items ]

Request samples

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

Response samples

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

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

required
string or integer

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

Responses

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

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

Request samples

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

Request samples

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" 

Response samples

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

Cancel Order Batch

Cancel multiple open orders by txid or userref (maximum 50 total unique IDs/references)

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

required
Array of objects

Responses

Request samples

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"],
      }

      

Response samples

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

User Funding

Get Deposit Methods

Retrieve methods available for depositing a particular asset.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

Request samples

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"

Response samples

Content type
application/json
{
  • "result": [
    • {
      • "method": "string",
      • "limit": null,
      • "fee": "string",
      • "address-setup-fee": "string",
      • "gen-address": true
      }
    ],
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Get Deposit Addresses

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

Request samples

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"

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. Any deposits initiated in the past 90 days will be included in the response, up to a maximum of 25 results, sorted by recency.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

asset
string

Filter for specific asset being deposited

method
string

Filter for specific name of deposit method

Responses

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

Request samples

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"

Response samples

Content type
application/json
{
  • "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": [
        ]
      }
    ],
  • "error": [
    • "EGeneral:Invalid arguments"
    ]
}

Get Withdrawal Information

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

address
string

Optional, crypto address than can be used to confirm address matches key (will return Invalid withdrawal address error if different)

amount
required
string

Amount to be withdrawn

Responses

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

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",
    "address": "bc1kar0ssrr7xf3vy5l6d3lydnwkre5og2zz3f5ldq",
    "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 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.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

asset
string

Filter for specific asset being withdrawn

method
string

Filter for specific name of withdrawal method

Responses

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

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()))
}, 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": "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"
      }
    ]
}

Request Withdrawal Cancelation

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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 Subaccounts

Subaccounts are currently only available to institutional clients. Please contact your Account Manager for more details.

Create Subaccount

Create a trading subaccount.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

username
required
string

Username for the subaccount

email
required
string

Email address for the subaccount

Responses

Response Schema: application/json
result
boolean

Whether subaccount creation was successful or not.

error
Array of strings (error)

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/CreateSubaccount', {
    "nonce": str(int(1000*time.time())),
    "username": "abc123",
    "email": "abc123@gmail.com"
}, api_key, api_sec)

print(resp.json())

Response samples

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

Account Transfer

Transfer funds to and from master and subaccounts. Note: AccountTransfer must be called by the master account.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

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

Responses

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

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

Response samples

Content type
application/json
{
  • "error": [ ],
  • "result": {
    • "transfer_id": "TOH3AS2-LPCWR8-JDQGEU",
    • "status": "complete"
    }
}

User Staking

Stake Asset

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

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

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

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 1000 recent staking transactions from past 90 days.

This operation requires an API key with Query funds permissions.

Authorizations:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

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

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:
(API-KeyAPI-Sign)
Request Body schema: application/x-www-form-urlencoded
nonce
required
integer <int32> (nonce)

Nonce used in construction of API-Sign header

Responses

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

Request samples

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

Response samples

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