Skip to content

Futures trading

Base URL for all endpoints in this module: https://openapi.bitbaby.com/futures/open

Full URL = {baseurl}{requestPath}, e.g. https://openapi.bitbaby.com/futures/open/fapi/v1/order.

When signing, requestPath must be /fapi/v1/... only — do not include the gateway prefix /futures/open. See General information → Signed endpoints.

General

Security: NONE

Public endpoints below require no API key or signature.

Test connectivity

GET /fapi/v1/ping

Checks REST API connectivity.

200

json
{}

Server time

GET /fapi/v1/time

200

json
{
    "serverTime": 1607702400000,
    "timezone": "China Standard Time"
}

Response

FieldTypeDescription
serverTimelongServer time (ms)
timezonestringTimezone name

Contracts

GET /fapi/v1/contracts

Returns metadata for all contracts. Optional header brokerId filters by broker.

200

json
[
    {
        "symbol": "E-BTC-USDT",
        "type": "E",
        "status": 1,
        "side": 1,
        "multiplier": 0.001,
        "multiplierCoin": "BTC",
        "pricePrecision": 2,
        "minOrderVolume": 1,
        "minOrderMoney": 0.001,
        "maxMarketVolume": 100000,
        "maxMarketMoney": 10000000,
        "maxLimitVolume": 1000000,
        "maxLimitMoney": 1000000,
        "maxValidOrder": 20
    }
]

Response

FieldTypeDescription
symbolstringContract, e.g. E-BTC-USDT
statusnumber0 not tradable / 1 tradable
typestringE perpetual, S simulated, other = mixed
sidenumber0 inverse / 1 linear
multipliernumberContract size
multiplierCoinstringSize unit
pricePrecisionnumberPrice decimals
minOrderVolumenumberMin order size
minOrderMoneynumberMin notional
maxMarketVolumenumberMax market size
maxMarketMoneynumberMax market notional
maxLimitVolumenumberMax limit size
maxValidOrdernumberMax open orders

Market data

Security: NONE

Market endpoints require no API key or signature.

Order book depth

GET /fapi/v1/depth

Query parameters

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT
limitintegerDefault 100; max 100

200

json
{
  "time": 1595563624731,
  "bids": [
    ["3.90000000", "431.00000000"],
    ["4.00000000", "431.00000000"]
  ],
  "asks": [
    ["4.00000200", "12.00000000"],
    ["5.10000000", "28.00000000"]
  ]
}

Each level is [price, size], sorted best price first.

24h ticker

GET /fapi/v1/ticker

Query parameters

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT

200

json
{
    "high": "9279.0301",
    "low": "9279.0301",
    "last": "9200",
    "vol": "1302",
    "rose": "0",
    "time": 1595563624731
}

All tickers

GET /fapi/v1/all_ticker

Returns a Map<contractName, ticker> with the same fields as above.

Index / mark price

GET /fapi/v1/index

Query parameters

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT

200

json
{
    "contractName": "E-ETH-USDT",
    "indexPrice": 646.3933333333333,
    "markPrice": 581.5,
    "lastFundingRate": 0.001,
    "time": 1608273554063
}

All-contracts index price

GET /fapi/v1/get_all_indexPrice

Returns Map<contractName, BigDecimal> of all index prices.

All-contracts index + mark prices

GET /fapi/v1/public_all_index_tag_price

Returns symbol, indexPrice, markPrice per contract.

K-lines / candles

GET /fapi/v1/klines

Query parameters

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT
interval*stringOne of 1min, 5min, 15min, 30min, 1h, 1day, 1week, 1month
limitintegerDefault 100; max 300
startTimelongStart time (ms)
endTimelongEnd time (ms)

200

json
[
    {
        "idx": 1594640340,
        "open": "6228.77",
        "close": "6228.77",
        "high": "6228.77",
        "low": "6228.77",
        "vol": "111"
    }
]

Trading

Security: TRADE

Every trading endpoint requires the same headers; we don't repeat them in each section.

HeaderTypeDescription
X-CH-APIKEY*stringAPI key
X-CH-TS*stringTimestamp (ms)
X-CH-SIGN*stringHMAC-SHA256 hex
Content-Type*stringapplication/json

