English
NAV Navbar
console

Changelog

November 10, 2020 【New fields in account interface】

1 Query all contract account information

November 3, 2020【Modify k-line interface and position information】

1 Get k-line data

2 Get contract position information

October 26, 2020【New contract documentary interface】

1、Place an order to close a warehouse

2、Get the trader's current list of orders

3、Get a list of historical tapes

4、Place an order

10.10 October【Added multiple interface return values】

1、Get all ticker information and add "24-hour trading volume" field

2、Get the information of a single ticker and add the "24-hour volume" field

3、Get the position information of all contracts and add the "unrealized profit and loss" field

4、Get position information of a single contract and add "unrealized profit and loss" field

5、Get the platform's total holdings and add multiple fields

September 16, 2020【New return value of contract information port】

1、Contract Information

September 14, 2020 [New contract supports full position]

1、Modify user account mode

September 7, 2020 [New Interface]

1、Get contract historical funding rate

2、Get order history commission

3、Get the current order of the order

June 9, 2020 [Add v3 contract document]

October 26, 2020【New contract documentary interface】

1、Place an order to close a warehouse

2、Get the trader's current list of orders

3、Get a list of historical tapes

4、Place an order

Historical API address

Contract WebSocket quotes, assets and trade push API

WebSocket API

Contract trading REST market, trading API

Contract API

INTRODUCTION

API INTRODUCTION

Welcome to Bitget API!

This is the official Bitget API document, this data is available and updates in real-time. Please follow us to get latest news.

You can switch to different API business in the top menu, and switch to different language by clicking the button in the top right.

The example of request and response is showing in the right-hand side.

Market Maker Program

Bitget welcome making /liquidity providing with good market making strategy and large trading volume. Please provide the information as below and email to:

  1. Please provide UID (This account is not allow to link to any rebate program account);
  2. Screenshot of trading volume in other transaction platform (such as trading volume within 30 days);
  3. A brief description of your market-making strategy。

Subscription

Bitget will publish API announcement in advance for any API change, please subscribe our announcements so that you can get latest update.

You can click Here to subscribe the announcements.Here subscribe。

contact us

You can contact us at bd.overseas@bitget.com if any issue or suggestions

Quick Start

Preparation

Before you use API, you need to login the website to create API Key with proper permissions.

You can manage your API Key. Here create API Key。

Every user account can create at most 10 API Key, each of them has two permissions:

Permission : - Read permission: It is used to query the data, such as order query, trade query. - Trade permission: It is used to create order, cancel order and transfer, etc.

Please remember below information after creation:

SDK and Demo

SDK (Suggested)

Java | Python | Node

CCXT is our authorized SDK provider and you may access the Bitget API through CCXT. For more information, please visit: https://ccxt.trade.

Interface Type

This chapter mainly divides the following two aspects into interface types:

Public APIs

The public interface can be used to get configuration information and market data. Public requests can be invoked without authentication.

Private APIs __

The private interface can be used for order management and account management. Each private request must be signed using a canonical form of validation.

The private interface needs to be validated using your APIKey.

Restriction of visit

This chapter is mainly for access restrictions:

When access exceeds the frequency limit, a status of 429 is returned: requests are too frequent.

Rest API

If a valid APIKey is passed in, limit the speed with APIKey; If not, then take the public IP speed limit.

Speed limit rules: there are separate instructions for each interface. If there is no general interface, the speed limit is 10 times/second.

Special note: When placing bulk orders, if 4 coin pairs are placed and each coin pair is 10 orders, it will be counted as one request.

API Domain

You can use the Rest API access method to operate by yourself.

Domain REST API Suggestion
Domain1 https://capi.bitget.com International
Domain2 https://capi.bitgetapi.com CHINA

API Authentication

Making Requests

All REST request headers must contain the following keys:

The signature

ACCESS-SIGN The request header is correct timestamp + method.toUpperCase() + requestPath + "?" + queryString + body String (+ represents string concatenation) is used HMAC SHA256 Method encrypt and pass*BASE64* Produced by encoding the output.

Signature field description

When the queryString is empty, the signature format

timestamp + method.toUpperCase() + requestPath + body

Signature format when queryString is not null

timestamp + method.toUpperCase() + requestPath + "?" + queryString + body

For example

Get the depth information of the contract. Take cmt_btcusdt as an example:

Generate the string to be signed:

'1591089508404GET/api/swap/v1/market/depth?symbol=cmt_btcusdt&limit=20'

Order by contract, take cmt_btcusdt as an example:

Generate the string to be signed:

'1561022985382POST/api/swap/v3/order/placeOrder{"symbol":"cmt_btcusdt","size":"8","type":"1","match_price":"1","order_type":"1","client_oid":"bitget#123456"}'

The steps to generate the final signature

In step 1, the string to be signed is encrypted using the private key secretkey for HMAC Sha256

Signature = hmac_sha256(secretkey, Message)

Step 2: Base64 encoding for Signature

Signature = base64.encode(Signature)

Request interaction

All requests are based on Https protocol, and the content-type in the request header should be uniformly set to 'Application/JSON'.

Request interaction specification

successful

The HTTP status code 200 indicates a successful response and may contain content. If the response contains content, it is displayed in the corresponding return content.

Common error code

Standard specification

The time stamp

The access-Timestamp in the request signature is in milliseconds. The timestamp of the request must be within 30 seconds of the API service time, otherwise the request will be considered expired and rejected. If there is a large deviation between local server time and API server time, we recommend that you update the HTTP header by querying API server time.

Limited frequency rules

