• OpenApi Basic Information

    中文版本

     

    API Basic Information

    HTTP Error Codes

    General Information

    LIMITS

    Endpoint Security Type

    Security TypeDescription
    NONEEndpoint can be accessed freely.
    TRADEEndpoint requires sending a valid API-Key and signature.
    USER_DATAEndpoint requires sending a valid API-Key and signature.
    USER_STREAMEndpoint requires sending a valid API-Key.
    MARKET_DATAEndpoint requires sending a valid API-Key.

    SIGNED (TRADE 与 USER_DATA) endpoint security

    Timing Security

    Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.

    It recommended to use a small recvWindow of 5000 or less!

    SIGNED Endpoint Examples for POST /sapi/v1/order

    Here is a step-by-step example of how to send a vaild signed payload from the Linux command line using echo, openssl, and curl.

    KeyValue
    apiKeyvmPUZE6mv9SD5V5e14y7Ju91duEh8A
    secretKey902ae3cb34ecee2779aa4d3e1d226686
    Parametervalue
    symbolBTCUSDT
    sideBUY
    typeLIMIT
    volume1
    price9300

    Signature example

     

    ENUM

    Terminology

    Order status:

    Order types:

    Order side:

    Kline/Candlestick Interval:

    min -> minutes; h -> hours; day -> days; week -> weeks; month -> months

     

    Spot

    Public

    Security: None

    Test Connectivity

    This endpoint checks connectivity to the host

    200: OK Connection normal

    Check Server Time

    This endpoint checks connectivity to the server and retrieves server timestamp

    200: OK Successfully retrieved server time

    Pairs List

    200: OK

    weight(IP/UID): 1

    Response:

    symbolstringBTCUSDTName of the symbol Currency to name
    baseAssetstringBTCUnderlying asset for the symbol base currency
    quoteAssetstringUSDTQuote asset for the symbol The base currency
    pricePrecisioninteger2Precision of the price Price Accuracy
    quantityPrecisioninteger6Precision of the quantity Quantity accuracy

    Market

    Security Type: None

    Depth

    market detpth data

    Query Parameters

    NameTypeDescription
    limitintegerDefault 100; Max 100
    symbol*StringSymbol Name E.g. BTCUSDT

    200: OK Successfully retrieved market depth data

    weight(IP/UID): 5

    Response:

    timelong1595563624731Current timestamp (ms)
    bidslist;List of all bids, best bids first. See below for entry details.
    askslist;List of all asks, best asks first. See below for entry details.

    The fields bids and asks are lists of order book price level entries, sorted from best to worst.

    ' 'float131.1price level
    ' 'float2.3The total quantity of orders for this price level

     

    24hrs ticker

    24 hour price change statistics.

    Query Parameters

    NameTypeDescription
    symbol*StringSymbol Name. E.g. BTCUSDT

    200: OK Successfully retrieved ticker data

    weight(IP/UID): 5

    Response:

    timelong1595563624731Open Time 
    highfloat9900High Price 
    lowfloat8800.34Low Price 
    openfloat8700Open Price 
    lastfloat8900Last Price 
    volfloat4999Trade Volume 
    rosefloat0Price increase or Price rise 

     

    Recent Trades List

    Query Parameters

    NameTypeDescription
    symbol*StringSymbol Name. E.g. BTCUSDT
    limitStringDefault 100; Max 1000Responses200

    200: OK

    weight(IP/UID): 5

    Response:

    pricefloat0.055The price of the trade 
    timelong1537797044116Current timestamp (ms) 
    qtyfloat5The quantity traded 
    sidestringBUY/SELLTaker side 

     

    Kline/candlestick data

    Query Parameters

    NameTypeDescription
    symbol* Symbol Name. E.g. BTCUSDT
    interval*StringInterval of the Kline. Possible values include: 1min,5min,15min,30min,60min,1day,1week,1month
    Default 100; Max 300StringDefault 100; Max 300Responses200
    startTimelongstartTime example:1538728740000
    endTimelongendTime example:1538728740000

    200: OK

    weight(IP/UID): 1

    Response:

    idxlong1538728740000Open time 
    openfloat36.00000open price 
    closefloat33.00000close price 
    highfloat36.00000high price 
    lowfloat30.00000low price 
    volfloat2456.111volume 

    Trade

    Security Type: TRADE

    Endpoints under Trade require an API Key and a signature

    New Order

    Rate Limit: 100times/2s

    Query Parameters

    NameTypeDescription
    X-CH-SIGNstringSign
    X-CH-APIKEYstringYour API-key
    X-CH-TSintegertimestamp

    Request Body

    NameTypeDescription
    symbol*StringSymbol Name. E.g. BTCUSDT
    volume*numberOrder vol. For MARKET BUY orders, vol=amount.
    side*StringSide of the order,BUY/SELL
    type*StringType of the order, LIMIT/MARKET
    price*numberOrder price, REQUIRED for LIMIT orders
    newClientOrderIdStringUnique order ID generated by users to mark their orders
    recvwindowintegerTime window

    200: OK Successfully post new order

    weight(IP/UID): 5

    Response:

    orderIdlong150695552109032492ID of the order 
    clientorderIdstring213443A unique ID of the order. 
    symbolstringBTCUSDTSymbol Name 
    transactTimeinteger1273774892913Time the order is placed 
    pricefloat4765.29Time the order is placed 
    origQtyfloat1.01Quantity ordered 
    executedQtyfloat1.01Quantity of orders that has been executed 
    typestringLIMITOrder typeLIMIT,MARKET 
    sidestringBUYOrder side:BUY, SELL 
    statusstring00 = new order 

    Test New Order

    Test new order creation and signature/recvWindow length. Creates and validates a new order but does not send the order into the matching engine.

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    Request Body

    NameTypeDescription
    type*StringType of the order, LIMIT/MARKET
    price*numberOrder price, REQUIRED for LIMIT orders
    volume*numberOrder vol. For MARKET BUY orders, vol=amount.
    side*StringSide of the order, BUY/SELL
    symbol*StringSymbol Name. E.g. BTCUSDT
    recvwindowintegerTime window
    newClientorderIdStringUnique order ID generated by users to mark their orders

    200: OK Successfully test new order

    weight(IP/UID): 1

     

    Batch Orders

    batch contains at most 10 orders

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    Request Body

    NameTypeDescription
    ordersnumberThe batch order information can contain a maximum of 10 records.
    symbol*StringSymbol Name. E.g. BTCUSDT

    200: OK

    weight(IP/UID): 10

    Resquest orders field:

    nametypeExampleDescription
    pricefolat1000Price
    volumefolat20.1Quantity
    sideStringBUY/SELLDirection
    batchTypeStringLIMIT/MARKETType

    Resquest

    idsStringString“3213213”A collection of order numbers of type String.
    idsinteger2100Collection of order numbers.

     

    Query Order

    Query Parameters

    NameTypeDescription
    orderId*StringOrder ID
    newClientorderIdStringClient Order Id, Unique order ID generated by users to mark their orders. E.g. 354444heihieddada
    symbol*StringSymbol Name. E.g. BTCUSDl

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestampResponses200
    X-CH-SIGNStringSign

    200: OK

    weight(IP/UID): 1

    Response:

    orderIdlong150695552109032492Order ID (system generated) 
    clientorderIdstring213443Order ID (sent by yourself) 
    symbolstringBTCUSDTCurrency Pair Name 
    pricefloat4765.29Order Price 
    origQtyfloat1.01Number of orders 
    executedQtyfloat1.01Number of orders already filled 
    avgPricefloat4754.24Average price of orders already filled 
    typestringlimitThe order typeLIMIT,MARKET 
    sidestringBUYOrder direction. Possible values can only be: BUY (buy long) and SELL (sell short) 
    statusstringNEWOrder status. Possible values are NEW (new order, no transaction), PARTIALLY_FILLED (partially filled), FILLED (fully filled), CANCELED (cancelled) and REJECTED (order rejected).POST 
    transactTimestring1574327555669Order Creation Time 

     

     

    Cancel Order

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    Request Body

    NameTypeDescription
    newClientOrderIdStringClient Order Id, Unique order ID generated by users to mark their orders. E.g. 354444heihieddada
    orderId*StringOrder ID
    symbol*StringSymbol Name. E.g. BTCUSDT

    200: OK

    weight(IP/UID): 5

    Response:

    orderIdlong150695552109032492ID of the order 
    clientorderIdstring213443Unique ID of the order. 
    symbolstringBTCUSDTName of the symbol 
    statusstringNEWThe state of the order.Possible values include NEW, PARTIALLY_FILLED, FILLED, CANCELED, and REJECTED.POST 

     

     

    Batch cancel orders

    batch contains at most 10 orders

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    Request Body

    NameTypeDescription
    orderIdsStringOrder ID collection[123,456]Responses200GET
    symbol*StringSymbol Name. E.g. BTCUSDT

    200: OK

    weight(IP/UID): 10

    Current Open Orders

    Query Parameters

    NameTypeDescription
    symbol*StringSymbol Name. E.g. BTCUSDT
    limitStringDefault 100; Max 1000

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    200: OK

    weight(IP/UID): 1

    Response:

    orderIdlong150695552109032492ID of the order 
    orderIdStringstring"150695552109032492"Character String Type Order ID (Recommended) 
    clientorderIdstring213443Unique ID of the order. 
    symbolstringBTCUSDTName of the symbol 
    pricefloat4765.29Price of the order 
    origQtyfloat1.01Quantity ordered 
    executedQtyfloat1.01Quantity of orders that has been executed 
    avgPricefloat4754.24Average price of filled orders. 
    typestringLIMITThe order typeLIMIT,MARKET 
    sidestringBUYThe order side BUY,SELL 
    statusstringNEWThe state of the order.Possible values include NEW, PARTIALLY_FILLED, FILLED, CANCELED, and REJECTED.GET 
    timestring1574327555669Creation Time 

     

    Trades

    Query Parameters

    NameTypeDescription
    symbol*StringSymbol Name. E.g. BTCUSDT
    limitStringDefault 100; Max1000
    fromIdStringTrade Id to fetch from

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    200: OK

    weight(IP/UID): 1

    Response:

    symbolstringBTCUSDTName of the symbol
    idinteger28457Trade ID
    bidIdlong150695552109032492Bid Order ID
    askIdlong150695552109032492Ask Order ID
    priceinteger4.01Price of the trade
    qtyfloat12Quantiry of the trade
    timenumber1499865549590timestamp of the trade
    isBuyerbooltruetrue= Buyer false= Seller
    isMakerboolfalsetrue=Maker false=Taker
    feeCoinstringETHTrading fee coin
    feenumber0.001Trading fee
    bidUserIdlong23334Buyer UID
    askUserIdlong44112Seller UID
    isSelfbooltruewhether is self dealt

     

    Account

    Security Type: USER_DATA

    Endpoints under Account require an API-key and a signature.

    Account Information

    Headers

    NameTypeDescription
    X-CH-APIKEYStringYour API-key
    X-CH-TSStringtimestamp
    X-CH-SIGNStringSign

    200: OK Successfully retrieved account information.

    weight(IP/UID): 1

    Response:

    nametypedescription
    balances[]Show balance details

    balances field:

    nametypeexampledescription
    assetstringUSDTName of the asset
    freefloat1000.30Amount available for use
    lockedfloat400Amount locked (for open orders)

     

     

    Margin

    Trade

    Security Type: TRADE

    Endpoints under Trade require an API-key and a signature.

    New Order

    Rate Limit:100times/2s

    Headers

    NameTypeDescription
    X-CH-SIGNStringSign
    X-CH-TSStringtimestamp
    X-CH-APIKEYStringYour API-key

    Request Body

    NameTypeDescription
    typeStringType of the order, LIMIT/MARKET
    recwwindowStringTime window
    pricenumberOrder price, REQUIRED for LIMIT orders
    newClientOrderIdStringUnique order ID generated by users to mark their orders, Cannot exceed 32 characters
    sideStringSide of the order, BUY/SELL
    volumenumberOrder vol. For MARKET BUY orders, vol=amount.
    symbolStringSymbol Name. E.g. BTCUSDT

    200: OK

    weight(IP/UID): 5

     

    Query Order

    Rate Limit: 20times/2s

    Query Parameters

    NameTypeDescription
    orderIdStringOrder ID
    newClientOrderIdStringClient Order Id, Unique order ID generated by users to mark their orders. E.g. 354444heihieddada
    symbolStringSymbol Name.E.g. BTCUSDTHeader

    Headers

    NameTypeDescription
    X-CH-SIGNStringSign
    X-CH-TSStringtimestamp
    X-CH-APIKEYStringYour API-key

    200: OK

    weight(IP/UID): 5

     

    Cancel Order

    Rate Limit: 100times/2s

    Headers

    NameTypeDescription
    X-CH-SIGNStringSign
    X-CH-TSStringtimestamp
    X-CH-APIKEYStringYour API-key

    Request Body

    NameTypeDescription
    newClientOrderIdStringSymbol Name. E.g. BTCUSDTResponses200GET
    symbolStringClient Order Id, Unique order ID generated by users to mark their orders. E.g. 354444heihieddada
    orderIdStringOrder ID

    200: OK

    weight(IP/UID): 5

     

    Current Open Orders

    Rate Limit: 20times/2s

    Query Parameters

    NameTypeDescription
    symbolStringSymbol Name. E.g. BTCUSDT
    limitStringDefault 100; Max 1000

    Headers

    NameTypeDescription
    X-CH-SIGNStringSign
    X-CH-TSStringtimestamp
    X-CH-APIKEYStringYour API-key

    200: OK

    weight(IP/UID): 1

     

    Trades

    Query Parameters

    NameTypeDescription
    symbolStringSymbol Name. E.g. BTCUSDT
    limitStringDefault 100; Max 1000
    fromIdStringTrade Id to fetch from

    Headers

    NameTypeDescription
    X-CH-SIGNStringSign
    X-CH-TSStringtimestamp
    X-CH-APIKEYStringYour API-key

    200: OK

    weight(IP/UID): 1

     

     

    Contract

    Public

    Security: None

    Endpoints under Public section can be accessed freely without requiring any API-key or signatures

    Test Connectivity

    This endpoint checks connectivity to the host

    200

     

    Check Server Time

    200

    Response:

    nametypeexampledescription
    serverTimelong1607702400000server timestamp
    timezonestringChina standard timeserver time zone

    Contract List

    200

    Response:

    nametypeexampledescription
    symbolstringE-BTC-USDTContract name
    statusnumber1status(0:cannot trade,1:can trade
    typestringScontract type, E: perpetual contract, S: test contract, others are mixed contract
    sidenumber1Contract direction(backwards:0,1:forward)
    multipliernumber0.5Contract face value
    multiplierCoinstringBTCContract face value unit
    pricePrecisionnumber4Precision of the price
    minOrderVolumenumber10Minimum order volume
    minOrderMoneynumber10Minimum order value
    maxMarketVolumenumber100000Market price order maximum volume
    maxMarketMoneynumber100000Market price order maximum value
    maxLimitVolumenumber100000Limit price order maximum volume
    maxValidOrdernumber100000Maximum valid order quantity

    Market

    Security: None

    Market section can be accessed freely without requiring any API-key or signatures.

    Depth

    Market depth data

    Query Parameters

    NameTypeDescription
    limitintegerDefault 100, Max 100
    Contract namestringContract Name E.g. E-BTC-USDT

    200 Successfully retrieve market depth data

     

    Response:

    nametypeexampledescription
    timelong1595563624731Current Timestamp (ms)
    bidslistLook belowOrder book purchase info
    askslistLook belowOrder book selling info

    The fields bids and asks are lists of order book price level entries, sorted from best to worst.

     

    nametypeexampledescription
    ' 'float131.1price level
    ' 'float2.3Total order quantity for this price level

    24hrs ticker

    24 hour price change statistics

    Query Parameters

    NameTypeDescription
    Contract namestringContract name E.g. E-BTC-USDT

    200 Successfully obtain ticker info

    Response:

    nametypeexampledescription
    timelong1595563624731Open time
    highfloat9900Higher price
    lowfloat8800.34Lower price
    lastfloat8900Newest price
    volfloat4999Trade volume
    rosestring+0.5Price variation

    Get index/marked price

    Query Parameters

    NameTypeDescription
    Contract namestringContract name E.g. E-BTC-USDT
    limitstringDefault 100, Max 100

    200

    Response:

    nametypeexampleDescription
    indexPricefloat0.055Index price
    markPricefloat0.0578Marked price
    contractNamestringE-BTC-USDTContract name
    lastFundingRatefloat0.123Current fund rate

    Kline/charts data

    Query Parameters

    NameTypeDescription
    ContractNamestringContract name E.g. E-BTC-USDT
    intervalstringK-line interval, identifies the sent value as: 1min,5min,15min,30min,1h,1day,1week,1month
    limitintegerDefault 100, Max 300

    200

    Response:

    nametypeexampledescription
    idxlong1538728740000Start timestamp (ms)
    openfloat36.00000Open price
    closefloat33.00000Closing price
    highfloat36.00000Max price
    lowfloat30.00000Min price
    volfloat2456.111Trade volume

    Trading

    Security: TRADE

    All interfaces under the transaction require signature and API-key verification

    Order creation

    Creation of single new orders

    Headers

    NameTypeDescription
    X-CH-TSstringTime stamp
    X-CH-APIKEYstringYour API-key
    X-CH-SIGNstringSignature

    Request Body

    NameTypeDescription
    volumenumberOrder quantity
    pricenumberOrder price
    contractNamestringContract name E.g. E-BTC-USDT
    typestringOrder type, LIMIT/MARKET
    sidestringtrade direction, BUY/SELL
    openstringOpen balancing direction, OPEN/CLOSE
    positionTypenumberHold-up position,1 full position, 2 restrictive position
    clientOrderIdstringClient order identity, a string with length less than 32 bit
    timeInForcestringLIMIT/MARKET

    200

    Response:

    nametypeexampledescription
    orderIdString256609229205684228Order ID

    Condition order creation

    Headers

    NameTypeDescription
    X-CH-TSstringTime stamp
    X-CH-APIKEYstringYour API-key
    X-CH-SIGNstringSignature

    Request Body

    NameTypeDescription
    volumenumberOrder quantity
    triggerTypestringtrigger type 3UP/4DOWN
    triggerPricestringtrigger price
    positionTypenumberHold-up position,1 full position, 2 restrictive position
    openstringOpen balancing direction, OPEN/CLOSE
    sidestringtrade direction, BUY/SELL
    typestringOrder type, LIMIT/MARKET
    contractNamestringContract name E.g. E-BTC-USDT
    pricenumberOrder price

    200: OK

    Cancel order

    Speed limit rules: 20 times/ 2 seconds

    Headers

    NameTypeDescription
    X-CH-SIGNstringSignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSintegerTime stamp

    Request Body

    NameTypeDescription
    contractNamestringContract name E.g.E-BTC-USDT
    orderIdstringOrder ID

    200

    Order details

    Request Body

    NameTypeDescription
    contractNamestring 

    200

    Response:

    nametypeexampledescription
    orderIdlong150695552109032492Order ID(system generated
    contractNamestringE-BTC-USDTContract name
    pricefloat10.5Order price
    origQtyfloat10.5Order quantity
    executedQtyfloat20Order quantity
    avgPricefloat10.5Average transaction price
    symbolstringBHTUSDTCoin pair name
    statusstringNEWOrder status. Possible values are:NEW(new order,not filled)、PARTIALLY_FILLED(partially filled)、FILLED(fully filled)、CANCELLED(already cancelled)andREJECTED(order rejected)
    sidestringNEWOrder direction. Possible values can only be:BUY(buy long)and SELL(sell short)
    actionstringOPENOPEN/CLOSE
    transactTimelong1607702400000Order creation time

    Open order

    Speed limit rules: Obtain open contract, the user's current order

    Query Parameters

    NameTypeDescription
    contractNamestringContract name E-BTC-USDT

    Headers

    NameTypeDescription
    X-CH-SIGNstringsignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSintegertime stamp

    200

    Response:

    nametypeexampledescription
    orderIdlong150695552109032492Order ID(system generated)
    contractNamestringE-BTC-USDTContract name
    pricefloat4765.29Order price
    origQtyfloat1.01Order quantity
    executedQtyfloat1.01Filled orders quantity
    avgPricefloat4754.24Filled orders average price
    typestringLIMITOrder type. Possible values can only be:LIMIT(limit price) andMARKET(market price)
    sidestringBUYOrder direction. Possible values can only be:BUY(buy long)and SELL(sell short)
    statusstringNEWOrder status. Possible values are:NEW(new order,not filled)、PARTIALLY_FILLED(partially filled)、FILLED(fully filled)、CANCELLED(already cancelled)andREJECTED(order rejected)
    actionstringOPENOPEN/CLOSE
    transactTimelong1607702400000Order creation time,

    order history

    Headers

    NameTypeDescription
    X-CH-SIGNstringsignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSstringtime stamp

    Request Body

    NameTypeDescription
    contractNamestringContract name E.g. E-BTC-USDT
    limitstringLines per page, default 100, max 1000
    fromIdlongStart retrieving from this Id

    200: OK

    profit history

    Headers

    NameTypeDescription
    X-CH-SIGNstringsignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSstringtime stamp

    Request Body

    NameTypeDescription
    contractNamestringContract name E.g. E-BTC-USDT
    limitstringLines per page, default 100, max 1000
    fromIdlongStart retrieving from this Id

    200: OK

     

    Order record

    Query Parameters

    NameTypeDescription
    contractNamestringContract name E.g. E-BTC-USDT
    limitstringLines per page, default 100, max 1000
    fromIdlongStart retrieving from this tradeId

    Headers

    NameTypeDescription
    X-CH-SIGNstringsignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSstringtime stamp

    200

    Response:

     

    nametypeexampledescription
    symbolstringETHBTCCoin name(trade pair)
    tradeIdnumber28457Trade ID
    bidIdlong150695552109032492Buyer order ID
    askIdlong150695552109032493Seller order ID
    bidUserIdinteger10024Buyer user ID
    askUserIdinteger10025Seller user ID
    pricefloat4.01Filled price
    qtyfloat12Trade quantity
    amountfloat5.38Filled amount
    timenumber1499865549590Trade time stamp
    feenumber0.001Trading fees
    sidestringbuyCurrent order direction BUY purchase, SELL selling
    contractNamestringE-BTC-USDTContract name
    isMakerbooleantrueis it maker?
    isBuyerbooleantrueis it buyer?

    Account

    Security: USER_DATA

    All interfaces under the account require signature and API-key verificationwindow.location='https://exdocs.gitbook.io/v/v/english/general-info#signed-trade-yu-userdata-endpoint-security')

    Account info

    Headers

    NameTypeDescription
    X-CH-SIGNstringSignature
    X-CH-APIKEYstringYour API-key
    X-CH-TSintegertime stamp

    200

    Response:

     

    nametypedescription
    account[]Balance collection

    account field:

    nametypeexampledescription
    marginCoinstringUSDTMargin coin
    accountNormalfloat10.05Balance account
    accountLockfloat10.07Margin frozen account
    partPositionNormalfloat10.07Restricted position margin balance
    totalPositionNormalfloat10.07Full position initial margin
    achievedAmountfloat10.07Profit and losses occurred
    unrealizedAmountfloat10.05Unfilled profit and losses
    totalMarginRatefloat10.05Full position margin rate
    totalEquityfloat10.07Full position equity
    partEquityfloat10.07Restricted position equity
    totalCostfloat10.07Full position costs
    sumMarginRatefloat10.07All accounts margin rate
    positionVos[ ] Position contract record

    positionVos field:

    nametypeexampledescription
    contractIdinteger2Contract id
    contractNamestringE-BTC-USDTContract name
    contractSymbolstringBTC-USDTContract coin pair
    positions[ ] Position details

    positions field:

    nametypeexampledescription
    idinteger2Position id
    uidinteger10023User ID
    positionTypeinteger1Hold position type(1 full,2 restrictive)
    sidestringSELLHold position direction BUY sell long, SELL buy short
    volumefloat1.05Hold quantity
    openPricefloat1.05Open position price
    avgPricefloat1.05Hold average price
    closePricefloat1.05Balancing average price
    leverageLevelfloat1.05Leverage multiple
    holdAmountfloat1.05Hold position margin
    closeVolumefloat1.05Balanced quantity
    pendingCloseVolumefloat1.05The number of pending closing orders
    realizedAmountfloat1.05Profit and losses occurred
    historyRealizedAmountfloat1.05Historic accumulated profit and losses
    tradeFeefloat1.05Trading fees
    capitalFeefloat1.05Capital costs
    closeProfitfloat1.05Balancing profit and loss
    shareAmountfloat1.05Amount to share
    freezeLockinteger0Position freeze status: 0 normal, 1 liquidation freeze, 2 delivery freeze
    statusinteger0Position effectiveness,0 ineffective 1 effective
    ctimetime Creation time
    mtimetime Update time
    brokerIdinteger1023Client id
    lockTimetime liquidation lock time
    marginRatefloat1.05Margin rate
    reducePricefloat1.05Price reduction
    returnRatefloat1.05Return rate (profit rate)
    unRealizedAmountfloat1.05Unfilled profit and losses
    openRealizedAmountfloat1.05Open position unfilled profit and losses
    positionBalancefloat1.05Position value
    indexPricefloat1.05Newest marked price
    keepRatefloat1.05Scaled minimum kept margin rate
    maxFeeRatefloat1.05Balancing maximum fees rate

     

    Create a profit stop loss order

    Create a single new order

    Headers

    NameTypeDescription
    X-CH-TSstringTimestamp
    X-CH-APIKEYstringAPI-KEY
    X-CH-SIGNstringSignature

    Request Body

    NameTypeDescription
    contractNamestringContract name such as E-BTC-USDT
    typestringOrder Type(1 limit, 2 market)
    sidestringBuy and sell direction, BUY/SELL
    openstringOpening and closing direction, OPEN/CLOSE
    positionTypenumberPosition type, 1 Full Position/2 Position by Position
    leverageLevelnumberLeverage, 10
    orderListStrstringOrder list

    OrderListStr

    NameTypeDescription
    triggerTypenumberStop-loss and take-profit order types (1 stop-loss, 2 take-profit)
    volumenumberOrder quantity
    pricenumberOrder price
    typestringOrder Type(1 limit, 2 market)
    expiredTimenumberValid time Unit: Days
    triggerPricenumberTrigger Price

    Response

    NameTypeExampleDescription
    orderIdstring256609229205684228Order ID

     

    Cancel the profit stop loss order

    Create a single new order

    Headers

    NameTypeDescription
    X-CH-TSstringTimestamp
    X-CH-APIKEYstringAPI-KEY
    X-CH-SIGNstringSignature

    Request Body

    NameTypeDescription
    contractNamestringContract name such as E-BTC-USDT
    orderIdsstringOrder ID, used for multiple orders, separated

    Response

    NameTypeExampleDescription
    codestring0Status 0 Success

     

    Lightning close

    Headers

    NameTypeDescription
    X-CH-SIGNstringSignature
    X-CH-APIKEYstringAPI-key
    X-CH-TSintegerTimestamp

    Request Body

    NameTypeDescription
    contractNamestringContract name such as E-BTC-USDT
    sidestringBuy and sell direction, BUY/SELL
    openstringOpening and closing direction, OPEN/CLOSE
    positionTypenumberPosition type, 1 Full Position/2 Position by Position

    Response

    NameTypeExampleDescription
    orderIdstring256609229205684228订单ID

     

    Check the stop-profit and stop-loss orders

    Query the user's effective stop-profit and stop-loss orders

    Headers

    NameTypeDescription
    X-CH-TSstringTimestamp
    X-CH-APIKEYstringAPI-KEY
    X-CH-SIGNstringSignature

    Request Body

    NameTypeDescription
    contractNamestringContract Name : E-BTC-USDT

    Response

    Request Body

    NameTypeDescription
    takeProfitListArrayTake Profit Order List
    stopLossListArrayStop Loss Order List
    takeProfitCountIntegerNumber of take profit orders
    stopLossCountIntegerNumber of stop loss orders
    countIntegerTotal Orders

    Order Object Field Description

    Field NameTypeDescription
    idStringOrder ID
    contractNameStringContract Name
    triggerPriceBigDecimalTrigger Price
    priceBigDecimalCommission Price
    pricePrecisionIntegerPrice precision (decimal places)
    volumeBigDecimalOrder quantity
    baseStringBase currency (such as BTC)
    quoteStringDenominated currency (such as USDT)

     

    Withdraw

    Apply for withdrawal

    Headers

    NameTypeDescription
    X-CH-APIKEY*StringYour API-key
    X-CH-SIGN*StringSign
    X-CH-TS*Integertimestamp

    Request Body

    NameTypeDescription
    withdrawOrderId*StringCustom withdrawal id, guaranteed to be unique
    amount*Stringquantity
    address*StringWithdrawal address
    labelStringSome currencies such as XRP, XMR allow filling of secondary address labels
    symbolStringcurrency name,For coins that support multiple mainchains, the actual currency name needs to be transmitted, as shown in Appendix 1

    200: OK

    weight(IP/UID): 100

    Withdrawal record query

    Headers

    NameTypeDescription
    X-CH-APIKEY*StringYour API-key
    X-CH-SIGN*StringSign
    X-CH-TS*Stringtimestamp

    Request Body

    NameTypeDescription
    symbolStringCurrency Name, For coins that support multiple mainchains, the actual currency name needs to be transmitted, as shown in Appendix 1
    withdrawIdStringPlatform withdrawal id
    withdrawOrderIdStringCustom withdrawal id
    startTimeStringStart time, timestamp, default 90 days ago
    endTimeStringend time, timestamp, default current time
    pageStringPage number, starting at 1

    200: OK

    weight(IP/UID): 100

    Responses

    ParameterTypeExampleRemark
    symbolStringUSDTWithdrawal currency
    amountNumber9.99quantity
    addressStringTFFrjNfBAagmFWypE3Hnv6zPKAFhd3VcDfWithdrawal address
    withdrawOrderIdStringabc123Custom withdrawal id
    feeNumber0.01fee
    ctimeNumber1605585397000creation time
    txIdString749864_20201117115930Withdrawal transaction id
    idNumber749864Platform withdrawal id
    applyTimeNumber1605585397000On-chain time
    statusNumber2Withdrawal status, 0-unapproved, 1-approved, 2-approved rejected, 3-payment, 4-payment failed, 5-completed, 6-revoked
    infoStringWithdrawal address errorReview rejection reasons

     

    WebSocket

    General

    Websocket is a new HTML5 Protocol. It achieves full-duplex data transmission between the client and the server, allowing data to be transferred effectively in both directions. With just only one handshake, the connection between the client and the server is established. The server will then be able to push data to the client according to preset rules. Its advantages include:

    We strongly recommend developers to use WebSocket API to retrieve market data and order book depth.

    Ws information

    heartbeat

    The server actively pushes ping messages every 10 seconds, and the client can decide whether to process it after receiving it (the server does not perform strict one-to-one verification and time verification on the client's Pong reply). To ensure the validity of the link, it is recommended that the client immediately reply in Pong format after receiving the ping message from the server. Format of ping message that is sent by Server is: {"ping": timestamp (seconds)} pong message format that is replied by client is : {"pong": timestamp (seconds)} Example: {"pong":1694416595}

    Command Format

    submarket_$symbol_depth_step0Subscribe depth 描述
    unsubmarket_$symbol_depth_step0Unsubscribe depth 币对名称
    submarket_$symbol_trade_tickerSubscribe to real-time trade base货币
    unsubmarket_$symbol_trade_tickerUnsubscribe real-time trade 计价货币
    submarket_$symbol_tickerSubscribe to 24h market data 价格精度
    unsubmarket_$symbol_tickerUnsubscribe 24h market data 数量精度
    submarket_$symbol_kline_1minSubscribe to 1min k-line information  
    regmarket_$symbol_kline_1monthRequest 1 month historical bar record  

     

    Heartbeat

    Every once in a while, the server will send a PING message. The client needs to reply to the PONG message, otherwise the server will close the connection.

    Subscription Full Depth

    Subscription Real Time Trade

    Subscription Kline Market

    Subscription Market Tickers

    Request Kline History Data

    Request History Trade

     

    Errors

    Errors consist of two parts: an error code and a message. Codes are universal, but messages can vary. Here is the error JSON payload:

    Copy

     

    General Server or Network issues

    code描述
    -1000An unknown error occured while processing the request.
    -1001Internal error; unable to process your request. Please try again.
    -1002You are not authorized to execute this request. Request need API Key included in . We suggest that API Key be included in any request.
    -1003Requests exceed the limit too frequently.
    -1004You are not authorized to execute this request. User not exit Company
    -1006An unexpected response was received from the message bus. Execution status unknown. OPEN API server find some exception in execute request .Please report to Customer service.
    -1007Timeout waiting for response from backend server. Send status unknown; execution status unknown.
    -1014Unsupported order combination.
    -1015Too many new orders.
    -1016This service is no longer available.
    -1017We recommend attaching Content-Type to all request headers and setting it to application/json
    -1020This operation is not supported.
    -1021Timestamp for this request is outside of the recvWindow.Timestamp for this request was 1000ms ahead of the server's time.Please check the difference between your local time and server time .
    -1022Signature for this request is not valid.
    -1023You are not authorized to execute this request, we recommend that you add X-CH-TS to all request headers
    -1024You are not authorized to execute this request, we recommend that you add X-CH-SIGN to the request header

     

    Request issues

    code描述
    -1100Illegal characters found in a parameter.
    -1101Too many parameters sent for this endpoint
    -1102A mandatory parameter was not sent, was empty/null, or malformed.Mandatory parameter '%s' was not sent, was empty/null, or malformed. Param '%s' or '%s' must be sent, but both were empty/null!
    -1103An unknown parameter was sent.each request requires at least one parameter. {Timestamp}.
    -1104Not all sent parameters were read.Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'.
    -1105A parameter was empty.Parameter '%s' was empty.
    -1106A parameter was sent when not required.Parameter '%s' sent when not required.
    -1111Precision is over the maximum defined for this asset.
    -1112No orders on book for symbol.
    -1116Invalid orderType.In the current version , ORDER_TYPE values is LIMIT or MARKET.
    -1117Invalid side.ORDER_SIDE values is BUY or SELL
    -1118New client order ID was empty.
    -1121Invalid symbol.
    -1136Order volume lower than the minimum.
    -1138Order price exceeds permissible range.
    -1139This trading pair does not support market trading
    -1145This order type does not support cancellation
    -2013Order does not exist.
    -2015Invalid API-key, IP, or permissions for action.
    -2016Transaction is frozen
    -2017Insufficient balance

     

    Official SDK

    Demo Url

    https://github.com/exchange2021

    Signed example

    Here is a example of how to create order

     

     

    FAQ

    What is the maximum difference between the timestamp parameter of the request interface and the arrival time of the server?

    When the server receives the request, it will judge the timestamp in the request. If it is sent before 5000 milliseconds, the request will be considered invalid. This time window value can be customized by sending the optional parameter recvWindow.

    The request header "X-CH-TS" cannot be empty. How to solve it?

    First, it is recommended that the user print out the X-CH-TS, and check whether the X-CH-TS is empty when there is an exception, and it is recommended that the user code is optimized, and judge whether the X-CH-TS is empty before each request.

    Why does authentication always return invalid signatures?

    You can print out the request header information and the string before signature, with the following points::

    The calling interface prompts ILLEGAL_CONTENT_TYPE (-1017). What is the reason?

    We recommend attaching Content-Type to all request headers and setting it to application/json

    Is there a limit to the frequency of API calls per second?

    There are restrictions. For details, see the access frequency restrictions for each interface in the document.

    What is the limit on API access frequency

    Personal data is restricted according to API-key, and public data is restricted according to ip. It should be noted that if the user requests public data and passes in valid personal information, it is restricted according to API-key.

    What is the cause of HTTP status code 429?

    The request interface exceeds the access frequency limit. It is recommended to reduce the access frequency.

    Will the IP be blocked if the API call interface reports that the access frequency is exceeded? How long is it sealed?

    Normally not, just reduce the frequency of access.

    Why is WebSocker disconnected??

    The user request interface reports an error Time Out?

    The network cannot connect to the server. It is recommended that you check whether the network is smooth.

    How to get all the currency pairs on the platform?

    Coin's /sapi/v1/symbols interface can be obtained

    Is there a limit on the number of batch orders/cancellations??

    Yes, the batch interface will limit 10 orders

    What is newClientOrderId and what does it do?

    How to get the latest transaction price?

    You can get ticker information, last is the latest transaction price

    Will there be a negative growth in the 24-hour trading volume in the ticker interface?

    Will do. Because the 24-hour trading volume is a 24-hour rolling data (the size of the translation window is 24 hours), it may happen that the accumulated trading volume and accumulated trading volume in the next window are smaller than the previous window.