Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sieblyio/kraken-api/llms.txt

Use this file to discover all available pages before exploring further.

All order management methods are private endpoints — they require a valid API key and secret. These methods cover the full order lifecycle: placing single and batch orders, amending open orders, cancelling individual or all orders, and the Dead Man’s Switch safety mechanism.
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});
API key permissions required: Orders and trades — Create & modify orders. Use getAssetPairs() to look up trading pair constraints (ordermin, costmin, tick_size) before placing orders.

generateNewOrderID()

A utility helper that generates a unique 32-character hex string suitable for use as a cl_ord_id. Call this before submitOrder() to track your orders without depending on the Kraken-assigned txid. Signature
generateNewOrderID(): string
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({ /* ... */ });

const clOrdId = client.generateNewOrderID();
// e.g. 'a3f1c2d4e5b60789abcdef0123456789'

const order = await client.submitOrder({
  ordertype: 'limit',
  type: 'buy',
  pair: 'XBTUSD',
  volume: '0.001',
  price: '50000',
  cl_ord_id: clOrdId,
});

submitOrder(params)

Place a new order on the spot exchange. Supports all order types including market, limit, stop-loss, take-profit, and trailing stops. Signature
submitOrder(
  params: SpotSubmitOrderParams
): Promise<SpotAPISuccessResponse<SpotSubmitOrderResponse>>
Required parameters
ordertype
string
required
Order type. One of: market, limit, iceberg, stop-loss, take-profit, stop-loss-limit, take-profit-limit, trailing-stop, trailing-stop-limit, settle-position.
type
'buy' | 'sell'
required
Order direction.
volume
string
required
Order quantity in base currency (as a string-encoded decimal).
pair
string
required
Asset pair to trade (e.g. "XBTUSD").
Optional parameters
price
string
Limit price for limit, stop-loss-limit, take-profit-limit orders. Stop price for stop-loss, take-profit, trailing-stop, trailing-stop-limit orders.
price2
string
Secondary price for limit portion of stop-loss-limit and take-profit-limit orders, or trailing offset for trailing stops.
trigger
'index' | 'last'
Price signal to trigger stop orders. Defaults to last.
leverage
string
Leverage factor for margin orders (e.g. "2:1").
reduce_only
boolean
If true, the order only reduces an existing margin position and never opens a new one.
stptype
'cancel-newest' | 'cancel-oldest' | 'cancel-both'
Self-trade prevention behaviour when both sides of a trade would belong to the same account. cancel-newest cancels the incoming order; cancel-oldest cancels the resting order; cancel-both cancels both.
oflags
string
Comma-delimited order flags:
  • post — post-only order (maker only)
  • fcib — prefer fee in base currency
  • fciq — prefer fee in quote currency
  • nompp — no market price protection
  • viqc — volume in quote currency
timeinforce
'GTC' | 'IOC' | 'GTD' | 'FOK'
Time-in-force policy. GTC = Good-Til-Cancelled, IOC = Immediate-Or-Cancel, GTD = Good-Til-Date, FOK = Fill-Or-Kill.
starttm
string
Scheduled start time. 0 for now, +<n> for n seconds from now, or Unix timestamp.
expiretm
string
Expiration time. Same format as starttm.
deadline
string
RFC3339 timestamp after which the order should be rejected if not yet placed (max 60 seconds in the future).
cl_ord_id
string
Client-defined order ID (max 36 characters). Recommended — use generateNewOrderID() to create one.
userref
number
Integer user reference ID for grouping orders.
displayvol
string
Visible quantity for iceberg orders. Must be less than volume.
validate
boolean
If true, validates the order but does not submit it. Useful for parameter testing.
'close[ordertype]'
string
Closing order type to attach (conditional close). E.g. "limit".
'close[price]'
string
Closing order price.
'close[price2]'
string
Closing order secondary price.
asset_class
'tokenized_asset'
Asset class of the pair.
PropertyValue
HTTP methodPOST
Endpoint0/private/AddOrder
Auth requiredYes
Response shapeSpotSubmitOrderResponse
FieldTypeDescription
descr.orderstringHuman-readable order description
descr.closestring?Close order description (if attached)
txidstring[]Array of transaction IDs assigned by Kraken
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const order = await client.submitOrder({
  ordertype: 'market',
  type: 'buy',
  volume: '0.01',
  pair: 'XBTUSD',
  cl_ord_id: client.generateNewOrderID(),
});

console.log('Order description:', order.result.descr.order);
console.log('Transaction IDs:', order.result.txid);

amendOrder(params)