The system automatically limits requests if they are too frequent, and returns the 429 Too many Requests status code in the HTTP header.

The request format

There are currently only two format request methods: GET and POST

Contract Trading interface

Gets the server time

Rate Limit:20 requests per 2 seconds

HTTP Request Time to return to server

Response:

{
    "epoch":"1591099099.896",
    "iso":"2020-06-02T11:58:19.896Z",
    "timestamp":1591099099896
}

Response

Parameters Description
epoch Unix timestamp in seconds
iso ISO8601 standard time format
timestamp Unix timestamp in milliseconds

Contract Information

Rate Limit:20 requests per 2 seconds

HTTP Requests Get market data.

Response:

[
  {
    "symbol":"cmt_btcusdt",   //Contract name
    "coin":"USDT",     // Margin currency
    "contract_val":"0.0001",   //Contract value 
    "delivery":[   // Settlement time
         "07:00:00",
         "15:00:00",
         "23:00:00"
     ], 
    "forwardContractFlag":true,   // (true or false) , forward contract or not
    "priceEndStep":5,    //Prices' Last Digit in Cents
    "quote_currency":"USDT",   //Denominated currency
    "size_increment":"0",    //Quantity accuracy
    "tick_size":"1",    //Price accuracy  
    "underlying_index":"BTC"   //Contract currency
    "minLeverage":1 // minimum  leverage
    "maxLeverage":100 //maximum leverage
  }
]

Response

Parameters Description
symbol Contract name
coin Margin currency
contract_val Contract value
delivery Settlement time
forwardContractFlag (true or false) , forward contract or not
priceEndStep Prices' Last Digit in Cents
quote_currency Denominated currency
size_increment Quantity accuracy
tick_size Price accuracy
underlying_index Contract currency
minLeverage minimum leverage
maxLeverage maximum leverage

Get depth data

Rate Limit:20 requests per 2 seconds

HTTP Requests Get depth data

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
'limit' Integer Yes Number of results per request

Response:

{
   "asks":[
         [
            "8858.0",   //price
            "19299",   //amount
              2.0     //Obsolete field
        ]   
     ],
   "bids":[
         [
            "7466.0",   //price
            "499",     //amount
             1.0       //Obsolete field
        ],
         [
            "4995.0",
            "12500",
              2.0
        ]
     ],
   "timestamp":"1591237821479" 
}

Response

Parameters Description
asks Sell side depth
bids Buy side depth
timestamp Timestamp

get all ticker information

Rate Limit:20 requests per 2 seconds

HTTP Requests get all ticker information

Response:


[
    {
        "symbol":"cmt_bchusdt",    //Contract name 
        "best_ask":"332.00",      //Best ask price 
        "best_bid":"203.00",      //Best bid price
        "high_24h":"394",        //Highest price in the past 24 hours 
        "last":"332",           //Last traded price 
        "low_24h":"332",        //Lowest price in the past 24 hours 
        "timestamp":"1591240033936",  //System timestamp
        "volume_24h":"0",    //Trading volume of past 24 hours
        "priceChangePercent": "-0.63"  //24-hour price change percentage
 }
]

Response

Parameters Description
symbol Contract name
best_ask Best ask price
best_bid best bid price
high_24h Highest price in the past 24 hours
last Last traded price
low_24h Lowest price in the past 24 hours
timestamp System timestamp
volume_24h Trading volume of past 24 hours
priceChangePercent 24-hour price change percentage

get one ticker information

Rate Limit:20 requests per 2 seconds

HTTP Requests get one ticker information

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
    "symbol":"cmt_btcusdt",   //Contract name 
    "best_ask":"8858.0",     //Best ask price
    "best_bid":"7466.0",    //Best bid price   
    "high_24h":"8858",     //Highest price in the past 24 hours
    "last":"8858",        //Last traded price  
    "low_24h":"8858",    //Lowest price in the past 24 hours
    "timestamp":"1591252726275",  //System Timestamp
    "volume_24h":"0",   //Trading volume of past 24 hours
    "priceChangePercent": "-0.63"  //24-hour price change percentage
}

Response

Parameters Description
symbol Contract name
best_ask Best ask price
best_bid Best bid price
high_24h Highest price in the past 24 hours
last Last traded price
low_24h Lowest price in the past 24 hours
timestamp System Timestamp
volume_24h Trading volume of past 24 hours
priceChangePercent 24-hour price change percentage

Filled Orders

Rate Limit:20 requests per 2 seconds

HTTP Requests

Filled Orders

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
'limit' String Yes Number of results per request

Response:

[
  {
      "symbol":"cmt_btcusdt",    //Contract name
      "price":"7844.00",        //Deal price
      "side":"buy",            //Transaction direction: sell, buy
      "size":"48",            //The number of transactions
      "timestamp":"1591111746879",    //Transaction timestamp
      "trade_id":"651735392382353615"   //Transaction id
 }
]

Response

Parameters Description
symbol Contract name
price Deal price
side Transaction direction: sell, buy
size The number of transactions
timestamp Transaction timestamp
trade_id Transaction id

Market Data

Rate Limit:20 requests per 2 seconds

HTTP Requests Retrieve the candlestick charts of the trading pairs.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
start String Yes Start time,in ISO 8601 format; Mark obsolete
end String Yes End time,in ISO 8601 format; Mark obsolete
startTime Long Yes Start time (time stamp)
endTime Long Yes End time (time stamp)
granularity String Yes Bar size in seconds, default 60, must be one of [60/180/300/900/1800/3600/7200/14400/21600/43200/86400/604800] or returns error

Response:

