Download OpenAPI specification:Download
All the endpoints will require an API Key. Please refer to this page regarding API key creation..
Once an API key is created, it is recommended to set IP restrictions on the key for security reasons.
Never share your API key/secret key to ANYONE.
If the API keys were accidentally shared, please delete them immediately and create a new key.
To manage your API keys, please go to the API Key Management page.
We support different options for API Key calling requests to Bitcastle:
Read Only: Request for login authentication and be able to use all the
Spot Trading: Request to create or cancel an exchange order
Withdraw: Request to create a withdraw order
After creating the API key, the default restriction is Enable. If we see any suspicious attempts that may not be safe for our system, it would be Disabled and no longer be used.
The default rate for an API Key is:
50 calls per 10 seconds for user account.
100 calls per 10 seconds for enterprise account.
We are support both MQTT and Websocket protocol for real time data. Data format must using MQTT package structure.
Base url:
public/exchange/update_ticker_24h
{
"data": [
{
"coin": "ada",
"currency": "usdt",
"volume": "3536679.8",
"total": "1321685.59747",
"high": "0.38",
"low": "0.3658",
"price": "0.3684",
"price_change": "-0.0096",
"price_percentage": "-2.539682539682539683"
}
],
"last_update": "1684469752863"
}
public/exchange/update_market_trade/{coin}/{currency}
public/exchange/update_market_trade/btc/usdt
{
"data": {
"id": "68367233",
"origin_order_id": "711794895602066054",
"match_order_id": "711794895606258816",
"coin": "btc",
"currency": "usdt",
"price": "26824.8",
"net_volume": "0.00326556",
"gross_volume": "0.00326556",
"create_time": "1684469927659",
},
"last_update": "1684469927705"
}
public/exchange/update_orderbook/{coin}/{currency}/{precision}
public/exchange/update_orderbook/btc/usdt/0.01
{
"data": {
"coin": "btc",
"currency": "usdt",
"precision": "0.01",
"type": "ws",
"orderbook": {
"asks": [
{
"price": "26851.57",
"volume": "0.00356067"
},
{
"price": "26851.49",
"volume": "0.00423304"
},
{
"price": "26851.47",
"volume": "0.01969202"
}
],
"bids": [
{
"price": "26797.22",
"volume": "0.00285109"
},
{
"price": "26797.19",
"volume": "0.00570166"
},
{
"price": "26797.18",
"volume": "0.00096345"
}
]
}
},
"last_update": 1684469761904
}
types[] | Array of any Default: [3] Example: types[]=1&types[]=2 Balance Types ([CASHBACK,BO,EXCHANGE,REWARD,1,2,3,4]) |
{- "data": [
- {
- "actual_balance": "0.000000000000000000",
- "available_balance": "0.000000000000000000",
- "created_at": "1649748104000",
- "currency": "eve",
- "id": "10120139",
- "type": "EXCHANGE",
- "updated_at": "1649748104000",
- "user_id": "42397",
- "version": 0
}, - {
- "actual_balance": "0.000000000000000000",
- "available_balance": "0.000000000000000000",
- "created_at": "1514764800000",
- "currency": "dot",
- "id": "10148131",
- "type": "EXCHANGE",
- "updated_at": "1514764800000",
- "user_id": "42397",
- "version": 0
}
], - "timestamp": 1683627338413
}
Market related statistics for all markets for the last 24 hours.
coin | string Example: coin=btc |
currency | string Example: currency=usdt |
{- "data": [
- {
- "coin": "ltc",
- "currency": "btc",
- "volume": "2279.0975",
- "total": "7.7372463612",
- "high": "0.003459",
- "low": "0.00336",
- "price": "0.003438",
- "price_change": "0.000023",
- "price_percentage": "0.673499267935578331"
}, - {
- "coin": "mc",
- "currency": "castle",
- "volume": "0",
- "total": "0",
- "high": "2.8954",
- "low": "2.8954",
- "price": "2.8954",
- "price_change": "0",
- "price_percentage": "0"
}
], - "last_update": 1683627338413
}
Order book depth of any given trading pair, split into two different arrays for bid and ask orders.
coin required | string Example: coin=btc |
currency required | string Example: currency=usdt |
precision required | string Example: precision=0.01 |
take | number Example: take=100 number of elements in each array, default = 100 |
sort | string Enum: "ASC" "DESC" order by: price, default = DESC |
{- "data": {
- "coin": "btc",
- "currency": "usdt",
- "precision": "0.01",
- "orderbook": {
- "asks": [
- {
- "price": "26858.58",
- "volume": "0.00427671"
}, - {
- "price": "26858.51",
- "volume": "0.00071742"
}
], - "bids": [
- {
- "price": "26804.68",
- "volume": "0.00065931"
}, - {
- "price": "26804.67",
- "volume": "0.04786604"
}
], - "current_price": "26831.57"
}
}, - "last_update": 1684470804010
}
Used to return data on historical completed trades for a given market pair.
coin required | string Example: BTC |
currency required | string Example: USDT |
{- "buy": [
- {
- "trade_id": 69236949,
- "target_volume": "1291.315173554",
- "price": "26899.900000000000000000",
- "base_volume": "0.048004460000000000",
- "type": "buy",
- "trade_timestamp": 1684898821781
}, - {
- "trade_id": 69236847,
- "target_volume": "6924.643975611",
- "price": "26938.900000000000000000",
- "base_volume": "0.257049990000000000",
- "type": "buy",
- "trade_timestamp": 1684898793543
}
], - "sell": [
- {
- "trade_id": 69237105,
- "target_volume": "1139.5688069113",
- "price": "26903.990000000000000000",
- "base_volume": "0.042356870000000000",
- "type": "sell",
- "trade_timestamp": 1684898867024
}, - {
- "trade_id": 69237056,
- "target_volume": "1216.730987031",
- "price": "26930.350000000000000000",
- "base_volume": "0.045180660000000000",
- "type": "sell",
- "trade_timestamp": 1684898852924
}
]
}
Historical trade data for any given trading pair.
coin required | string Example: coin=btc |
currency required | string Example: currency=usdt |
take | number Example: take=50 Default is 50 |
{- "data": [
- {
- "id": "68369770",
- "price": "26848.400000000000000000",
- "gross_volume": "0.000755450000000000",
- "create_time": "1684471142347",
- "coin": "btc",
- "currency": "usdt",
- "order_type": 1
}, - {
- "id": "68369742",
- "price": "26848.400000000000000000",
- "gross_volume": "0.001033290000000000",
- "create_time": "1684471126255",
- "coin": "btc",
- "currency": "usdt",
- "order_type": 1
}
]
}
The request will respond candle stick data buy trading pair
coin required | string Example: coin=btc |
currency required | string Example: currency=usdt |
range required | string Example: range=24h Write List: 24h,7d,30d |
{- "data": [
- {
- "price": "27490",
- "time": "1684470600000"
}, - {
- "price": "27490",
- "time": "1684470900000"
}, - {
- "price": "27490",
- "time": "1684471200000"
}
], - "last_update": "1684471309175"
}
The List Open Orders API allows you to retrieve a list of open or pending orders.
order_class | number Enum: 1 2 3 4 Example: order_class=2 MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4 |
order_type | number Enum: 1 2 Example: order_type=2 BUY = 1, SELL = 2 |
currency | string Example: currency=usdt |
coin | string Example: coin=btc |
from_create_date | string Example: from_create_date=1672053435907 |
to_create_date | string Example: to_create_date=1672053435907 |
take | number Default: 10 Example: take=10 Default is 10. For pagination |
from | string order_id of order |
to | string order_id of order |
{- "data": [
- {
- "status": 1,
- "order_class": 2,
- "stop_direction": 0,
- "filled_volume": "0",
- "error_count": 0,
- "order_id": "87365289",
- "user_id": "61254",
- "order_type": 1,
- "price": "31000.00",
- "volume": "0.05",
- "stop_price": "0",
- "create_time": "1686624064264",
- "update_time": "1686624064264",
- "coin": "btc",
- "currency": "usdt",
- "filled_price": "0"
}
], - "status_code": 200,
- "msg": "Success",
- "timestamp": "123124123123"
}
The List Order History API provides a convenient way to retrieve a user's order history
order_class | number Enum: 1 2 3 4 Example: order_class=2 MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4 |
order_type | number Enum: 1 2 Example: order_type=2 BUY = 1, SELL = 2 |
currency | string Example: currency=usdt |
coin | string Example: coin=btc |
from_create_date | string Example: from_create_date=1672053435907 |
to_create_date | string Example: to_create_date=1672053435907 |
order_status | number Enum: 1 2 3 4 6 Example: order_status=2 PENDING = 1, FILLED = 2, CANCELED = 3, EXPIRED = 4, CANCELING = 6 |
take | number Default: 10 Example: take=10 Default is 10. For pagination |
from | string id of order |
to | string id of order |
{- "data": [
- {
- "status": 2,
- "order_class": 2,
- "stop_direction": 0,
- "filled_volume": "0.05",
- "error_count": 0,
- "order_id": "87365289",
- "user_id": "61254",
- "order_type": 1,
- "price": "31000.00",
- "volume": "0.05",
- "stop_price": "0",
- "create_time": "1688026064722",
- "update_time": "1688026064722",
- "coin": "btc",
- "currency": "usdt",
- "filled_price": "31000.00"
}
], - "status_code": 200,
- "msg": "Success",
- "timestamp": "123124123123"
}
The List Trade History API provides a convenient way to retrieve the trade history.
order_class | number Enum: 1 2 3 4 Example: order_class=2 MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4 |
order_type | number Enum: 1 2 Example: order_type=2 BUY = 1, SELL = 2 |
currency | string Example: currency=usdt |
coin | string Example: coin=btc |
from_create_date | string Example: from_create_date=1672053435907 |
to_create_date | string Example: to_create_date=1672053435907 |
take | number Default: 10 Example: take=10 Default is 10. For pagination |
from | string id of trade-history |
to | string id of trade-history |
{- "data": [
- {
- "id": "235263512",
- "order_id": "1235263512",
- "order_type": 1,
- "price": "31000.00",
- "net_volume": "0.05",
- "gross_volume": "0.05",
- "create_time": "1688026066346",
- "coin": "btc",
- "currency": "usdt"
}
], - "status_code": 200,
- "msg": "Success",
- "timestamp": "123124123123"
}
Open new Order
order_type required | number |
order_class required | number |
coin required | string |
currency required | string |
price required | string |
stop_price required | string |
volume required | string |
{- "order_type": 1,
- "order_class": 1,
- "coin": "btc",
- "currency": "usdt",
- "price": "0.1",
- "stop_price": "0.1",
- "volume": "0.1"
}
{- "order_type": 0,
- "order_class": 0,
- "coin": "btc",
- "currency": "usdt",
- "price": "0.1234211",
- "stop_price": "0.1234211",
- "volume": "0.1234211"
}
Get user's order by order_id.
order_id required | number Example: order_id=687611739734551300 Id of the order |
{- "data": [
- {
- "status": 1,
- "order_class": 0,
- "stop_direction": 0,
- "filled_volume": "0.00001",
- "error_count": 0,
- "order_id": "87365289",
- "user_id": "61254",
- "order_type": 0,
- "price": "0.0000342",
- "volume": "0.0000342",
- "stop_price": "0.0000342",
- "create_time": "0.0000342",
- "update_time": "0.0000342",
- "coin": "btc",
- "currency": "usdt",
- "filled_price": "0.0000342"
}
], - "status_code": 200,
- "msg": "Success",
- "timestamp": "123124123123"
}
The Cancel Open Order API allows you to cancel an open or pending orders by list of IDs
ids | Array of strings non-empty |
{- "ids": [
- "112321",
- "123212",
- "312321"
]
}
{- "data": { },
- "status_code": 200,
- "msg": "Success",
- "timestamp": "123124123123"
}
Get futures open orders of user.
limit | number Example: limit=10 Default is 10. Min is 1. Max is 1000 . For pagination |
page | number Example: page=1 Default is 1. For pagination |
{- "timestamp": "1716778236408",
- "data": [
- {
- "id": "847305749708412094",
- "price": "69035.200000000000000000",
- "amount": "0.030000000000000000",
- "pnl": "0.000000000000000000",
- "create_time": "1716778232910",
- "update_time": "1716778232910",
- "leverage": 150,
- "side": 1,
- "mode": 2,
- "status": 1,
- "user_type": 1,
- "coin": "btc",
- "currency": "usdt",
- "addition_margin": "0.000000000000000000",
- "margin": "13.807040000000000000",
- "fee": "0.828422400000000000",
- "hold_balance": "14.635462400000000000",
- "collateral": 1,
- "user_id": "67850",
- "type": 2,
- "stop_loss_price": null,
- "take_profit_price": null,
- "position_id": null,
- "extra": null
}
], - "status_code": 200,
- "pagination": {
- "total": 1,
- "size": 1000,
- "page": 1
}, - "links": {
- "next": "",
- "prev": ""
}
}
Get futures order histories of user.
coin | string Example: coin=btc coin |
currency | string Example: currency=usdt currency |
side | number Enum: 1 2 Example: side=1 BUY: 1, SELL: 2 |
status | number Enum: 3 4 Example: status=3 CANCEL: 3, FILLED: 4 |
type | number Enum: 1 2 Example: type=1 MARKET: 1, LIMIT: 2 |
position_id | string Example: position_id=123124123123 Position ID |
start_time | string Example: start_time=1672053435907 Start time in ms |
end_time | string Example: end_time=1672053435907 End time in ms |
limit | string Example: limit=10 Default is 10. Min is 1. Max is 1000 . For pagination |
page | string Example: page=1 Default is 1. For pagination |
order_by | string Enum: "asc" "desc" Example: order_by=desc Ascending: asc, Descending: desc |
{- "timestamp": "1712564120647",
- "data": [
- {
- "id": "829607696239173110",
- "price": "69688.700000000000000000",
- "amount": "0.010000000000000000",
- "create_time": "1712558688149",
- "update_time": "1712558690739",
- "leverage": 20,
- "side": 1,
- "type": 2,
- "status": 4,
- "user_type": 1,
- "coin": "btc",
- "currency": "usdt",
- "addition_margin": "0.000000000000000000",
- "margin": "34.844350000000000000",
- "fee": "0.418132200000000000",
- "collateral": 1,
- "user_id": "67850",
- "mode": 2,
- "stop_loss_price": null,
- "take_profit_price": null,
- "hold_balance": "0.000000000000000000",
- "pnl": "0.000000000000000000",
- "position_id": "167887458909060434",
- "extra": null,
- "matching_price": "69688.700000000000000000"
}
], - "status_code": 200,
- "pagination": {
- "total": 1,
- "size": 100,
- "page": 1
}, - "links": {
- "next": "",
- "prev": ""
}
}
Open new futures order
mode required | number Enum: 1 2 ISOLATED: 1, CROSS: 2 |
side required | number Enum: 1 2 BUY: 1, SELL: 2 |
coin required | string coin |
currency required | string coin |
price required | string Price of the order |
type required | number Enum: 1 2 MARKET: 1, LIMIT: 2 |
amount required | string Amount of the order |
collateral required | number Enum: 1 2 USD-M: 1, COIN-M: 2 |
stop_loss_price | string Price to stop loss |
take_profit_price | string Price to take profit |
{- "mode": 1,
- "side": 1,
- "coin": "btc",
- "currency": "usdt",
- "price": "19000",
- "type": 1,
- "amount": "0.1",
- "collateral": 1,
- "stop_loss_price": "18000",
- "take_profit_price": "20000"
}
{- "timestamp": "1712566153345",
- "msg": "Order created",
- "data": {
- "id": "829639006571728950",
- "price": "71411.600000000000000000",
- "amount": "0.010000000000000000",
- "pnl": "0.000000000000000000",
- "create_time": "1712566153114",
- "update_time": "1712566153114",
- "leverage": 20,
- "side": 1,
- "mode": 2,
- "status": 1,
- "user_type": 1,
- "coin": "btc",
- "currency": "usdt",
- "addition_margin": "0.000000000000000000",
- "margin": "35.705800000000000000",
- "fee": "0.428469600000000000",
- "hold_balance": "36.134269600000000000",
- "collateral": 1,
- "user_id": "67850",
- "type": 2,
- "stop_loss_price": null,
- "take_profit_price": null,
- "position_id": null,
- "extra": null
}, - "status_code": 200
}
Cancel futures order
id required | string ID of order to cancel |
{- "id": "1684470600000"
}
{- "timestamp": "1712568171728",
- "msg": "",
- "status_code": 200
}
Get futures positions of user.
coin | string Example: coin=btc coin |
currency | string Example: currency=usdt currency |
side | string Enum: "long" "short" Example: side=long LONG: long, SHORT: short |
status | string Enum: "open" "close" Example: status=open OPEN: open, CLOSE: close |
sort_by | string Enum: "id" "updated_at" Example: sort_by=id Sort by ID: id, sort by updated at: updated_at |
start_time | string Example: start_time=1672053435907 Start time in ms |
end_time | string Example: end_time=1672053435907 End time in ms |
limit | string Example: limit=10 Default is 10. For pagination |
page | string Example: page=1 Default is 1. For pagination |
order_by | string Enum: "asc" "desc" Example: order_by=desc Ascending: asc, Descending: desc |
{- "timestamp": "1712564117654",
- "data": [
- {
- "id": "167887458909060434",
- "user_id": "67850",
- "symbol": "btc/usdt",
- "entry_price": "69688.7",
- "leverage": "20",
- "margin": "34.92100757",
- "initial_margin": "34.84435",
- "size": "0.01",
- "side": "long",
- "position_type": "cross",
- "status": "open",
- "liquidation_price": "0",
- "unrealized_pnl": "17.1464507092",
- "mark_price": "71403.34507092",
- "created_at": "1712558689403",
- "updated_at": "1712563201465",
- "take_profit_price": "",
- "stop_loss_price": "",
- "close_limit_price": ""
}
], - "status_code": 200,
- "pagination": {
- "page": 1,
- "size": 1000,
- "total": 3
}, - "links": {
- "next": "",
- "prev": ""
}
}
Close futures position by id
position_id required | string ID of position to close |
type required | string Enum: "market" "limit" Market: market, Limit: limit |
exit_price | string exit price |
{- "position_id": "1684470600000",
- "type": "market",
- "exit_price": "19000"
}
{- "timestamp": "1712568517328",
- "msg": "",
- "data": { },
- "status_code": 200
}
Adjust margin for futures position
id required | string ID of position to adjust |
action required | string Enum: "increase" "decrease" Increase: increase, Decrease: decrease |
currency required | string Currency to adjust |
amount required | string Amount to adjust |
{- "id": "1684470600000",
- "action": "increase",
- "currency": "usdt",
- "amount": "100"
}
{- "timestamp": "1712569459026",
- "msg": "",
- "data": {
- "id": "158798026629490732",
- "user_id": "67850",
- "symbol": "eth/usdt",
- "entry_price": "3973.96",
- "leverage": "10",
- "margin": "154037.60415901",
- "initial_margin": "3397.62055515992",
- "size": "8.54971",
- "side": "short",
- "position_type": "isolated",
- "status": "open",
- "liquidation_price": "21970.79",
- "created_at": "1710391599873",
- "updated_at": "1712569457868",
- "take_profit_price": "",
- "stop_loss_price": "",
- "close_limit_price": ""
}, - "status_code": 200
}
Modify take profit and stop loss for futures position
position_id required | string ID of position to update take profit stop loss |
take_profit_price required | string Price to take profit |
stop_loss_price required | string Price to stop loss |
{- "position_id": "1684470600000",
- "take_profit_price": "21000",
- "stop_loss_price": "19000"
}
{- "timestamp": "1712569723788",
- "msg": "",
- "data": { },
- "status_code": 200
}
Get leverage user setting use for place futures order.
symbol required | string Example: symbol=btc/usdt symbol |
{- "timestamp": "1716879322196",
- "msg": "Get leverage info success!",
- "data": [
- {
- "symbol": "btc/usdt",
- "leverage": "150",
- "position_side": "dual"
}
], - "status_code": 200
}
Get margin mode user setting use for place futures order.
symbol required | string Example: symbol=btc/usdt symbol |
{- "timestamp": "1716879322199",
- "msg": "Get margin mode info success!",
- "data": {
- "mode": "cross"
}, - "status_code": 200
}
Update leverage use for place futures order
leverage required | string Leverage use for place futures order |
side required | string Enum: "long" "short" "dual" LONG: long, SHORT: short, DUAL: dual |
symbol required | string Symbol |
{- "leverage": "125",
- "side": "long",
- "symbol": "btc/usdt"
}
{- "timestamp": "1716777514301",
- "msg": "Update leverage info success!",
- "data": {
- "symbol": "btc/usdt",
- "leverage": "125",
- "position_side": "long"
}, - "status_code": 200
}
Update position mode use for place futures order
use_hedge_mode required | boolean Use hedge mode |
{- "use_hedge_mode": true
}
{- "timestamp": "1716777571615",
- "msg": "Change position mode success!",
- "data": {
- "use_hedge_mode": true
}, - "status_code": 200
}
Update margin mode use for place futures order
mode | string Enum: "cross" "isolated" Cross: cross, Isolated: isolated |
symbol required | string Symbol |
{- "mode": "cross",
- "symbol": "btc/usdt"
}
{- "timestamp": "1716879119196",
- "msg": "Update margin mode info success!",
- "data": {
- "mode": "cross"
}, - "status_code": 200
}
Cancel trigger price
position_id required | string ID of position to cancel trigger price |
type required | string Enum: "take_profit_price" "stop_loss_price" "close_limit_price" Take profit price: take_profit_price, Stop loss price: stop_loss_price, Close limit: close_limit_price |
{- "position_id": "1684470600000",
- "type": "take_profit_price"
}
{- "timestamp": "1716892283873",
- "msg": "",
- "data": { },
- "status_code": 200
}