Skip to main content
Create buy stock market order
curl --request POST \
  --url https://whitebit.com/api/v4/order/stock_market \
  --header 'Content-Type: application/json' \
  --header 'X-TXC-APIKEY: <api-key>' \
  --header 'X-TXC-PAYLOAD: <api-key>' \
  --header 'X-TXC-SIGNATURE: <api-key>' \
  --data '
{
  "market": "BTC_USDT",
  "side": "buy",
  "amount": "0.001",
  "request": "{{request}}",
  "nonce": 1594297865000,
  "clientOrderId": "order1987111",
  "stp": "no"
}
'
import requests

url = "https://whitebit.com/api/v4/order/stock_market"

payload = {
    "market": "BTC_USDT",
    "side": "buy",
    "amount": "0.001",
    "request": "{{request}}",
    "nonce": 1594297865000,
    "clientOrderId": "order1987111",
    "stp": "no"
}
headers = {
    "X-TXC-APIKEY": "<api-key>",
    "X-TXC-PAYLOAD": "<api-key>",
    "X-TXC-SIGNATURE": "<api-key>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {
    'X-TXC-APIKEY': '<api-key>',
    'X-TXC-PAYLOAD': '<api-key>',
    'X-TXC-SIGNATURE': '<api-key>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    market: 'BTC_USDT',
    side: 'buy',
    amount: '0.001',
    request: '{{request}}',
    nonce: 1594297865000,
    clientOrderId: 'order1987111',
    stp: 'no'
  })
};