[
    "1556687460000",    //System timestamp
    "5315.5",          //Open price
    "5315.5",         //Higest price
    "5315.5",        //Lowest price
    "5315.5",       //Closing price
    "342",         //Transaction volume (converted by Zhang)
    "0.064340137494"   //Transaction volume (converted by currency)
]

Response

Parameters Description
timestamp System timestamp
open Open price
high Higest price
low Lowest price
close Closing price
volume Transaction volume (converted by Zhang)
currency_volume Transaction volume (converted by currency)

Indices

Rate Limit:20 requests per 2 seconds

HTTP Requests Retrieve indices of tokens. This is publicly accessible without account authentication.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
    "symbol":"cmt_btcusdt",   //Contract name
    "index":"9654.1",        //Index price
    "timestamp":"1591256590003"  //System Timestamp
}

Response

Parameters Description
symbol Contract name
index Index price
timestamp System Timestamp

Open Interests

Rate Limit:20 requests per 2 seconds

HTTP Requests Retrieve the total open interest of a contract on Bitget. This is publicly accessible without account authentication.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
    "symbol": "cmt_btcusdt",//Contract  name
    "amount": "4097696",//Total holdings
    "base_volume": "4097.696",//Total holdings,left coin vol
    "target_volume": "47124323.5392",//Total holdings,right coin vol
    "timestamp": "1603109860796",// System Timestamp
    "forwardContractFlag": true //Is it a forward contract
}

Response

Parameters Description
symbol Contract name
amount Total holdings
forwardContractFlag Is it a forward contract
timestamp System Timestamp
base_volume Total holdings,left coin vol
target_volume Total holdings,right coin vol

Current Price Limits

Rate Limit:20 requests per 2 seconds

HTTP Requests Retrieve the ceiling of the buy price and floor of sell price of the contract. This is publicly accessible without account authentication.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
     "symbol":"cmt_btcusdt",    //Contract name
     "forwardContractFlag":true,  //Is it a forward contract
     "highest":"14474.5",        //Ceiling of buying price
     "lowest":"4824.5",         //Floor of selling price
     "timestamp":"1591257126461"   //System Timestamp
 }

Response

Parameters Description
symbol Contract name
forwardContractFlag Is it a forward contract
highest Ceiling of buying price
lowest Floor of selling price
timestamp System Timestamp

Next Settlement Time

Rate Limit:20 requests per 2 seconds

HTTP Requests Get the time of next settlement.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

 {
     "symbol":"cmt_btcusdt",     //Contract name
     "forwardContractFlag":false,     //Is it a forward contract
     "funding_time":"1591282800000"  //time of current funding
 }

Response

Parameters Description
symbol Contract name
forwardContractFlag Is it a forward contract
funding_time time of current funding

Funding Rate History

Rate Limit:20 requests per 2 seconds

HTTP Requests Get Funding Rate History

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
pageIndex String Yes Page number, empty default first page, starting from 1
pageSize String Yes Number of data per page

Response:

 {
     "symbol":"cmt_btcusdt",       //Contract name
     "funding_rate":"0.001",      //current funding rate
     "funding_time":"19238271212"    //Settlement time
 }

Response

Parameters Description
symbol Contract name
funding_rate current funding rate
funding_time Settlement time

Mark Price

Rate Limit:20 requests per 2 seconds

HTTP Requests Get the tag price. This is a public endpoint, no identity verification is needed.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

 {
     "symbol":"cmt_btcusdt",       //Contract name
     "mark_price":"8047.87",      //Specify the margin price
     "timestamp":"1591264230941"   //System Timestamp
 }

Response

Parameters Description
symbol Contract name
mark_price Specify the margin price
timestamp System Timestamp

Gets the openable number

Rate Limit:20 requests per 2 seconds

HTTP Requests Gets the openable number

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
amount BigDecimal Yes The total amount of the opening
openPrice BigDecimal Yes Open price
leverage BigDecimal No The default leverage is 20 times

Response:

{
   "openCount":"199999"     //Number of openings
 }

Response

Parameters Description
openCount Number of openings

Contract account interface

all contract account information

Rate Limit:1 requests per 1 seconds

HTTP Requests Retrieve information from all tokens in the perpetual swap account

Response:

[ 
  {
   "symbol":"cmt_btcusdt",      //Contract name
   "equity":"0.00000000",      //Equity of the account
   "fixed_balance":"0.00000000",      //Obsolete field
   "total_avail_balance":"0.00000000",   //Available Balance
   "margin":"0",                        //Used margin
   "realized_pnl":"0",                 //Realized profits and losses
   "unrealized_pnl":"0",              //Unrealized profits and losses
   "longMarginRatio":"0",            //Margin rate for multiple positions
   "shortMarginRatio": "0",         //Margin rate for short positions
   "marginRatio": "0",             //Whole position margin rate
   "margin_frozen":"0",              //Freeze margin for opening positions
   "timestamp":"1658098718494",     //Creation time
   "margin_mode":"fixed",          //Margin Mode: crossed / fixed
   "forwardContractFlag":true     //Is it a forward contract
 }
]

Response

Parameters Description
symbol Contract name
equity Equity of the account
fixed_balance Available balance by warehouse
total_avail_balance Available Balance
margin Used margin
realized_pnl Realized profits and losses
unrealized_pnl Unrealized profits and losses
longMarginRatio Margin rate for multiple positions
shortMarginRatio Margin rate for short positions
marginRatio Whole position margin rate
margin_frozen Freeze margin for opening positions
timestamp Creation time
margin_mode Margin Mode: crossed / fixed
forwardContractFlag Is it a forward contract