Place order

POST /fapi/v1/order

Places a single order (limit or market).

Request body

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT
volume*numberContracts; for market open, this is notional value
side*stringBUY / SELL
type*stringLIMIT / MARKET
open*stringOPEN / CLOSE
positionType*number1 cross / 2 isolated
pricenumberRequired for LIMIT
clientOrderIdstringClient order id (< 32 chars)
timeInForcestringIOC, FOK, POST_ONLY

200

json
{
    "orderId": 256609229205684228
}

Conditional order

POST /fapi/v1/conditionOrder

Places a trigger-price order (stop-loss / take-profit / trailing).

Request body

In addition to the fields of Place order:

NameTypeDescription
triggerType*number3 stop-loss / 4 take-profit
triggerPrice*numberTrigger price
trailCallbackRationumberTrailing callback ratio (trailing stops)

200

json
{
    "orderId": 256609229205684228
}

Cancel order

POST /fapi/v1/cancel

Rate limit: 20 req / 2s

Request body

NameTypeDescription
contractName*stringContract, e.g. E-BTC-USDT
orderId*stringOrder id

200

json
{
    "orderId": 256609229205684228
}

Batch place

POST /fapi/v1/batchOrders

Alias POST /fapi/v1/placeBatchOrder behaves identically.

Request body

NameTypeDescription
contractName*stringContract
orders*arrayArray of orders; each item uses the Place order body

200

json
{
    "ids": ["256609229205684228", "256609229205684229"]
}

Batch cancel

POST /fapi/v1/batchCancel

Request body

NameTypeDescription
contractName*stringContract
orderIds*arrayOrder ids to cancel

200

json
{
    "success": ["256609229205684228"],
    "failed":  ["256609229205684229"]
}

Order detail

GET /fapi/v1/order

Query parameters

NameTypeDescription
contractName*stringContract
orderIdstringOrder id (or use clientOrderId)
clientOrderIdstringClient order id

200

json
{
    "orderId": 259396989397942275,
    "contractName": "E-BTC-USDT",
    "side": "BUY",
    "action": "OPEN",
    "type": "LIMIT",
    "price": 10000,
    "origQty": 1,
    "executedQty": 0,
    "avgPrice": 0,
    "transactTime": "1607702400000",
    "status": "INIT",
    "fills": []
}

Response

FieldTypeDescription
orderIdlongOrder id
contractNamestringContract
sidestringBUY / SELL
actionstringOPEN / CLOSE
typestringLIMIT / MARKET
pricenumberOrder price
origQtynumberOrder quantity
executedQtynumberFilled quantity
avgPricenumberAverage fill price
transactTimestringCreate time (ms)
statusstringINIT / NEW / PARTIALLY_FILLED / FILLED / CANCELED / REJECTED
fillsarrayFills array

Open orders

GET /fapi/v1/openOrders

Returns the user's open orders. contractName is optional; omit it to query across all contracts.

Query parameters

NameTypeDescription
contractNamestringContract (optional)

200 Same shape as the Order detail array.

Open orders count (paginated)

POST /fapi/v1/openOrdersCount

Useful for paginated browsing of open orders.

Request body

NameTypeDescription
contractIdintegerContract id (optional)
pageintegerPage number (1-based)
pageSizeintegerPage size

200

json
{
    "code": "0",
    "data": {
        "count": 12,
        "orderList": [ /* same shape as openOrders */ ]
    }
}

Order history

POST /fapi/v1/orderHistorical

Request body

NameTypeDescription
contractNamestringContract (optional; omit for all)
limitintegerPage size; default 100; max 1000
fromIdlongStart after this order id

200

json
[
    {
        "orderId": 777293886968070157,
        "contractName": "E-BTC-USDT",
        "side": "BUY",
        "openOrClose": "OPEN",
        "positionType": 2,
        "type": 4,
        "price": 41000,
        "volume": 2,
        "dealVolume": 1,
        "dealMoney": 4.1,
        "avgPrice": 41000,
        "leverageLevel": 26,
        "openTakerFeeRate": 0.00065,
        "openMakerFeeRate": 0.00025,
        "closeTakerFeeRate": 0.00065,
        "closeMakerFeeRate": 0.00025,
        "status": 4,
        "ctime": "2021-09-29T16:16:51",
        "ctimeMs": 1632903411000
    }
]