Amend an existing open order. The order’s Kraken transaction ID and client order ID remain unchanged, and queue priority is maintained where possible. Signature
amendOrder(
  params: SpotAmendOrderParams
): Promise<SpotAPISuccessResponse<{ amend_id: string }>>
txid
string
Transaction ID of the order to amend. Either txid or cl_ord_id is required.
cl_ord_id
string
Client order ID of the order to amend.
order_qty
string
New order quantity (total, not delta).
display_qty
string
New display quantity for iceberg orders.
limit_price
string
New limit price.
trigger_price
string
New trigger/stop price.
pair
string
Asset pair (required for some amend operations).
post_only
boolean
Update post-only flag.
deadline
string
RFC3339 deadline timestamp.
PropertyValue
HTTP methodPOST
Endpoint0/private/AmendOrder
Auth requiredYes
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const result = await client.amendOrder({
  txid: 'OQCLML-BW3P3-BUCMWZ',
  limit_price: '48000',
});
console.log('Amend ID:', result.result.amend_id);

cancelOrder(params)

Cancel a particular open order (or set of open orders) by txid, userref, or cl_ord_id. Signature
cancelOrder(params: {
  txid?: string | number;
  cl_ord_id?: string;
}): Promise<SpotAPISuccessResponse<{ count: number; pending?: boolean }>>
txid
string | number
Transaction ID, user reference ID, or comma-delimited list of transaction IDs to cancel.
cl_ord_id
string
Client order ID to cancel.
PropertyValue
HTTP methodPOST
Endpoint0/private/CancelOrder
Auth requiredYes
Response fields
FieldTypeDescription
countnumberNumber of orders cancelled
pendingboolean?If true, a partially filled order is pending cancellation
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const result = await client.cancelOrder({
  txid: 'OQCLML-BW3P3-BUCMWZ',
});
console.log('Cancelled orders:', result.result.count);

cancelAllOrders()

Cancel all currently open orders. No parameters required. Signature
cancelAllOrders(): Promise<SpotAPISuccessResponse<{ count: number; pending: boolean }>>
PropertyValue
HTTP methodPOST
Endpoint0/private/CancelAll
Auth requiredYes
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const result = await client.cancelAllOrders();
console.log('Cancelled:', result.result.count, 'orders');

cancelAllOrdersAfter(params)

Dead Man’s Switch. Sets a countdown timer that will automatically cancel all client orders if not reset before expiry. Send timeout: 0 to disable the timer. Designed to protect against network disconnections or system failures. Signature
cancelAllOrdersAfter(params: { timeout: number }): Promise<
  SpotAPISuccessResponse<{
    currentTime: string;
    triggerTime: string;
  }>
>
timeout
number
required
Number of seconds until all orders are cancelled. Set to 0 to disable the timer. Maximum: 86400 (24 hours).
PropertyValue
HTTP methodPOST
Endpoint0/private/CancelAllOrdersAfter
Auth requiredYes
Response fields
FieldTypeDescription
currentTimestringServer time when request was received
triggerTimestringScheduled cancellation time
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

// Start 60-second countdown
const dms = await client.cancelAllOrdersAfter({ timeout: 60 });
console.log('Will cancel at:', dms.result.triggerTime);

// Heartbeat loop — reset every 30s
setInterval(async () => {
  await client.cancelAllOrdersAfter({ timeout: 60 });
}, 30_000);

// Disable when shutting down cleanly
await client.cancelAllOrdersAfter({ timeout: 0 });
You must continuously reset the timer before it expires. The timer resets each time you call cancelAllOrdersAfter() with a non-zero timeout. If your process crashes, the timer will fire and cancel all orders.

submitBatchOrders(params)

Submit a collection of orders (minimum 2, maximum 15) for a single trading pair. Validation is applied to the entire batch before any orders are placed — if one order fails validation, the whole batch is rejected. Signature
submitBatchOrders(params: SpotSubmitOrderBatchParams): Promise<
  SpotAPISuccessResponse<{ orders: SpotBatchOrderResult[] }>
>
pair
string
required
Asset pair for all orders in the batch. All orders must share the same pair.
orders
SpotBatchOrderItem[]
required
Array of 2–15 order objects. Each item supports the same fields as submitOrder() except pair.
validate
boolean
If true, validates the batch but does not submit. Useful for parameter testing.
deadline
string
RFC3339 deadline timestamp for the batch.
asset_class
'tokenized_asset'
Asset class filter.
broker
string
Broker identifier (if applicable).
PropertyValue
HTTP methodPOST
Endpoint0/private/AddOrderBatch
Auth requiredYes
Response{ orders: SpotBatchOrderResult[] } Each SpotBatchOrderResult contains txid?, descr?, and error? (if that specific order failed).
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const batch = await client.submitBatchOrders({
  pair: 'XBTUSD',
  orders: [
    {
      ordertype: 'limit',
      type: 'buy',
      volume: '0.0001',
      price: '45000.00',
      timeinforce: 'GTC',
      cl_ord_id: client.generateNewOrderID(),
    },
    {
      ordertype: 'limit',
      type: 'buy',
      volume: '0.0001',
      price: '44000.00',
      timeinforce: 'GTC',
      cl_ord_id: client.generateNewOrderID(),
    },
    {
      ordertype: 'limit',
      type: 'sell',
      volume: '0.0001',
      price: '55000.00',
      timeinforce: 'GTC',
      cl_ord_id: client.generateNewOrderID(),
    },
  ],
});