Perpetual Swap Account of a Currency

Rate Limit:5 requests per second

HTTP Requests Retrieve the perpetual swap account information of a single trading pair.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
     "symbol":"cmt_btcusdt",      //Contract name
     "equity":"0.00000000",      //Equity of the account
     "fixed_balance":"0.00000000",      //Obsolete field
     "total_avail_balance":"0.00000000",   //Available Balance
     "margin":"0",                        //Used margin
     "realized_pnl":"0",                 //Realized profits and losses
     "unrealized_pnl":"0",              //Unrealized profits and losses
     "longMarginRatio":"0",            //Margin rate for multiple positions
     "shortMarginRatio": "0",         //Margin rate for short positions
     "marginRatio": "0",             //Whole position margin rate
     "margin_frozen":"0",              //Freeze margin for opening positions
     "timestamp":"1658098718494",     //Creation time
     "margin_mode":"fixed",          //Margin Mode: crossed / fixed
     "forwardContractFlag":true     //Is it a forward contract
 }

Response

Parameters Description
symbol Contract name
equity Equity of the account
fixed_balance Available balance by warehouse
total_avail_balance Available Balance
margin Used margin
realized_pnl Realized profits and losses
unrealized_pnl Unrealized profits and losses
longMarginRatio Margin rate for multiple positions
shortMarginRatio Margin rate for short positions
marginRatio Whole position margin rate
margin_frozen Freeze margin for opening positions
timestamp Creation time
margin_mode Margin Mode: crossed / fixed
forwardContractFlag Is it a forward contract

Get Swap Leverage

Rate Limit:5 requests per second

HTTP Requests Retrieve the leverage ratio and margin mode of a perpetual swap.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

 {
   "symbol":"cmt_btcusdt",        //Contract name
   "long_leverage":"100",        //Leverage level for long positions
   "margin_mode":"fixed",       //Margin Mode: crossed / fixed
   "short_leverage":"2",       //Leverage level for short positions
   "forwardContractFlag":true     //Is it a forward contract
 }

Response

Parameters Description
symbol Contract name
long_leverage Leverage level for long positions
margin_mode Margin Mode: crossed / fixed
short_leverage Leverage level for short positions
forwardContractFlag Is it a forward contract

Set Swap Leverage

Rate Limit:5 requests per second

HTTP Requests 调整杠杆

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
leverage Integer Yes New leverage level from 1-100
side Integer Yes Position direction (1-long position, 2-short position) Mark obsolete
holdSide Integer Yes Position direction (1-long position, 2-short position) crossed mode the holdSide field does not need to be passed

Response:

{
   "symbol":"cmt_btcusdt",           //Contract name
   "long_leverage":"100",           //Leverage level for long positions
   "margin_mode":"fixed",          //Margin mode: crossed / fixed
   "short_leverage":"2",          //Leverage level for short positions
   "forwardContractFlag":true    //Is it a forward contract
 }

Response

Parameters Description
symbol Contract name
long_leverage Leverage level for long positions
margin_mode Margin mode: crossed / fixed
short_leverage Leverage level for short positions
forwardContractFlag Is it a forward contract

Adjust margin

Rate Limit:20 requests per 2 seconds

HTTP Requests adjust margin

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
amount String Yes adjust amount
positionType Integer Yes Direction 0 Long 1 Short
type Integer Yes Type 1 Increase 2 Reduce

Response:

 {
    "result":true,      //result
    "orderNo":"527252921197264814"   //Order ID
 }

Response

Parameters Description
result Result
orderNo Order ID

Auto Margin Replenishment (AMR)

Rate Limit:5 requests per second

HTTP Requests Auto Margin Replenishment (AMR)

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
side Integer Yes Position direction 1 Long 2 Short Mark obsolete
holdSide Integer Yes Position direction 1 Long 2 Short
append_type Integer Yes Adjust margin type 0 Manually 1 Automatic

Response:

 {
     "result":true,       //Setting result
     "append_type":1     //Current setting: 0 Manually 1 Automatic
 }

Response

Parameters Description
result Setting result
append_type Current setting: 0 Manually 1 Automatic

Get all contract position information

Rate Limit:5 requests per second

HTTP Requests get all contract position information

Response:

 [
 {
    "margin_mode":"fixed",       //Margin mode: crossed / fixed
    "holding":[
           {
              "symbol":"cmt_btcusdt",      //Contract name
              "liquidation_price":"0.00",    //Estimated liquidation price
              "position":"0",               //Position Margi(the margin for holding current positions)
              "avail_position":"0",        //Available position
              "avg_cost":"0.00",          //Transaction average price
              "leverage":"2",            //Leverage
              "realized_pnl":"0.00000000",      //Realized Profit and loss
              "keepMarginRate":"0.005",        //Maintenance margin rate
              "side":"1",                      // Position Direction Long or short     Mark obsolete
              "holdSide":"1",                      //Position Direction Long or short
              "timestamp":"1557571623963",    //System timestamp
              "margin":"0.0000000000000000"  //Used margin
              "unrealized_pnl":"0.00000000" //Unrealized profit and loss
       }
     ]
 }
]

Response

Parameters Description
symbol Contract name
margin_mode Margin mode: crossed / fixed
liquidation_price Estimated liquidation price
position Position Margi(the margin for holding current positions)
avail_position Available position
avg_cost Transaction average price
leverage Leverage
realized_pnl Realized Profit and loss
keepMarginRate Maintenance margin rate
side Direction Long or short
holdSide Position Direction Long or short
timestamp System timestamp
margin Used margin
unrealized_pnl Unrealized profit and loss