PnL history

POST /fapi/v1/profitHistorical

Same request body as Order history.

200

json
[
    {
        "id": 8764,
        "contractId": 1,
        "side": "SELL",
        "positionType": 2,
        "leverageLevel": 26,
        "openPrice": 44500,
        "openEndPrice": 44500,
        "volume": 900,
        "tradeFee": -5.23575,
        "capitalFee": 0,
        "shareAmount": 0,
        "closeProfit": -45,
        "settleProfit": 0,
        "realizedAmount": 0,
        "historyRealizedAmount": -50.23575,
        "ctime": 1632882691000,
        "mtime": 1632882739000
    }
]

User trades

GET /fapi/v1/myTrades

Rate limit: 20 req / 2s

Query parameters

NameTypeDescription
contractNamestringContract, e.g. E-BTC-USDT
limitintegerPage size; default 100; max 1000
fromIdlongStart from this trade id

200

json
[
  {
    "tradeId": 100211,
    "symbol": "E-BTC-USDT",
    "contractName": "E-BTC-USDT",
    "bidId": 150695552109032492,
    "askId": 150695552109032493,
    "bidUserId": 10024,
    "askUserId": 10025,
    "price": "4.00000100",
    "qty": "12.00000000",
    "amount": "48.00",
    "time": 1499865549590,
    "side": "BUY",
    "isBuyer": true,
    "isMaker": false,
    "fee": "0.001"
  }
]

Open / close / ADL / liquidation records

GET /fapi/v1/tradesRecord

Paginated user fills with open/close direction labels. Same parameters as User trades.

GET /fapi/v1/adlRecord

Auto-deleveraging records. contractName required, paging same as above.

GET /fapi/v1/liquidationList

Liquidation records.

Conditional orders

MethodPathDescription
POST/fapi/v1/profitLossOrderCreate stop-loss / take-profit attached to a position
POST/fapi/v1/trigger_order_listList trigger orders
POST/fapi/v1/cancel_trigger_orderCancel a trigger order

profitLossOrder body — main fields:

NameTypeDescription
contractNamestringContract
positionIdintegerPosition id
sidestringBUY / SELL
positionTypeinteger1 cross / 2 isolated
orderListarraySub trigger orders

orderList[] items:

NameTypeDescription
triggerTypeinteger3 stop-loss / 4 take-profit
triggerPricenumberTrigger price
pricenumberOrder price after trigger
volumenumberOrder quantity after trigger
typeintegerOrder type
expiredTimeintegerExpiry time (ms)
tagPriceTriggerinteger1 use mark price / 0 use last trade price

Account

Security: USER_DATA

Account endpoints require API key + signature. Headers as in Trading.

Account information

GET /fapi/v1/account

Rate limit: 20 req / 2s

200

json
{
    "account": [
        {
            "marginCoin": "USDT",
            "accountNormal": 999.5606,
            "accountLock": 23799.5017,
            "partPositionNormal": 9110.7294,
            "totalPositionNormal": 0,
            "achievedAmount": 4156.5072,
            "unrealizedAmount": 650.6385,
            "totalEquity": 99964804.560,
            "partEquity": 13917.8753,
            "totalCost": 0,
            "totalMarginRate": 0,
            "sumMarginRate": 873.4608,
            "positionVos": [
                {
                    "contractId": 1,
                    "contractName": "E-BTC-USDT",
                    "contractSymbol": "BTC-USDT",
                    "positions": [
                        {
                            "id": 13603,
                            "contractId": 1,
                            "positionType": 2,
                            "side": "BUY",
                            "volume": 69642.0,
                            "openPrice": 11840.2394,
                            "avgPrice": 11840.3095,
                            "leverageLevel": 24,
                            "holdAmount": 7014.2111,
                            "marginRate": 0.2097,
                            "reducePrice": 9740.8083,
                            "unRealizedAmount": 2164.5289,
                            "realizedAmount": 8115.9125,
                            "positionBalance": 82458.2839,
                            "indexPrice": 12151.1175,
                            "status": 1
                        }
                    ]
                }
            ]
        }
    ]
}

