### Get ACCESS-TIMESTAMP Source: https://www.bitget.com/api-doc/classic/quickStart/intro Examples for generating the required millisecond-precision timestamp across different programming languages. ```Java Long timestamp = System.currentTimeMillis(); ``` ```Python import time time.time_ns() / 1000000 ``` ```Go import ( "time" ) int64(time.Now().UnixNano()/1000000) ``` ```JS Math.round(new Date()) ``` ```PHP microtime(true) * 1000; ``` -------------------------------- ### Subscribe Response Example Source: https://www.bitget.com/api-doc/classic/quickStart/websocket-intro Example of a successful subscription confirmation message received from the server. ```json { "event": "subscribe", "arg": { "instType":"SPOT", "channel":"ticker", "instId":"BTCUSDT" } } ``` -------------------------------- ### Login Request Example Source: https://www.bitget.com/api-doc/classic/quickStart/websocket-intro An example of a complete login request payload, demonstrating the structure and expected values for authentication parameters. ```json { "op":"login", "args":[ { "apiKey":"xx_xxx", "passphrase":"xxx", "timestamp":"1538054050", "sign":"8RCOqCJAhhEh4PWcZB/96QojLDqMAg4qNynIixFzS3E=" } ] } ``` -------------------------------- ### Unsubscribe Response Example Source: https://www.bitget.com/api-doc/classic/quickStart/websocket-intro Example of a confirmation message received after successfully unsubscribing from channels. ```json { "op":"unsubscribe", "args":[ { "instType":"USDT-FUTURES", "channel":"ticker", "instId":"BTCUSDT" }, { "instType":"USDT-FUTURES", "channel":"candle1m", "instId":"BTCUSDT" } ] } ``` -------------------------------- ### Query Announcements Request Example Source: https://www.bitget.com/api-doc/classic/common/notice/Get-All-Notices Example cURL command to fetch announcements in Chinese. ```bash curl "https://api.bitget.com/api/v2/public/annoucements?language=zh_CN" ``` -------------------------------- ### Query Announcements Response Example Source: https://www.bitget.com/api-doc/classic/common/notice/Get-All-Notices Example JSON response returned by the announcements endpoint. ```json { "code": "00000", "msg": "success", "requestTime": 1688008631614, "data": [ { "annId": "1", "annTitle": "test0629", "annDesc": "Latest announcement", "cTime": "1688008040000", "language": "zh_CN", "annUrl": "https://www.bitget.com/zh_CN/support/articles/23685" } ] } ``` -------------------------------- ### Get Server Time Response Example Source: https://www.bitget.com/api-doc/classic/common/public/Get-Server-Time This is an example of a successful response from the /api/v2/public/time endpoint. It includes a status code, message, request time, and the server time as a Unix millisecond timestamp. ```json { "code": "00000", "msg": "success", "requestTime": 1688008631614, "data": { "serverTime": "1688008631614" } } ``` -------------------------------- ### GET /api/v2/margin/market/isolated-borrow-rate Request Example Source: https://www.bitget.com/api-doc/classic/common/apidata/Margin-Iso-Borrow-Ratio Use this endpoint to retrieve the borrowing ratio data for isolated margin accounts. Specify the trading pair using the 'symbol' parameter. ```bash curl "https://api.bitget.com/api/v2/margin/market/isolated-borrow-rate?symbol=BTCUSDT" ``` -------------------------------- ### POST /api/v2/copy/mix-follower/copy-settings Source: https://www.bitget.com/api-doc/classic/changelog New version interface for follower order-following setup. ```APIDOC ## POST /api/v2/copy/mix-follower/copy-settings ### Description New version interface for follower order-following setup. ### Method POST ### Endpoint /api/v2/copy/mix-follower/copy-settings ``` -------------------------------- ### Get Trade Rate Request Source: https://www.bitget.com/api-doc/classic/common/public/Get-Trade-Rate Example of a GET request to retrieve trade rates using cURL. Requires authentication headers including ACCESS-KEY, ACCESS-SIGN, and ACCESS-TIMESTAMP. ```bash curl "https://api.bitget.com/api/v2/common/trade-rate?symbol=BTCUSDT&businessType=mix" \ -H "ACCESS-KEY:*******" \ -H "ACCESS-SIGN:*" \ -H "ACCESS-PASSPHRASE:*" \ -H "ACCESS-TIMESTAMP:1659076670000" \ -H "locale:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Response Example for All Symbol Trade Rate Source: https://www.bitget.com/api-doc/classic/common/public/Get-All-Trade-Rate This is an example of the JSON response you will receive, containing the trading symbol and its maker and taker fee rates. ```json { "code": "00000", "msg": "success", "requestTime": 1683875302853, "data": [ { "symbol": "BTCUSDT", "makerFeeRate": "0.0001", "takerFeeRate": "0.0004" }, { "symbol": "ETHUSDT", "makerFeeRate": "0.0001", "takerFeeRate": "0.0004" }, { "symbol": "DOGEUSDT", "makerFeeRate": "0.0001", "takerFeeRate": "0.0004" } ] } ``` -------------------------------- ### Maximum Openable Quantity Response Example Source: https://www.bitget.com/api-doc/classic/best-practices Example response from the 'open-count' API, indicating the maximum openable quantity for a given futures contract in the specified base currency. ```json {"code": "00000", "msg": "success", "requestTime": 1695812285073, "data": {"size": "0.47"}} ``` -------------------------------- ### Get Server Time Request Source: https://www.bitget.com/api-doc/classic/common/public/Get-Server-Time Use this cURL command to make a GET request to the Bitget API to retrieve the server time. The endpoint is /api/v2/public/time. ```bash curl "https://api.bitget.com/api/v2/public/time" ``` -------------------------------- ### Set Leverage Request Body Source: https://www.bitget.com/api-doc/classic/best-practices Example JSON payload for configuring leverage on a specific trading pair. ```json { "symbol": "BTCUSDT", "productType": "usdt-futures", "marginCoin": "usdt", "leverage": "3" } ``` -------------------------------- ### Define RSA Signing Function in JavaScript Source: https://www.bitget.com/api-doc/classic/quickStart/intro Example structure for a signing function in JavaScript containing a private key. ```javascript export function sign() { const private_key = '-----BEGIN PRIVATE KEY-----\n' + 'XXXXXXXXXXANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCdTR5gmwGH77wE\n' + 'XXXXXXXXXXVhiw7fPXWhMh7gZwurQQ8M/I9/VA8lDjwwoGuuJ6enurdfwhpZxeZH\n' + 'XXXXXXXXXXLESEXVuxJv5hdpI9m6ydInK9SA8IbaF4yYWp0l4N2mA44MzadA7QZq\n' + 'XXXXXXXXXXeia5q/NZHFWCrCbW2lGAAWwrhQq9LceVIW75e213xtnps0pGlII7Ye\n' + 'XXXXXXXXXXX8YNSxlCdLOiz1GvOeVSeiSZx31o/O+rj7tDFpSgZJEXRmtGRoJkJy\n' + 'XXXXXXXXXXzCVSOcb1hCExg4osK6rBKnDjFjwQvwvNNZq0JG+CkfH8eHAa7gSK50\n' + 'XXXXXXXXXXMBAAECggEAEvYk30hQGu7PH0stQX3UhlVsR6HXnRlvgIrmJe7F/VLO\n' + 'XXXXXXXXXXtU/heYY1nsX8+mIyjmvEOayqPgdkEmXevVlcuQf38Zbduynr3vlRCX\n' + 'XXXXXXXXXXucSxFBODuu/EAZc3mm27C2wUV7w6SAy9g0g6Os97ehZsSGAwHl4aye\n' + 'XXXXXXXXXX10Eh5Ptq4YAfCYiUO7j10pQ+DJKqN9N1eyjyw5eixEgCpudcbpCc9X\n' + 'XXXXXXXXXXr0ANX8/LwvokqgYBK1UIL6ear0dtKmeFU+KwrmkKZfXk8/Amr/O8Ot\n' + 'XXXXXXXXXXKRzq3La149LMmNkUYxaMSV/KGTEV7ukQKBgQDQl/fA3mxXtQg2IjTB\n' + 'XXXXXXXXXXhaECWcP7TQWJDb30vxOKeq1k9YPUfegZga5zlyV28PAZnb0m5x07+0\n' + 'XXXXXXXXXXpje9OhQxfkAY6AtJaiIqhCcw5ew8Go/Ja1ML0jZESWG1MWBJtCcFTm\n' + 'XXXXXXXXXX1Ze0adilYmyu7zwwKBgQDBDPJZgSj7YssPyRmo3bO0MjknfYBqXvwi\n' + 'XXXXXXXXXX5BJ9Rc2WXGfEm3DEn7TO/Wv0t7Yqm6/sXg5HzriN/PHlaVtE6wlXe7\n' + 'XXXXXXXXXXKO7KKWYqP812mASl6ydLX9QWozlOXjVhWMuSGqMWjut4J3P8jlkOJ6\n' + 'XXXXXXXXXXKBgQCxwvAl8ubNj78hsuDWgsddKIMkwvKrfdsvXrMOYouAdLjZJvjs\n' + 'XXXXXXXXXXl3s9km8g/479pYlOn+Iv/Z7Lqke8/HdOFASoQ9h1nSuujgEgXUwkg1\n' + 'XXXXXXXXXX0k2BY3FPnGGh8iQma1pdkUVn35fAq/m7e/S+kP1JY6lPIx1QKBgQCS\n' + 'XXXXXXXXXXNmpot+ceGt2bseSd8l4jqU3nDZ0oW8+4Qnnu9QFhN4Hn9wIjpAOGaU\n' + 'XXXXXXXXXXh+Vbior98JxMSDHsHmuXKPA8DishumGlqV+vxsIzLQD1Ge/dbqsERB\n' + 'XXXXXXXXXXiyUNqjk5kcPQeHIyJk5qQaF21udoTQKBgDOMbtM0Nq7cd/SAHISR\n' + 'XXXXXXXXXXLJW7DRJGxw3AEwxKG+nxNLeG7GsQDyPCvZSKwRpdpXRTh+6mzXqe\n' + 'XXXXXXXXXXz8Cwo6tgyKRi6QPObQk00vbrKEBTihP30m81rwBPzjwj7iKXxWgA\n' + 'DJoVsaqGOaIf4qXXXXXXXXXX\n' + '-----END PRIVATE KEY-----'; ``` -------------------------------- ### Get Spot Account Assets (All Currencies) Source: https://www.bitget.com/api-doc/classic/best-practices Retrieve the spot account balance for all currencies. This is the default behavior when no specific 'coin' parameter is provided. ```http GET /api/v2/spot/account/assets ``` -------------------------------- ### GET /api/v2/spot/market/whale-net-flow Source: https://www.bitget.com/api-doc/classic/common/apidata/Whale-Net-Flow Retrieves spot fund flow data for a specified trading pair. ```APIDOC ## GET /api/v2/spot/market/whale-net-flow ### Description Get spot fund flow data for a specific trading pair. ### Method GET ### Endpoint /api/v2/spot/market/whale-net-flow ### Parameters #### Query Parameters - **symbol** (String) - Required - Trading pair ### Request Example curl "https://api.bitget.com/api/v2/spot/market/fund-flow?symbol=BTCUSDT" ### Response #### Success Response (200) - **code** (String) - Response code - **msg** (String) - Response message - **requestTime** (Long) - Request timestamp - **data** (Array) - List of whale flow records - **volume** (String) - Whale buy sell volume - **date** (String) - Milliseconds time #### Response Example { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "volume": "-1.1", "date": "1713942000000" } ] } ``` -------------------------------- ### Generate Content to Sign for Market Depth Source: https://www.bitget.com/api-doc/classic/quickStart/intro This is the content to be signed for a GET request to retrieve market depth information. Ensure the timestamp, method, request path, and query string are correctly formatted. ```text 16273667805456GET/api/mix/v2/market/depth?limit=20&symbol=BTCUSDT ``` -------------------------------- ### Bitcoin Lightning Network Support (Jul 03, 2024) Source: https://www.bitget.com/api-doc/classic/changelog Updates to the Withdraw, Get Deposit Address, and Get SubAccount Deposit Address endpoints to support the Bitcoin Lightning Network. Users can now obtain Bitcoin Lightning Network invoice addresses and perform withdrawals to/from them. ```APIDOC ## Bitcoin Lightning Network Support (Jul 03, 2024) ### Description The following endpoints have been updated to support the Bitcoin Lightning Network: - **Withdraw** - **Get Deposit Address** - **Get SubAccount Deposit Address** ### Changes: - **Get Deposit Address & Get SubAccount Deposit Address**: Now supports obtaining Bitcoin Lightning Network invoice addresses. - **Withdraw**: Now supports withdrawals to Bitcoin Lightning Network invoice addresses. ``` -------------------------------- ### GET /api/v2/spot/market/support-symbols Source: https://www.bitget.com/api-doc/classic/common/apidata/Get-Big-Data-Symbol Retrieves a list of supported trading symbols for both spot and futures markets. This endpoint is useful for understanding the available trading pairs on the Bitget platform. ```APIDOC ## GET /api/v2/spot/market/support-symbols ### Description Get Trade data support symbols. ### Method GET ### Endpoint /api/v2/spot/market/support-symbols ### Parameters N/A ### Request Example ```curl curl "https://api.bitget.com/api/v2/spot/market/support-symbols" ``` ### Response #### Success Response (200) - **spotList** (List) - Spot data symbols - **futureList** (List) - Futures data symbols #### Response Example ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": { "spotList": ["BTCUSDT","ETHUSDT"], "futureList": ["BTCUSDT","ETHUSDT"] } } ``` ``` -------------------------------- ### GET /api/v2/spot/trade/history-plan-order Source: https://www.bitget.com/api-doc/classic/changelog Retrieves historical plan orders for spot trading with optional filtering parameters. ```APIDOC ## GET /api/v2/spot/trade/history-plan-order ### Description Retrieves historical plan orders. Parameters symbol, startTime, and endTime are now optional. ### Method GET ### Endpoint /api/v2/spot/trade/history-plan-order ### Parameters #### Query Parameters - **symbol** (string) - Optional - Trading pair - **startTime** (string) - Optional - Start timestamp - **endTime** (string) - Optional - End timestamp ``` -------------------------------- ### Response Example for Isolated Margin Borrowing Ratio Source: https://www.bitget.com/api-doc/classic/common/apidata/Margin-Iso-Borrow-Ratio The response includes a status code, message, request timestamp, and an array of borrowing ratio data, each with a timestamp and the borrow rate. ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "ts": "1713942000000", "borrowRate": "-0.96" }, { "ts": "1713942000000", "borrowRate": "-0.96" } ] } ``` -------------------------------- ### Get Spot Account Assets (Specific Currency) Source: https://www.bitget.com/api-doc/classic/best-practices Retrieve the spot account balance for a specific currency by providing the 'coin' parameter. This applies to currencies previously held, even if the current balance is zero. ```http GET /api/v2/spot/account/assets?coin=BTC ``` -------------------------------- ### Futures Long Short Account Data Response Source: https://www.bitget.com/api-doc/classic/common/apidata/Account-Long-Short Example JSON response containing the long/short account ratios and timestamps. ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "longAccountRatio": "0.01", "shortAccountRatio": "0.12", "longShortAccountRatio": "1.2", "ts": "1714020600000" }, { "longAccountRatio": "0.01", "shortAccountRatio": "0.12", "longShortAccountRatio": "1.2", "ts": "1714020600000" } ] } ``` -------------------------------- ### Futures Long and Short Ratio Response Format Source: https://www.bitget.com/api-doc/classic/common/apidata/Long-Short Example JSON response structure containing the long, short, and long-short ratios with timestamps. ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "longRatio": "0.01", "shortRatio": "0.12", "longShortRatio": "1.2", "ts": "1714020600000" }, { "longRatio": "0.01", "shortRatio": "0.12", "longShortRatio": "1.2", "ts": "1714020600000" } ] } ``` -------------------------------- ### GET /api/v2/spot/market/fund-net-flow Source: https://www.bitget.com/api-doc/classic/common/apidata/Fund-Net-Flow Retrieves the 24-hour net capital inflow information for a specified spot trading pair. ```APIDOC ## GET /api/v2/spot/market/fund-net-flow ### Description Get Spot 24H Net Capital Inflow Info. ### Method GET ### Endpoint /api/v2/spot/market/fund-net-flow ### Parameters #### Query Parameters - **symbol** (String) - Required - Trading pair ### Request Example curl "https://api.bitget.com/api/v2/spot/market/fund-net-flow?symbol=BTCUSDT" ### Response #### Success Response (200) - **code** (String) - Response code - **msg** (String) - Response message - **requestTime** (Long) - Request timestamp - **data** (Array) - List of net flow records - **netFlow** (String) - Whale fund net flow - **ts** (String) - Milliseconds time #### Response Example { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "netFlow": "-1.1", "ts": "1713942000000" } ] } ``` -------------------------------- ### GET /api/v2/spot/public/symbols Source: https://www.bitget.com/api-doc/classic/changelog Retrieves symbol information for the Classic Account spot market, now including maximum order value limits. ```APIDOC ## GET /api/v2/spot/public/symbols ### Description Retrieves the list of symbols and their trading information. Recently updated to include maximum limit and market order values. ### Method GET ### Endpoint /api/v2/spot/public/symbols ### Response #### Success Response (200) - **maxLimitOrderValue** (string) - Maximum single limit order value - **maxMarketOrderValue** (string) - Maximum single market order value ``` -------------------------------- ### Get All Symbol Trade Rate Request Source: https://www.bitget.com/api-doc/classic/common/public/Get-All-Trade-Rate Use this cURL command to request the trade rates for all symbols. Ensure you replace placeholder headers with your actual API credentials and timestamp. ```bash curl "https://api.bitget.com/api/v2/common/all-trade-rate?businessType=mix" \ -H "ACCESS-KEY:*******" \ -H "ACCESS-SIGN:*" \ -H "ACCESS-PASSPHRASE:*" \ -H "ACCESS-TIMESTAMP:1659076670000" \ -H "locale:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Signature Generation Source: https://www.bitget.com/api-doc/classic/quickStart/intro Instructions on how to construct the signature string for the ACCESS-SIGN header. ```APIDOC ## Signature Generation ### Description The signature is generated by encrypting a concatenated string using HMAC SHA256 with your SecretKey, then encoding the result in Base64. ### Signature String Construction - **If queryString is empty:** `timestamp + method.toUpperCase() + requestPath + body` - **If queryString is not empty:** `timestamp + method.toUpperCase() + requestPath + "?" + queryString + body` ### Parameters - **timestamp**: Milliseconds since Epoch. - **method**: HTTP method in uppercase (e.g., GET, POST). - **requestPath**: The API endpoint path. - **queryString**: Parameters following the '?' in the URL. - **body**: The request body as a string (omit if empty). ``` -------------------------------- ### Pagination Parameters Source: https://www.bitget.com/api-doc/classic/best-practices Bitget provides pagination functionality to help users easily obtain data. These parameters can be used with various trading interfaces. ```APIDOC ## Pagination Parameters ### Description Parameters used for paginating through data. ### Parameters #### Query Parameters - **idLessThan** (String) - Optional - Request paginated content before this ID (older data), the value passed is the corresponding interface's `orderId`, `billId`, `tradeId`, etc. - **startTime** (String) - Optional - Start time, Unix timestamp (milliseconds) - **endTime** (String) - Optional - End time, Unix timestamp (milliseconds) - **limit** (String) - Optional - Number of results returned, maximum 100, default 100 ``` -------------------------------- ### POST /api/v2/copy/mix-trader/create-copy-api Source: https://www.bitget.com/api-doc/classic/changelog New version interface for order initiators to create order API keys. ```APIDOC ## POST /api/v2/copy/mix-trader/create-copy-api ### Description New version interface for order initiators to create order API keys. ### Method POST ### Endpoint /api/v2/copy/mix-trader/create-copy-api ``` -------------------------------- ### Get P2P Merchant List Interface Adjustment (Jun 25, 2024) Source: https://www.bitget.com/api-doc/classic/changelog The `merchantId` parameter has been removed from the Get P2P Merchant List interface as of June 25, 2024. ```APIDOC ## Get P2P Merchant List Interface Adjustment (Jun 25, 2024) ### Description The `merchantId` parameter has been removed from the **Get P2P Merchant List** interface. ``` -------------------------------- ### Get Spot 24H Net Capital Inflow Info Request Source: https://www.bitget.com/api-doc/classic/common/apidata/Fund-Net-Flow Use this GET request to retrieve the 24-hour net capital inflow for a specific spot trading pair. Ensure you replace 'BTCUSDT' with your desired symbol. ```curl curl "https://api.bitget.com/api/v2/spot/market/fund-net-flow?symbol=BTCUSDT" ``` -------------------------------- ### Trading Interfaces with Pagination Source: https://www.bitget.com/api-doc/classic/best-practices List of trading interfaces that support pagination. ```APIDOC ## Trading Interfaces with Pagination ### Description These endpoints support the pagination parameters described above. ### Endpoints - `GET /api/v2/spot/trade/unfilled-orders` - Get unfilled orders list - `GET /api/v2/spot/trade/history-orders` - Get historical orders - `GET /api/v2/spot/trade/fills` - Get fill details - `GET /api/v2/mix/order/orders-history` - Get futures historical orders - `GET /api/v2/mix/order/fills` - Get futures fill details ``` -------------------------------- ### Generate HMAC Signature in Java Source: https://www.bitget.com/api-doc/classic/quickStart/intro Use this Java code to generate an HMAC-SHA256 signature for API requests. It handles both GET and POST methods and requires timestamp, method, request path, query string (for GET), body (for POST), and your secret key. ```Java import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import javax.management.RuntimeErrorException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Base64; import org.springframework.util.Base64Utils; @Slf4j public class CheckSign { private static final String secretKey = ""; public static void main(String[] args) throws Exception { //POST sign example // String timestamp = "1684813405151"; // String body = "{\"symbol\":\"TRXUSDT\",\"marginCoin\":\"USDT\",\"size\":551,\"side\":\"buy\",\"orderType\":\"limit\",\"price\":0.0555,\"force\":\"normal\"}"; // // String sign = generate(timestamp,"POST","/api/v2/mix/order/place-order" ,null,body,secretKey); // log.info("sign:{}",sign); //GET sign example String timestamp = "1684814440729"; String queryString = "marginCoin=usdt&symbol=btcusdt"; // Need to be sorted in ascending alphabetical order by key String sign = generate(timestamp,"GET","/api/v2/mix/account/account" ,queryString,null,secretKey); log.info("sign:{}",sign); } private static Mac MAC; static { try { CheckSign.MAC = Mac.getInstance("HmacSHA256"); } catch (NoSuchAlgorithmException var1) { throw new RuntimeErrorException(new Error("Can't get Mac's instance.")); } } public static String generate(String timestamp, String method, String requestPath, String queryString, String body, String secretKey) throws CloneNotSupportedException, InvalidKeyException, UnsupportedEncodingException { method = method.toUpperCase(); body = StringUtils.defaultIfBlank(body, StringUtils.EMPTY); queryString = StringUtils.isBlank(queryString) ? StringUtils.EMPTY : "?" + queryString; String preHash = timestamp + method + requestPath + queryString + body; log.info("preHash:{}",preHash); byte[] secretKeyBytes = secretKey.getBytes("UTF-8"); SecretKeySpec secretKeySpec = new SecretKeySpec(secretKeyBytes, "HmacSHA256"); Mac mac = (Mac) CheckSign.MAC.clone(); mac.init(secretKeySpec); return Base64.getEncoder().encodeToString(mac.doFinal(preHash.getBytes("UTF-8"))); } } ``` -------------------------------- ### Get History Trigger Order Time Range Adjustment (Mar 15, 2024) Source: https://www.bitget.com/api-doc/classic/changelog Effective March 15, 2024, the time range for the Get History Trigger Order endpoint has been adjusted. The interval between `startTime` and `endTime` is now limited to 90 days, and only historical records within the past 90 days are supported. ```APIDOC ## Get History Trigger Order Time Range Adjustment (Mar 15, 2024) ### Endpoint - Get History Trigger Order ### Changes: 1. The interval between `startTime` and `endTime` is now limited to 90 days. 2. Only historical records within the past 90 days are supported. ``` -------------------------------- ### GET /api/v2/mix/order/orders-history Source: https://www.bitget.com/api-doc/classic/changelog Retrieves historical futures orders with added liquidation price information. ```APIDOC ## GET /api/v2/mix/order/orders-history ### Description Retrieves historical futures orders. Includes order source information and liquidation price. ### Method GET ### Endpoint /api/v2/mix/order/orders-history ### Response #### Success Response (200) - **orderSource** (string) - Source of the order (includes 'off_close' for Delisting Liquidation) - **liqPrice** (string) - Liquidation price of the order ``` -------------------------------- ### GET /api/v2/spot/account/transferRecords Source: https://www.bitget.com/api-doc/classic/changelog Retrieves spot account transfer records with updated pagination support. ```APIDOC ## GET /api/v2/spot/account/transferRecords ### Description Retrieves transfer records for the spot account. Pagination now uses idLessThan instead of pageNum. ### Method GET ### Endpoint /api/v2/spot/account/transferRecords ### Parameters #### Query Parameters - **idLessThan** (string) - Required - Pagination cursor for retrieving records ``` -------------------------------- ### Generate Signature - Step 3: Base64 Encode Hash Source: https://www.bitget.com/api-doc/classic/quickStart/websocket-intro Base64 encode the resulting hash to obtain the final signature string. ```java String sign = base64.encode(hash); ``` -------------------------------- ### GET /api/v2/mix/market/oi-limit Source: https://www.bitget.com/api-doc/classic/changelog Provides information regarding Open Interest (OI) position limits in contracts. ```APIDOC ## GET /api/v2/mix/market/oi-limit ### Description Provides information regarding Open Interest (OI) position limits in contracts. ### Method GET ### Endpoint /api/v2/mix/market/oi-limit ``` -------------------------------- ### Place Order - WebSocket Source: https://www.bitget.com/api-doc/classic/best-practices Place orders efficiently using WebSocket. Requires a message ID (`id`) for asynchronous request identification. The response includes the message ID and the exchange-assigned order ID. ```APIDOC ## Place Order via WebSocket ### Description Places an order through WebSocket, offering potentially higher efficiency than REST. Requires a unique message ID (`id`) for tracking asynchronous responses. ### Method WebSocket ### Endpoint Private WebSocket connection ### Request Body ```json { "args": [ { "channel": "place-order", "id": "NEWtestBTC0123", "instId": "BTCUSDT", "instType": "USDT-FUTURES", "params": { "orderType": "limit", "side": "buy", "size": "2", "tradeSide": "open", "price": "501", "marginCoin": "USDT", "force": "gtc", "marginMode": "crossed", "clientOid": "testBTC0123" } } ], "op": "trade" } ``` ### Response Example ```json { "event": "trade", "arg": [ { "id": "NEWtestBTC0123", "instType": "USDT-FUTURES", "channel": "place-order", "instId": "BTCUSDT", "params": { "orderId": "1234567890", "clientOid": "testBTC0123" } } ], "code": 0, "msg": "Success" } ``` ### Note This response confirms the exchange received the order request and assigned an order ID. The order's status in the matching system needs further verification via order status checks. ``` -------------------------------- ### Response structure for support symbols Source: https://www.bitget.com/api-doc/classic/common/apidata/Get-Big-Data-Symbol The response returns a JSON object containing lists of supported spot and futures symbols. ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": { "spotList": ["BTCUSDT","ETHUSDT"], "futureList": ["BTCUSDT","ETHUSDT"] } } ``` -------------------------------- ### GET /api/v2/margin/market/isolated-borrow-rate Source: https://www.bitget.com/api-doc/classic/common/apidata/Margin-Iso-Borrow-Ratio Retrieves the borrowing ratio for a specific trading pair in isolated margin accounts. ```APIDOC ## GET /api/v2/margin/market/isolated-borrow-rate ### Description The ratio of borrowed amount in the base currency and borrowed amount in the quote currency in isolated margin accounts, converted to USDT. ### Method GET ### Endpoint /api/v2/margin/market/isolated-borrow-rate ### Parameters #### Query Parameters - **symbol** (String) - Required - Trading pair - **period** (String) - Optional - Default: 24h, support: 24h, 30d ### Request Example curl "https://api.bitget.com/api/v2/margin/market/isolated-borrow-rate?symbol=BTCUSDT" ### Response #### Success Response (200) - **code** (String) - Response code - **msg** (String) - Response message - **requestTime** (Long) - Request timestamp - **data** (Array) - List of borrowing rate records - **ts** (String) - Milliseconds time - **borrowRate** (String) - Borrow ratio #### Response Example { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "ts": "1713942000000", "borrowRate": "-0.96" }, { "ts": "1713942000000", "borrowRate": "-0.96" } ] } ``` -------------------------------- ### Spot Whale Net Flow Response Format Source: https://www.bitget.com/api-doc/classic/common/apidata/Whale-Net-Flow The API returns a JSON object containing a list of volume and date entries. ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "volume": "-1.1", "date": "1713942000000" }, { "volume": "-1.1", "date": "1713942000000" }, { "volume": "-1.1", "date": "1713942000000" }, { "volume": "-1.1", "date": "1713942000000" }, { "volume": "-1.1", "date": "1713942000000" } ] } ``` -------------------------------- ### Maximum Openable Quantity - Futures Source: https://www.bitget.com/api-doc/classic/best-practices Get the maximum position quantity that can be opened for a given futures product. ```APIDOC ## Maximum Openable Quantity - Futures ### Description Retrieve the maximum openable quantity for futures trading products. ### Endpoint `GET /api/v2/mix/account/open-count` ### Parameters #### Query Parameters - **productType** (String) - Required - Type of futures product (e.g., `usdt-futures`) - **symbol** (String) - Required - Trading symbol (e.g., `ethusdt`) - **marginCoin** (String) - Required - Margin currency (e.g., `USDT`) - **openPrice** (String) - Required - Current open price - **leverage** (String) - Required - Leverage applied - **openAmount** (String) - Required - Amount to open ### Request Example `GET /api/v2/mix/account/open-count?productType=usdt-futures&symbol=ethusdt&marginCoin=USDT&openPrice=23189.5&leverage=20&openAmount=5000` ### Response #### Success Response (200) - **size** (String) - The maximum openable quantity for the specified futures product. ``` ```APIDOC ### Response Example ```json { "code": "00000", "msg": "success", "requestTime": 1695812285073, "data": { "size": "0.47" } } ``` ``` -------------------------------- ### Place Order - REST API Source: https://www.bitget.com/api-doc/classic/best-practices Place orders using the REST API. The API returns an order ID upon successful request reception. It is recommended to fill in a `clientOid` for easier order identification. ```APIDOC ## POST /api/v2/mix/order/place-order ### Description Places an order via the REST API. The server returns an order ID upon successful request reception. It is recommended to use a unique `clientOid` for troubleshooting. ### Method POST ### Endpoint `/api/v2/mix/order/place-order` ### Parameters #### Request Body - **symbol** (string) - Required - The trading symbol (e.g., "BTCUSDT"). - **productType** (string) - Required - The product type (e.g., "usdt-futures"). - **marginMode** (string) - Required - The margin mode (e.g., "crossed"). - **marginCoin** (string) - Required - The margin currency (e.g., "USDT"). - **clientOid** (string) - Optional - A unique client-defined order ID. Must match `^[0-9A-Za-z_:#\-+\s]{1,32}$`. - **side** (string) - Required - The order side (e.g., "buy" or "sell"). - **orderType** (string) - Required - The type of order (e.g., "limit" or "market"). - **price** (string) - Required if `orderType` is "limit" - The price of the order. - **size** (string) - Required - The quantity of the order. ### Request Example ```json { "symbol": "BTCUSDT", "productType": "usdt-futures", "marginMode": "crossed", "marginCoin": "USDT", "clientOid": "testBTC0123", "side": "buy", "orderType": "limit", "price": "50000", "size": "0.1" } ``` ### Response #### Success Response (200) - **code** (string) - Response code. - **msg** (string) - Response message. - **data** (object) - Response data. - **clientOid** (string) - The client order ID. - **orderId** (string) - The exchange-assigned order ID. #### Response Example ```json { "code": "00000", "msg": "success", "data": { "clientOid": "testBTC0123", "orderId": "1234567890" } } ``` ### Note This response indicates the exchange has received the request and assigned an order ID. The order may not have reached the matching system yet; further status checks are required. ``` -------------------------------- ### POST /login Source: https://www.bitget.com/api-doc/classic/quickStart/websocket-intro Authenticates a WebSocket connection using an API key, passphrase, and a generated signature. ```APIDOC ## POST /login ### Description Authenticates the current WebSocket connection. If authentication fails, the server will automatically disconnect the client. ### Request Body - **op** (string) - Required - Operation type, must be "login" - **args** (array) - Required - Array containing the authentication object - **apiKey** (string) - Required - Unique API key - **passphrase** (string) - Required - API key password - **timestamp** (string) - Required - Unix timestamp in milliseconds (expires in 30s) - **sign** (string) - Required - Signature generated via HMAC SHA256 or RSA ### Request Example { "op": "login", "args": [ { "apiKey": "xx_xxx", "passphrase": "xxx", "timestamp": "1538054050", "sign": "8RCOqCJAhhEh4PWcZB/96QojLDqMAg4qNynIixFzS3E=" } ] } ### Response #### Success Response (200) - **event** (string) - Event type, returns "login" - **code** (string) - Status code, "0" indicates success - **msg** (string) - Status message #### Response Example { "event": "login", "code": "0", "msg": "" } ``` -------------------------------- ### Get Futures Account Balance Source: https://www.bitget.com/api-doc/classic/best-practices Use this REST API endpoint to query the balance for your futures account. ```http GET /api/v2/mix/account/accounts ``` -------------------------------- ### GET /api/v2/mix/position/adlRank Source: https://www.bitget.com/api-doc/classic/changelog Supports obtaining ADL (Auto-Deleveraging) rankings for users across various trading pairs. ```APIDOC ## GET /api/v2/mix/position/adlRank ### Description Supports obtaining ADL (Auto-Deleveraging) rankings for users across various trading pairs. ### Method GET ### Endpoint /api/v2/mix/position/adlRank ``` -------------------------------- ### GET /api/v2/mix/market/account-long-short Source: https://www.bitget.com/api-doc/classic/common/apidata/Account-Long-Short Retrieves the active long/short account ratio data for a specified futures trading pair. ```APIDOC ## GET /api/v2/mix/market/account-long-short ### Description Get Futures Active Long Short Account Data ### Method GET ### Endpoint /api/v2/mix/market/account-long-short ### Parameters #### Query Parameters - **symbol** (String) - Required - Trading pair - **period** (String) - Optional - Time period (default: 5m, support: 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d) ### Request Example curl "https://api.bitget.com/api/v2/mix/market/account-long-short?symbol=BTCUSDT" ### Response #### Success Response (200) - **code** (String) - Response code - **msg** (String) - Response message - **requestTime** (Long) - Request timestamp - **data** (Array) - List of account ratio records - **longAccountRatio** (String) - Long Account Ratio - **shortAccountRatio** (String) - Short Account Ratio - **longShortAccountRatio** (String) - Long Short Account Ratio - **ts** (String) - Milliseconds time #### Response Example { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "longAccountRatio": "0.01", "shortAccountRatio": "0.12", "longShortAccountRatio": "1.2", "ts": "1714020600000" } ] } ``` -------------------------------- ### GET /api/v2/mix/market/long-short Source: https://www.bitget.com/api-doc/classic/common/apidata/Long-Short Retrieves Futures Long and Short Ratio Data for a specified trading pair and period. ```APIDOC ## GET /api/v2/mix/market/long-short ### Description Get Futures Long and Short Ratio Data. ### Method GET ### Endpoint /api/v2/mix/market/long-short ### Parameters #### Query Parameters - **symbol** (String) - Required - Trading pair - **period** (String) - Optional - Default: 5m. Supported values: `5m`, `15m`, `30m`, `1h`, `2h`, `4h`, `6h`, `12h`, `1Dutc` ### Request Example ```json { "example": "curl \"https://api.bitget.com/api/v2/mix/market/long-short?symbol=BTCUSDT\"" } ``` ### Response #### Success Response (200) - **code** (String) - Response code - **msg** (String) - Response message - **requestTime** (Number) - Request timestamp - **data** (Array) - Array of ratio data objects - **longRatio** (String) - Long Ratio - **shortRatio** (String) - Short Ratio - **longShortRatio** (String) - Long Short Ratio - **ts** (String) - Milliseconds timestamp #### Response Example ```json { "code": "00000", "msg": "success", "requestTime": 1656589586807, "data": [ { "longRatio": "0.01", "shortRatio": "0.12", "longShortRatio": "1.2", "ts": "1714020600000" }, { "longRatio": "0.01", "shortRatio": "0.12", "longShortRatio": "1.2", "ts": "1714020600000" } ] } ``` ``` -------------------------------- ### Place Order via REST API Source: https://www.bitget.com/api-doc/classic/best-practices Place a limit order for BTCUSDT futures using the REST API. Ensure the `clientOid` is unique for better troubleshooting. The response indicates successful request reception, not necessarily order matching. ```json {"symbol": "BTCUSDT", "productType": "usdt-futures", "marginMode": "crossed", "marginCoin": "USDT", "clientOid": "testBTC0123", "side": "buy", "orderType": "limit", "price": "50000", "size": "0.1"} ``` ```json {"code": "00000", "msg": "success", "data": {"clientOid": "testBTC0123", "orderId": "1234567890"}} ```