Get one of the Margin mode information

Rate Limit:10 requests per second

HTTP Requests Retrieve information on your positions of a single contract.

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

{
    "margin_mode":"fixed",       //Margin mode: crossed / fixed
    "holding":[
           {
              "symbol":"cmt_btcusdt",       //Contract name
              "liquidation_price":"0.00",  //Estimated liquidation price
              "position":"0",             //Position Margi(the margin for holding current positions)
              "avail_position":"0",      //Available position
              "avg_cost":"0.00",        //Transaction average price
              "leverage":"2",          //Leverage
              "realized_pnl":"0.00000000",    //Realized Profit and loss
              "keepMarginRate":"0.005",      //Maintenance margin rate
              "side":"1",                    //Position Direction Long or short     Mark obsolete
              "holdSide":"1",                    //Position Direction Long or short
              "timestamp":"1557571623963",  // System timestamp
              "margin":"0.0000000000000000"   //Used margin
              "unrealized_pnl":"0.00000000" //Unrealized profit and loss
       }
     ]
 }

Response

Parameters Description
symbol Contract name
margin_mode Margin mode: crossed / fixed
liquidation_price Estimated liquidation price
position Position Margi(the margin for holding current positions)
avail_position Available position
avg_cost Transaction average price
leverage Leverage
realized_pnl Realized Profit and loss
keepMarginRate Maintenance margin rate
side Direction: Long or short
timestamp System timestamp
margin Used margin
unrealized_pnl Unrealized profit and loss

Modify the user's account mode

Rate Limit:20 requests per second

HTTP Requests Modify the user's account mode

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
holdModel Integer Yes account mode (1 position by position 2 full position)

Response:

 {
    "symbol":"cmt_btcusdt",     //Contract name
    "resultHoldMode":1,        //Return to the account mode 1 position by position 2 full position
    "switchSuccess":true      //Whether the modification is successful true success false failure
}

Response

Parameters Description
symbol Contract name
resultHoldMode Return to the account mode 1 position by position 2 full position
switchSuccess Whether the modification is successful true success false failure

Contract trading endpoints

Place order

Rate Limit:10 requests per second

HTTP Requests Place order

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
client_oid String Yes Custom order number (not more than 40 characters, and cannot be special characters, such as Martian characters, etc.), can not be repeated in the pending order. If vacant, the system will automatically assign value
size String Yes Quantity to buy or sell (value not equal to 0 or negative)
type String Yes 1 Open long 2Open short 3 Close long 4 Close short
order_type String Yes 0: Normal order (Unfilled and 0 imply normal limit order) 1: Post only 2: Fill or Kill 3: Immediate Or Cancel
match_price String Yes 0 Limit price 1 market price
price String No Price of each contract
presetTakeProfitPrice BigDecimal No Preset take profit price
presetStopLossPrice BigDecimal No Preset stop price

Response:

{
    "client_oid":"bitget#123456",      //Client  ID 
    "order_id":"513466539039522813"   //Order ID 
}

Response

Parameters Description
client_oid Client ID 
order_id Order ID 

Batch order

Rate Limit:10 requests per second

HTTP Requests batch order

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
orderDataList List Yes Object attributes, e.g (price=5,size=2,type=1,match_price=1,order_type=1,client_oid="abc"),The fields refer to the [Contract trading] endpoints, and can only process up to 20 orders in batch

Response:

{
    "result":true,  
    "order_info":[
        {
            "result":true,         //Result of an Order
            "client_oid":"dxdanzi",     //Client  ID
            "order_id":"513468410013679613"   //Order ID
        },
        {
            "result":true,
            "client_oid":"dxdanzi",
            "order_id":"513468410001096713"
        }
    ]
}

Response

Parameters Description
result Result of an Order
client_oid Client ID
order_id Order ID

Cancel order

Rate Limit:10 requests per second

HTTP Requests Cancel order

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
orderId String Yes order id

Response:

{
   "symbol":"cmt_btcusdt",          //Contract name
   "order_id":"513468410013679613",   //Order ID
   "client_oid":"bitget#123456",     //Client ID
   "result":true                    //Cancellation status
}

Response

Parameters Description
symbol Contract name
order_id Order ID
client_oid Client ID
result Cancellation status

Cancel orders in batch

Rate Limit:10 requests per seconds

HTTP Requests request to cancel order in batch

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
ids List Yes Order ID combination

Response:

{
   "symbol":"cmt_btcusdt",      //Contract name
   "result":true,              //processing result
   "order_ids":[
          "258414711",   //Successful id
          "478585558"
    ],
   "fail_infos":[
          {
        "order_id":"258414711",   //Failed id
        "err_code":"401",        //Error code
        "err_msg":""            //Error message
     }
  ]
}

Response

Parameters Description
symbol Contract name
result processing result
order_ids Orders
order_id Order ID
err_code Error code
err_msg Error message

Get the Order Details of an Order

Rate Limit:10 requests per second

HTTP Requests get the order details of an order

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
orderId String Yes Order ID

Response:

{
     "symbol":"cmt_btcusdt",    //Contract name
     "size":"12",              //The amount in this order
     "timestamp":"15582271175271",     //Obsolete field
     "client_oid":"cmdtde",           //Client ID
     "createTime":"1698475585258",   //Creation time
     "filled_qty":"0",              //The amount which has been filled
     "fee":"0",                    //Transaction fee
     "order_id":"513468410013679613",    //Order ID
     "price":"12",                      //The limit price of limit order 
     "price_avg":"0",                  //Average filled price
     "status":"-1",                   //Order status
     "type":"1",                     //Commission type
     "order_type":"0",              //Order type
     "totalProfits":"253"          //Total profit and loss          
}