batch.result.orders.forEach((o, i) => {
  if (o.error) {
    console.error(`Order ${i} failed:`, o.error);
  } else {
    console.log(`Order ${i} placed:`, o.txid);
  }
});

cancelBatchOrders(params)

Cancel multiple open orders by txid, userref, or cl_ord_id. Supports up to 50 unique IDs/references per call. Signature
cancelBatchOrders(params: {
  orders?: Array<string | number>;
  cl_ord_ids?: string[];
}): Promise<SpotAPISuccessResponse<{ count: number }>>
orders
Array<string | number>
Array of transaction IDs or user reference IDs to cancel.
cl_ord_ids
string[]
Array of client order IDs to cancel.
PropertyValue
HTTP methodPOST
Endpoint0/private/CancelOrderBatch
Auth requiredYes
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const result = await client.cancelBatchOrders({
  orders: [
    'OQCLML-BW3P3-BUCMWZ',
    'OZNOZE-2DOVH-Q4DOQT',
  ],
});
console.log('Cancelled:', result.result.count);

createSubaccount(params)

Create a trading subaccount. Must be called using an API key from the master account. Signature
createSubaccount(params: {
  username: string;
  email: string;
}): Promise<SpotAPISuccessResponse<boolean>>
username
string
required
Username for the new subaccount.
email
string
required
Email address for the new subaccount.
PropertyValue
HTTP methodPOST
Endpoint0/private/CreateSubaccount
Auth requiredYes (master account API key)

submitSubaccountTransfer(params)

Transfer funds between the master account and subaccounts, or between subaccounts. Must be called using an API key from the master account. Signature
submitSubaccountTransfer(
  params: SpotAccountTransferParams
): Promise<SpotAPISuccessResponse<SpotAccountTransferResponse>>
asset
string
required
Asset to transfer (e.g. "EUR", "XBT").
amount
string
required
Amount to transfer.
from
string
required
Source account UID.
to
string
required
Destination account UID.
asset_class
'currency' | 'tokenized_asset'
Asset class of the transferred asset.
PropertyValue
HTTP methodPOST
Endpoint0/private/AccountTransfer
Auth requiredYes (master account API key)
Response fieldsSpotAccountTransferResponse
FieldTypeDescription
transfer_idstringUnique transfer identifier
statusstringTransfer status
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

const transfer = await client.submitSubaccountTransfer({
  asset: 'EUR',
  amount: '500',
  from: 'MASTER_ACCOUNT_UID',
  to: 'SUBACCOUNT_UID',
});
console.log('Transfer ID:', transfer.result.transfer_id);
console.log('Status:', transfer.result.status);

Full Order Lifecycle Example

The following example shows a complete order cycle — place a limit order, verify it appears in open orders, then cancel it.
import { SpotClient } from '@siebly/kraken-api';

const client = new SpotClient({
  apiKey: process.env.API_SPOT_KEY,
  apiSecret: process.env.API_SPOT_SECRET,
});

// 1. Generate a unique client order ID
const clOrdId = client.generateNewOrderID();

// 2. Place a limit order (well below market to avoid fill)
const submitted = await client.submitOrder({
  ordertype: 'limit',
  type: 'buy',
  volume: '0.001',
  pair: 'XBTUSD',
  price: '10000',
  timeinforce: 'GTC',
  cl_ord_id: clOrdId,
});
const txid = submitted.result.txid[0];
console.log('Order placed, txid:', txid);

// 3. Confirm it appears in open orders
const openOrders = await client.getOpenOrders({ cl_ord_id: clOrdId });
console.log('Open order status:', openOrders.result.open[txid]?.status);

// 4. Cancel the order
const cancelResult = await client.cancelOrder({ txid });
console.log('Cancelled:', cancelResult.result.count, 'order(s)');

// 5. Verify it's now closed
const closedOrders = await client.getOrders({ txid, trades: false });
console.log('Final status:', closedOrders.result[txid]?.status);

Build docs developers (and LLMs) love