Response — quick guide:

SectionKey fieldsNotes
AccountmarginCoin, accountNormal, accountLock, totalEquity, partEquityMargin asset, balance, locked, cross/isolated equity
AccountunrealizedAmount, achievedAmount, sumMarginRateUnrealized PnL, realized PnL, account margin ratio
PositionpositionVos[].positions[]Per-contract position list
Positionvolume, avgPrice, leverageLevel, positionType, sideSize and leverage
PositionmarginRate, reducePrice, unRealizedAmount, indexPriceFor risk monitoring / liquidation alerts

Full field reference below.

account[] fields

FieldTypeDescription
marginCoinstringMargin asset
accountNormalnumberWallet balance
accountLocknumberLocked margin
partPositionNormalnumberIsolated margin balance
totalPositionNormalnumberCross initial margin in use
achievedAmountnumberRealized PnL
unrealizedAmountnumberUnrealized PnL
totalEquitynumberCross equity
partEquitynumberIsolated equity
totalCostnumberCross cost
totalMarginRatenumberCross margin ratio
sumMarginRatenumberAccount margin ratio
positionVosarrayPositions grouped by contract

positionVos[].positions[] fields

FieldTypeDescription
idintegerPosition id
positionTypeinteger1 cross / 2 isolated
sidestringBUY long / SELL short
volumenumberSize
openPricenumberEntry price
avgPricenumberAverage price
leverageLevelnumberLeverage
holdAmountnumberMargin held
realizedAmountnumberRealized PnL
historyRealizedAmountnumberCumulative realized PnL
unRealizedAmountnumberUnrealized PnL
openRealizedAmountnumberOpen-leg unrealized
positionBalancenumberPosition value
marginRatenumberMargin rate
reducePricenumberLiquidation / reduce price
returnRatenumberReturn rate
indexPricenumberMark price
keepRatenumberTiered maintenance margin rate
maxFeeRatenumberMax close fee rate
tradeFeenumberTrade fee
capitalFeenumberFunding fee
shareAmountnumberSocialized loss share
freezeLockinteger0 normal / 1 liquidation freeze / 2 delivery freeze
statusinteger0 invalid / 1 valid

Positions

GET /fapi/v1/positions

Query parameters

NameTypeDescription
contractNamestringContract (optional)

200

json
{
    "positions": [
        /* each item matches account.positionVos[].positions[] */
    ]
}

Capital flow

GET /fapi/v1/capital

Query parameters

NameTypeDescription
beginTimelongStart time (ms)
endTimelongEnd time (ms)
pageintegerPage
limitintegerPage size

200

json
{
    "records": [
        {
            "contractName": "E-BTC-USDT",
            "type": "TRADE_FEE",
            "amount": "-0.123",
            "balance": "1000.5",
            "time": 1607702400000
        }
    ]
}

Adjust leverage / position model

MethodPathDescription
POST/fapi/v1/edit_leverAdjust leverage for a contract
POST/fapi/v1/level_editLegacy alias for leverage adjustment
POST/fapi/v1/edit_user_position_modelSwitch cross / isolated mode
POST/fapi/v1/edit_user_margin_modelSwitch margin model
POST/fapi/v1/trigger_time_editAdjust trigger expiry time

edit_lever request example:

json
{
    "contractName": "E-BTC-USDT",
    "leverageLevel": 20,
    "positionType": 2
}

Funds transfer (RSA-signed)

Different from HMAC endpoints

The two endpoints below use a separate RSA signing scheme. They require the request headers Ex-sign and Ex-ts and do not reuse X-CH-SIGN / X-CH-TS. They are reserved for institutional integrations — please contact support to obtain an RSA key pair before using them.

HeaderDescription
Ex-tsTimestamp (ms)
Ex-signBase64 RSA signature over JSON.stringify(body) + Ex-ts
MethodPathDescription
POST/fapi/v1/futures_transferTransfer between spot and futures wallets
POST/fapi/v1/futures_balanceQuery futures wallet balance