Response

Parameters Description
symbol Contract name
size The amount in this order
timestamp System time
client_oid Client ID
createTime Creation time
filled_qty The amount which has been filled
fee Transaction fee
order_id Order ID
price The limit price of limit order
price_avg Average filled price
status Order status -1 Cancelled successful 0 submitted 1partial-filled 2filled
type Commission type, 1,Open long 2 Open short 3 Close long 4 Close short 5 Buy limit 6Sell limit 7.Long close agreement 8. Short close agreement 9. Forced liquidity long 10 Forced liquidity short
order_type Order Type 0. Normal limit order 1. Only be Maker (Post only)"2 Fill or Kill (FOK) 3. Immediate or Cancel (IOC)
totalProfits Total profit and loss

Get order history commission

Rate Limit:10 requests per second

HTTP Requests Get order history commission

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
pageIndex String Yes Page number, empty default first page, starting from 1
pageSize String Yes Number of data per page
createDate Integer Yes Number of days (the number of days must be less than or equal to 90, cannot be a negative number)

Response:

[
   {
          "symbol":"cmt_btcusdt",    //Contract name
          "size":"12",              //The amount in this order
          "client_oid":"cmdtde",           //Client ID
          "createTime":"1698475585258",   //Creation time
          "filled_qty":"0",              //The amount which has been filled
          "fee":"0",                    //Transaction fee
          "order_id":"513468410013679613",    //Order ID
          "price":"12",                      //The limit price of limit order 
          "price_avg":"0",                  //Average filled price
          "status":"-1",                   //Order status
          "type":"1",                     //Commission type
          "order_type":"0",              //Order type
          "totalProfits":"253"          //Total profit and loss    
 }
]

Response

Parameters Description
symbol Contract name
size The amount in this order
client_oid Client ID
createTime Creation time
filled_qty The amount which has been filled
fee Transaction fee
order_id Order ID
price The limit price of limit order
price_avg Average filled price
status Order status -1 Cancelled successful 0 submitted 1partial-filled 2filled
type Commission type, 1,Open long 2 Open short 3 Close long 4 Close short 5 Buy limit 6Sell limit 7.Long close agreement 8. Short close agreement 9. Forced liquidity long 10 Forced liquidity short
order_type Order Type 0. Normal limit order 1. Only be Maker (Post only)"2 Fill or Kill (FOK) 3. Immediate or Cancel (IOC)
totalProfits Total profit and loss

Get the current order of the order

Rate Limit:10 requests per second

HTTP Requests Get the current order of the order

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name

Response:

[
   {
          "symbol":"cmt_btcusdt",    //Contract name
          "size":"12",              //The amount in this order
          "client_oid":"cmdtde",           //Client ID
          "createTime":"1698475585258",   //Creation time
          "filled_qty":"0",              //The amount which has been filled
          "fee":"0",                    //Transaction fee
          "order_id":"513468410013679613",    //Order ID
          "price":"12",                      //The limit price of limit order 
          "price_avg":"0",                  //Average filled price
          "status":"-1",                   //Order status
          "type":"1",                     //Commission type
          "order_type":"0",              //Order type
          "totalProfits":"253"          //Total profit and loss    
 }
]

Response

Parameters Description
symbol Contract name
size The amount in this order
client_oid Client ID
createTime Creation time
filled_qty The amount which has been filled
fee Transaction fee
order_id Order ID
price The limit price of limit order
price_avg Average filled price
status Order status -1 Cancelled successful 0 submitted 1partial-filled 2filled
type Commission type, 1,Open long 2 Open short 3 Close long 4 Close short 5 Buy limit 6Sell limit 7.Long close agreement 8. Short close agreement 9. Forced liquidity long 10 Forced liquidity short
order_type Order Type 0. Normal limit order 1. Only be Maker (Post only)"2 Fill or Kill (FOK) 3. Immediate or Cancel (IOC)
totalProfits Total profit and loss

Get Transaction Details

Rate Limit:10 requests per second

HTTP Requests get transaction details

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
orderId String Yes Order ID

Response:

[
  {
      "symbol":"cmt_btcusdt",    //Contract name
      "trade_id":"6667390",     //trade Id
      "order_id":"525946425993854915",   //order id
      "price":"9839.00",      //deal price
      "order_qty":"3466",    //Quantity
      "fee":"-0.0000528407360000",    //transaction fee
      "timestamp":"1561121514442",   //Creation time
      "exec_type":"M",              //Liquidity direction   Taker or maker (T or M)
      "side":"3",                 //Commission type    Mark obsolete
      "delegateType":"3"          //Commission type
}
]

Response

Parameters Description
symbol Contract name
trade_id trade Id
order_id order id
price deal price
order_qty Quantity
fee transaction fee
timestamp Creation time
exec_type Liquidity direction Taker or maker (T or M)
side Side of the order 1,Open long 2 Open short 3 Close long 4 Close short 5 Buy limit 6Sell limit 7.Long close agreement 8. Short close agreement 9. Forced liquidity long 10 Forced liquidity short

Place order with Stop limit

Rate Limit:10 requests per second

HTTP Requests place order with Stop limit

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
client_oid String Yes Custom order number (not more than 40 characters, and cannot be special characters, such as Martian characters, etc.), can not be repeated in the pending order. If vacant, the system will automatically assign value
size String Yes Quantity to buy or sell (value not equal to 0 or negative)
type String Yes Type 1 Open position 2 Close position
side String Yes Position Direction 1 Long 2 Short Mark obsolete
holdSide String Yes Position Direction 1 Long 2 Short
match_type String Yes Order Type 0 Limit 1 Market
execute_price String Yes Stop price (execute price)
trigger_price String Yes Limit price (trigger price)