fetch('https://whitebit.com/api/v4/order/stock_market', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://whitebit.com/api/v4/order/stock_market",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'market' => 'BTC_USDT',
    'side' => 'buy',
    'amount' => '0.001',
    'request' => '{{request}}',
    'nonce' => 1594297865000,
    'clientOrderId' => 'order1987111',
    'stp' => 'no'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "X-TXC-APIKEY: <api-key>",
    "X-TXC-PAYLOAD: <api-key>",
    "X-TXC-SIGNATURE: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://whitebit.com/api/v4/order/stock_market"

	payload := strings.NewReader("{\n  \"market\": \"BTC_USDT\",\n  \"side\": \"buy\",\n  \"amount\": \"0.001\",\n  \"request\": \"{{request}}\",\n  \"nonce\": 1594297865000,\n  \"clientOrderId\": \"order1987111\",\n  \"stp\": \"no\"\n}")

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

	req.Header.Add("X-TXC-APIKEY", "<api-key>")
	req.Header.Add("X-TXC-PAYLOAD", "<api-key>")
	req.Header.Add("X-TXC-SIGNATURE", "<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))

}
HttpResponse<String> response = Unirest.post("https://whitebit.com/api/v4/order/stock_market")
  .header("X-TXC-APIKEY", "<api-key>")
  .header("X-TXC-PAYLOAD", "<api-key>")
  .header("X-TXC-SIGNATURE", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"market\": \"BTC_USDT\",\n  \"side\": \"buy\",\n  \"amount\": \"0.001\",\n  \"request\": \"{{request}}\",\n  \"nonce\": 1594297865000,\n  \"clientOrderId\": \"order1987111\",\n  \"stp\": \"no\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://whitebit.com/api/v4/order/stock_market")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-TXC-APIKEY"] = '<api-key>'
request["X-TXC-PAYLOAD"] = '<api-key>'
request["X-TXC-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"market\": \"BTC_USDT\",\n  \"side\": \"buy\",\n  \"amount\": \"0.001\",\n  \"request\": \"{{request}}\",\n  \"nonce\": 1594297865000,\n  \"clientOrderId\": \"order1987111\",\n  \"stp\": \"no\"\n}"

response = http.request(request)
puts response.read_body
{
  "orderId": 4180284841,
  "clientOrderId": "order1987111",
  "market": "BTC_USDT",
  "side": "buy",
  "type": "limit",
  "timestamp": 1595792396.165973,
  "dealMoney": "0",
  "dealStock": "0",
  "amount": "0.01",
  "left": "0.001",
  "dealFee": "0",
  "price": "40000",
  "postOnly": false,
  "ioc": false,
  "status": "FILLED",
  "stp": "no",
  "positionSide": "LONG",
  "rpi": true,
  "retail": true,
  "reduceOnly": false,
  "activated": 0,
  "activationCondition": "lte",
  "activation_price": "40000"
}
{
  "code": 30,
  "message": "Validation failed",
  "errors": {}
}
{
  "code": 30,
  "message": "Validation failed",
  "errors": {}
}

Authorizations

X-TXC-APIKEY
string
header
required

The public WhiteBIT API key.

X-TXC-PAYLOAD
string
header
required

Base64-encoded JSON request body.

X-TXC-SIGNATURE
string
header
required

HMAC-SHA512 signature of the payload, hex-encoded. Computed as hex(HMAC-SHA512(payload, api_secret)).

Body

application/json
market
string
required

Trading pair. Format: BASE_QUOTE (e.g., BTC_USDT). Query GET /api/v4/public/markets for available markets.

Example:

"BTC_USDT"

side
enum<string>
required

Order side. Allowed values: buy, sell.

Available options:
buy,
sell
Example:

"buy"

amount
string
required

Order quantity in base (stock) currency for both buy and sell sides. To place a market order specifying the quote (money) currency amount instead, use POST /api/v4/order/market. Minimum and maximum values are market-dependent. Query GET /api/v4/public/markets for minAmount, minTotal, maxTotal.

Example:

"0.001"

request
string
required
Example:

"{{request}}"

nonce
integer
required
Example:

1594297865000

clientOrderId
string

Custom client order identifier. Uniqueness is enforced only among the account's open (pending) orders on the same market — once a previous order is filled or canceled, the same identifier can be reused, including on the same market. Contains only letters, numbers, dashes, dots, or underscores.

Example:

"order1987111"

stp
enum<string>
default:no

Self-trade prevention mode. Allowed values: no (self-trades allowed), cb (cancel both the new and the existing order), cn (cancel the new order, keep the existing), co (cancel the existing order, place the new one). Default: no.

Legacy values cancel_both, cancel_new, cancel_old are deprecated: the API accepts the legacy values with identical behavior until a deprecation deadline is announced, then rejects the legacy values. Responses always return the abbreviated form, regardless of which variant the request used.

See Self-Trade Prevention.

Available options:
no,
cb,
cn,
co
Example:

"no"

Response

Order created successfully

orderId
integer

Unique identifier assigned to the order by the matching engine.

Example:

4180284841

clientOrderId
string

Custom client order identifier supplied in the request. Returns an empty string when not specified.

Example:

"order1987111"

market
string

Trading pair for the order. Format: BASE_QUOTE (e.g., BTC_USDT).

Example:

"BTC_USDT"

side
string

Order side. Possible values: buy, sell.

Example:

"buy"

type
string

Order type. Possible values: limit, market, stock market, stop limit, stop market.

Example:

"limit"

timestamp
number

Unix timestamp in seconds (UTC) of order creation, with microsecond precision.

Example:

1595792396.165973

dealMoney
string

Filled amount in quote currency. Returns "0" while the order remains unfilled.

Example:

"0"

dealStock
string

Filled amount in base currency. Returns "0" while the order remains unfilled.

Example:

"0"

amount
string

Order quantity in base currency for limit and stop-limit orders, or in quote currency for buy market orders.

Example:

"0.01"

left
string

Remaining unfilled quantity. Equals amount for new orders and "0" for fully filled orders.

Example:

"0.001"

dealFee
string

Cumulative trading fee charged for filled portions, denominated in the fee asset.

Example:

"0"

price
string

Limit price per unit in quote currency. Returns "0" for market orders.

Example:

"40000"

postOnly
boolean

Post-only flag. When true, the order executes only as a maker order and is rejected if it would match immediately. Default: false.

Example:

false

ioc
boolean

Immediate-or-cancel flag. When true, the order executes available quantity immediately and cancels the unfilled remainder. Default: false.

Example:

false

status
string

Order lifecycle status. NEW — accepted, not yet matched. FILLED — fully executed. CANCELED — canceled before execution. PARTIAL_FILLED — partially executed, remainder still active. PARTIAL_CANCELED — partially filled, remainder canceled. CANCELED_TAKER_BAND — partially filled up to the taker band limit, remainder canceled to protect against excessive order book slippage. AUTO_CANCELED_REDUCE_ONLY — pending reduce-only order auto-canceled because the associated position was closed. AUTO_CANCELED_LIQUIDATION — pending order auto-canceled because the associated position was force-liquidated. CANCELED_STP — order canceled by Self-Trade Prevention.

Example:

"FILLED"

stp
string

Self-trade prevention mode applied to the order. Possible values: no, cb, cn, co. The response always returns the abbreviated form, even when the request used a legacy value. Default: no.

Example:

"no"

positionSide
string

Position side (for collateral orders)

Example:

"LONG"

rpi
boolean

Indicates Retail Price Improvement (RPI) mode for the order.

Example:

true

retail
boolean

Retail-source taker flag. The field is present only when the order was placed with retail=true. See Retail flag.

Example:

true

reduceOnly
boolean

Reduce-only flag. When true, the order can only reduce or close an existing position. See reduce-only.

Example:

false

activated
integer

Activation status of the stop order. 0 = not yet triggered (waiting for the activation_price condition to be met). 1 = triggered (the stop condition has been met and the order is now active).

Example:

0

activationCondition
enum<string>

Trigger condition for the stop order. Response-only — not accepted in the request body, and cannot be overridden. Derived from side:

  • side = buygte. The order activates when the market price rises to or above activation_price.
  • side = selllte. The order activates when the market price falls to or below activation_price.
Available options:
lte,
gte
Example:

"lte"

activation_price
string

The trigger price for the stop order. Always equals the activation_price value submitted in the request.

Example:

"40000"