Skip to main content
POST
/
private
/
AddOrderBatch
Add Order Batch
curl --request POST \
  --url https://api.kraken.com/0/private/AddOrderBatch \
  --header 'API-Key: <api-key>' \
  --header 'API-Sign: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "nonce": 1695828490,
  "orders": [
    {
      "close": {
        "ordertype": "stop-loss-limit",
        "price": "37000",
        "price2": "36000"
      },
      "ordertype": "limit",
      "price": "40000",
      "price2": "string",
      "timeinforce": "GTC",
      "type": "buy",
      "cl_ord_id": "6d1b345e-2821-40e2-ad83-4ecb18a06876",
      "volume": "1.2"
    },
    {
      "ordertype": "limit",
      "price": "42000",
      "starttm": "string",
      "timeinforce": "GTC",
      "type": "sell",
      "cl_ord_id": "da8e4ad59b78481c93e589746b0cf91",
      "volume": "1.2"
    }
  ],
  "pair": "BTC/USD",
  "validate": false,
  "deadline": "2023-09-24T14:15:22Z"
}
'
import requests

url = "https://api.kraken.com/0/private/AddOrderBatch"

payload = {
"nonce": 1695828490,
"orders": [
{
"close": {
"ordertype": "stop-loss-limit",
"price": "37000",
"price2": "36000"
},
"ordertype": "limit",
"price": "40000",
"price2": "string",
"timeinforce": "GTC",
"type": "buy",
"cl_ord_id": "6d1b345e-2821-40e2-ad83-4ecb18a06876",
"volume": "1.2"
},
{
"ordertype": "limit",
"price": "42000",
"starttm": "string",
"timeinforce": "GTC",
"type": "sell",
"cl_ord_id": "da8e4ad59b78481c93e589746b0cf91",
"volume": "1.2"
}
],
"pair": "BTC/USD",
"validate": False,
"deadline": "2023-09-24T14:15:22Z"
}
headers = {
"API-Key": "<api-key>",
"API-Sign": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'API-Key': '<api-key>',
'API-Sign': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
nonce: 1695828490,
orders: [
{
close: {ordertype: 'stop-loss-limit', price: '37000', price2: '36000'},
ordertype: 'limit',
price: '40000',
price2: 'string',
timeinforce: 'GTC',
type: 'buy',
cl_ord_id: '6d1b345e-2821-40e2-ad83-4ecb18a06876',
volume: '1.2'
},
{
ordertype: 'limit',
price: '42000',
starttm: 'string',
timeinforce: 'GTC',
type: 'sell',
cl_ord_id: 'da8e4ad59b78481c93e589746b0cf91',
volume: '1.2'
}
],
pair: 'BTC/USD',
validate: false,
deadline: '2023-09-24T14:15:22Z'
})
};

fetch('https://api.kraken.com/0/private/AddOrderBatch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.kraken.com/0/private/AddOrderBatch"

payload := strings.NewReader("{\n \"nonce\": 1695828490,\n \"orders\": [\n {\n \"close\": {\n \"ordertype\": \"stop-loss-limit\",\n \"price\": \"37000\",\n \"price2\": \"36000\"\n },\n \"ordertype\": \"limit\",\n \"price\": \"40000\",\n \"price2\": \"string\",\n \"timeinforce\": \"GTC\",\n \"type\": \"buy\",\n \"cl_ord_id\": \"6d1b345e-2821-40e2-ad83-4ecb18a06876\",\n \"volume\": \"1.2\"\n },\n {\n \"ordertype\": \"limit\",\n \"price\": \"42000\",\n \"starttm\": \"string\",\n \"timeinforce\": \"GTC\",\n \"type\": \"sell\",\n \"cl_ord_id\": \"da8e4ad59b78481c93e589746b0cf91\",\n \"volume\": \"1.2\"\n }\n ],\n \"pair\": \"BTC/USD\",\n \"validate\": false,\n \"deadline\": \"2023-09-24T14:15:22Z\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("API-Key", "<api-key>")
req.Header.Add("API-Sign", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
{
  "error": [],
  "result": {
    "orders": [
      {
        "txid": "O5OR23-ADFAD-Y2G61C",
        "descr": {
          "order": "buy 0.80300000 XBTUSD @ limit 28300.0",
          "close": "close position @ stop loss 27000.0 -> limit 26000.0"
        }
      },
      {
        "txid": "9K6KFS-5H3PL-XBRC7A",
        "descr": {
          "order": "sell 0.10500000 XBTUSD @ limit 36000.0"
        }
      }
    ]
  }
}

Authorizations

API-Key
string
header
required

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

API-Sign
string
header
required

Authenticated requests should be signed with the "API-Sign" header, using a signature generated with your private key, nonce, encoded payload, and URI path.

Body

application/json
nonce
integer<int64>
required

Nonce used in construction of API-Sign header

orders
object[]
required
pair
string
required

Asset pair id or altname

asset_class
enum<string>

This parameter is required on requests for non-crypto pairs, i.e. use tokenized_asset for xstocks.

Available options:
tokenized_asset
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.

broker
string | null

Broker IIBAN (Partner's Kraken IIBAN)

Response

200 - application/json

The order of returned orders in the response array is the same as the order of the order list sent in request.

result
Result · object
error
string[][]

Kraken API error