Response:

{
      "client_oid":"bitget#123456",       //Client ID
      "order_id":"589579827556646928"    //plan Order ID 
}

Response

Parameters Description
client_oid Client ID
order_id plan Order ID

Close position with Stop limit

Rate Limit:10 requests per second

HTTP Requests close position with Stop limit

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
orderId String Yes Order ID

Response:

 {
     "order_id":"5895798275566469458",      //Order ID
     "client_oid":"bitget#123456",         //Client ID
     "result":false,                      //Status of cancellation
     "err_code":"403",                   //code of cancellation 
     "err_msg":"order not exist"        //reason of cancellation
}

Response

Parameters Description
order_id Order ID
client_oid Client ID
result Status of cancellation
err_code code of cancellation
err_msg reason of cancellation

Check Stop limit status

Rate Limit:10 requests per second

HTTP Requests check stop limit status

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
side String Yes Commission type 1 Open long 2 Open short 3 Close long 4 Close short Mark obsolete
delegateType String Yes Commission type 1 Open long 2 Open short 3 Close long 4 Close short
pageIndex String Yes Current page (1-200)
pageSize String Yes Number per page(1-100)
startTime String No Query start time
endTime String No Query stop time

Response:

{
      "list":[
              {
                 "symbol":"cmt_btcusdt",     //Contract name
                 "execute_count":"0",       //amount of Stop
                 "delegate_count":"1222222",     //amount of Limit
                 "create_time":1576294708136,   //Created time
                 "update_time":1576294708136,  //Updated time
                 "direction":1,               //Direction
                 "direction_desc":"开多",     //Description of direction
                 "trigger_price":"22222210.0",       //Stop price 
                 "execute_price":"7490.0",          //limit price (execute price) 
                 "order_id":"589588227514433528",  //Order ID
                 "order_type":0,                  //Order Type
                 "status":1,                     //status
                 "status_desc":"status",        //Description of status
                 "create_trade_price":"7490"   //Executed price of stop limit
           }
         ],
    "nextPage":false   //Next page 
}

Response

Parameters Description
symbol Contract name
nextPage Next page
execute_count amount of Stop
delegate_count amount of Limit
create_time Created time
update_time Updated time
direction Direction 1.Open long 2.Open short 3 Close long 4 Close short
direction_desc Description of direction 1.Open long 2.Open short 3 Close long 4 Close short
trigger_price Stop price
execute_price limit price (execute price)
order_id Order ID
order_type Order Type 0 Limit 1 Market
status status 1: waiting to order 2: order placing 3: failed status 4 under cancellation
status_desc Description of status 1: waiting to order 2: order placing 3: failed status 4 under cancellation
create_trade_price Executed price of stop limit

Get the history of Stop limit

Rate Limit:10 requests per second

HTTP Requests Get the history of Stop limit

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
side String Yes Commission type 1 Open long 2 Open short 3 Close long 4 Close short Mark obsolete
delegateType String Yes Commission type 1 Open long 2 Open short 3 Close long 4 Close short
pageIndex String Yes current page(1-200)
pageSize String Yes Number per page(1-100)
startTime String No Query start time
endTime String No Query end time

Response:

{
        "list":[
                    {
                       "symbol":"cmt_btcusdt",     //Contract name
                       "execute_count":"0",       //amount of Stop
                       "delegate_count":"1222222",     //amount of Limit
                       "create_time":1576294708136,   //Created time
                       "update_time":1576294708136,  //Updated time
                       "direction":1,               //Direction
                       "direction_desc":"开多",     //Description of direction
                       "trigger_price":"22222210.0",       //Stop price 
                       "execute_price":"7490.0",          //limit price (execute price) 
                       "order_id":"589588227514433528",  //Order ID
                       "order_type":0,                  //Order Type
                       "status":1,                     //status
                       "status_desc":"status",        //Description of status
                       "create_trade_price":"7490"   //Executed price of stop limit
                 }
               ],
          "nextPage":false   //Next page 
}

Response

Parameters Description
symbol Contract name
nextPage Next page
execute_count amount of limit
delegate_count amount of stop
create_time Creation time
update_time Update time
direction Direction 1.Open long 2.Open short 3 Close long 4 Close short
direction_desc Description of direction 1.Open long 2.Open short 3 Close long 4 Close short
trigger_price trigger price
execute_price execute price
order_id Order ID
order_type Order Type 0 Limit 1 Market
status status 1: waiting to order 2: order placing 3: failed status 4 under cancellation
status_desc description of 1: waiting to order 2: order placing 3: failed status 4 under cancellation
create_trade_price Executed price of stop limit

Copy trading interface

Place an order to close a warehouse

Rate Limit:1 requests per second

HTTP Requests

Place an order to close a warehouse

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
trackingNo Long Yes Tracking order number

Response:

{
     "trackingNo":6258224712558517, //Document number
     "result":true                 //Copy result
}

Get the current list

Rate Limit:20 requests per second

HTTP Requests

Get the current list

Request Parameter

Parameters Type Required Description
symbol String Yes Contract name
pageIndex String Yes Page number, empty default first page, starting from 1
pageSize String Yes Number per page (1-100 integer)

Response:

[
  {

     "symbol":"cmt_btcusdt", //Contract name
     "orderNo":"699848017573842632",  //order number
     "holdSide":1, //Position direction  1 Long position 2 Short position
     "openLeverage":20,   //Opening leverage
     "averageOpenPrice":11451.50000,  //Average opening price
     "openTime":1602582690614,  //Opening time
     "openDealCount":"10",    //Number of positions (number of transactions opened)
     "stopProfitPrice":"123.14",    //Take Profit Price
     "stopLossPrice":"20.52"     //Stop price
 }
]

Get a list of historical tapes

Rate Limit:20 requests per second

HTTP Requests Get a list of historical tapes

Request Parameter

Parameters Type Required Description
pageIndex String Yes Page number, empty default first page, starting from 1
pageSize String Yes Number per page (1-100 integer)
createDate Integer Yes The number of days to query forward from the current time (the number of days must be less than or equal to 90, cannot be a negative number)

Response:

{
     "symbol":"cmt_btcusdt", //Contract name
     "orderNo": "682799071840175632",  //order number
     "holdSide":1,             //Position direction  1 Long position 0 Short position
     "openLevel": 20,        //Opening leverage
     "openAvgPrice" :"11366.50",     //Average opening price
     "openTime": 1598517905197,    //Opening time
     "closeDealCount": "10",           //Number of closed trades
     "closeTime":1599135145368,          //Position closing trigger time
     "closeAvgPrice": "11272.00",        //Average closing price
     "stopType": "1",                   //0 common 1 stop profit 2 stop loss (closed position type)
     "achievedProfits": "-0.07650000", //Realized profit and loss
     "openFee": "-0.00680910",  // Cumulative fees for opening positions
     "closeFee": "0.000000"    //Cumulative handling fee for liquidation
}

RestAPI error code

## Public error code

Error message error code http status code
ACCESS_KEY header is required 40001 400
ACCESS_SIGN header is required 40002 400
ACCESS_TIMESTAMP header is required 40003 400
Invalid ACCESS_TIMESTAMP 40005 400
Invalid ACCESS_KEY 40006 400
Invalid Content_Type, please use the application/json format 40007 400
Request timestamp expired 40008 400
API authentication failed 40009 400
Request too frequently 429 429
ACCESS_PASSPHRASE header is required 40011 400
apikey/passphrase is incorrect 40012 400
User is frozen 40013 400
Incorrect permissions 40014 400
System error 40015 400
The user must bind a mobile phone or Google 40016 400
Parameter verification failed 40017 400
Illegal ip request 40018 400

Contract error code

Error message error code http status code
The contract configuration does not exist, please check the parameters 40102 400
Can't find the order data, please confirm the order number 40109 400
Server upgrade, please try again later 40200 400
No permission to use it yet, if you need to use it, please contact customer service 40301 400
Can only query up to 20,000 data 40303 400
client_oid length is not greater than 40, and cannot be Martian characters 40305 400
Batch processing orders can only process up to 50 40306 400
The contract is temporarily maintained 40308 400
The contract has been removed 40309 400
Status check abnormal 40400 400
The operation cannot be performed 40401 400
The query direction is not the direction of the plan commission 40407 400
Range error 40408 400
wrong format 40409 400
Only check the data of the last three months 40704 400
The start and end time cannot exceed 90 days 40705 400
Start time is greater than end time 40707 400
There is no position in this position, and automatic margin call cannot be set 40709 400
Abnormal account status 40710 400
Insufficient contract account balance 40711 400
Insufficient margin 40712 400
Cannot exceed the maximum transferable margin amount 40713 400
The position is zero and direct margin call is not allowed 40714 400
The number of orders is greater than the maximum number that can be opened 40715 400
The trading pair does not support full position mode 40716 400
The number of closed positions cannot exceed the number of holdings 40717 400
The commission price for closing long positions is not allowed to be lower than the liquidation price 40718 400
The short order price is not allowed to be higher than the liquidation price 40719 400
Contract opponent depth does not exist 40720 400
Currently not allowed to list market orders 40721 400
Due to excessive price fluctuations and insufficient market price commission costs, the position opening commission failed 40722 400
The total number of unfilled orders is too high 40723 400
Parameter is empty 40724 400
contract service return an error 40725 400
Full position mode does not support automatic margin call 40726 400
Whole position mode does not support margin adjustment 40727 400
You are currently a trader, please close the position under the current order 40728 400
Failed to adjust the position, the current position or order or plan order 40729 400
There is currently a commission or a planned commission, and the leverage cannot be adjusted 40730 400
This product does not support copy trading 40731 400
Not currently a trader 40732 400
The order closing has been processed 40733 400
Failed to place an order, the minimum number of trader open positions %s 40734 400
Long position take profit price should be greater than the average opening price 40735 400
Long position take profit price is greater than the current price 40736 400
The short position take profit price should be less than the average opening price 40737 400
The short position take profit price should be less than the current price 40738 400
The stop loss price of a long position should be less than the average opening price 40739 400
The stop loss price of a long position should be less than the current price 40740 400
The stop loss price of a short position should be greater than the average opening price 40741 400
The stop loss price of the short position should be greater than the current price 40742 400
The order is being closed and cannot be closed again 40743 400
The tracking order status is wrong 40744 400
This order is being commissioned, and liquidation is not supported temporarily 40745 400
At present, the maximum number of positions that can be closed is %s. For the excess number, please go to the current order to close the position
40746 400
The bonus is not allowed to hold two-way positions 40747 400
The commission price is higher than the highest bid price 40748 400
The commission price is lower than the lowest selling price 40749 400
The plan commission for this contract has reached the upper limit 40750 400
The contract's stop profit and stop loss order has reached the upper limit 40751 400