### Get History Orders Request Example Source: https://www.bitunix.com/api-docs/futures/trade/get_history_orders.html This example demonstrates how to make a GET request to retrieve historical orders. Ensure you replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/trade/get_history_orders?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get History TP/SL Order Request Example Source: https://www.bitunix.com/api-docs/futures/tp_sl/get_history_tp_sl_order.html Use this example to make a GET request to retrieve historical TP/SL orders. Ensure you replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/tpsl/get_history_orders?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Pending Positions Request Example Source: https://www.bitunix.com/api-docs/futures/position/get_pending_positions.html Use this example to make a GET request to the /api/v1/futures/position/get_pending_positions endpoint. Ensure you replace placeholder headers with your actual API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/position/get_pending_positions?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Leverage and Margin Mode Response Example Source: https://www.bitunix.com/api-docs/futures/account/get_leverage_and_margin_mode.html This is an example of a successful JSON response when querying leverage and margin mode. It includes the trading pair, margin coin, leverage, and margin mode. ```json {"code":0,"data":{"symbol":"BTCUSDT","marginCoin":"USDT","leverage":10,"marginMode":"ISOLATION"},"msg":"Success"} ``` -------------------------------- ### Get Order Detail Request Example (cURL) Source: https://www.bitunix.com/api-docs/futures/trade/get_order_detail.html Demonstrates how to make a GET request to retrieve order details using cURL. Ensure you replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/trade/get_order_detail?orderId=12345' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Pending Orders Request Example Source: https://www.bitunix.com/api-docs/futures/trade/get_pending_orders.html This example demonstrates how to make a GET request to the /api/v1/futures/trade/get_pending_orders endpoint using cURL. Ensure you replace placeholder values with your actual API credentials and desired parameters. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/trade/get_pending_orders?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Trading Pairs Response Example Source: https://www.bitunix.com/api-docs/futures/market/get_trading_pairs.html This is an example of the JSON response when successfully retrieving trading pair data. It includes details like symbol, base/quote currencies, precision, leverage, and status. ```json {"code":0,"data":[{"symbol":"BTCUSDT","base":"BTC","quote":"USDT","minTradeVolume":"0.0001","minBuyPriceOffset":"-0.95","maxSellPriceOffset":"100","maxLimitOrderVolume":"100000","maxMarketOrderVolume":"50000","basePrecision":4,"quotePrecision":1,"minLeverage":1,"maxLeverage":125,"defaultLeverage":20,"defaultMarginMode":1,"priceProtectScope":"0.02","symbolStatus":"OPEN"}],"msg":"Success"} ``` -------------------------------- ### Get Leverage and Margin Mode Request Example Source: https://www.bitunix.com/api-docs/futures/account/get_leverage_and_margin_mode.html Use this cURL command to make a GET request to retrieve leverage and margin mode. Ensure you replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/account/get_leverage_margin_mode?symbol=BTCUSDT&marginCoin=USDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Asset Query API Request Example Source: https://www.bitunix.com/api-docs/futures/copyTrading/asset/asset_query.html Demonstrates how to make a GET request to the asset query endpoint using cURL. Ensure you replace placeholder values for api-key, sign, timestamp, and nonce with your actual credentials and a valid nonce. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/cp/asset/query' \ -H "api-key:*******" \ -H "sign:*" \ -H "timestamp:1659076670000" \ -H "nonce:your-nonce" \ -H "language:en-US" ``` -------------------------------- ### Change Position Mode Response Example Source: https://www.bitunix.com/api-docs/futures/account/change_position_mode.html This is an example of a successful response when changing the position mode. It confirms the new position mode setting. ```json {"code":0,"data":[{"positionMode":"HEDGE"}],"msg":"Success"} ``` -------------------------------- ### Get Position Tiers Request Example Source: https://www.bitunix.com/api-docs/futures/position/get_position_tiers.html Use this cURL command to make a GET request to the API endpoint. Ensure you replace 'BTCUSDT' with the desired trading pair. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/position/get_position_tiers?symbol=BTCUSDT' ``` -------------------------------- ### Get Single Futures Account Request Example Source: https://www.bitunix.com/api-docs/futures/account/get_single_account.html Use this cURL command to make a GET request to retrieve account details. Ensure you replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/account?marginCoin=USDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Change Margin Mode Response Example Source: https://www.bitunix.com/api-docs/futures/account/change_margin_mode.html This is a successful response example after changing the margin mode. It confirms the new margin mode and trading pair. ```json {"code":0,"data":[{"positionMode":"ISOLATION"}],"msg":"Success"} ``` -------------------------------- ### Get Single Futures Account Response Example Source: https://www.bitunix.com/api-docs/futures/account/get_single_account.html This is an example of a successful JSON response when retrieving futures account details. It includes fields like available balance, margin, PNL, and position mode. ```json {"code":0,"data":[{"marginCoin":"USDT","available":"1000","frozen":"0","margin":"10","transfer":"1000","positionMode":"HEDGE","crossUnrealizedPNL":"2","isolationUnrealizedPNL":"0","bonus":"0"}],"msg":"Success"} ``` -------------------------------- ### Get Tickers Response Example - JSON Source: https://www.bitunix.com/api-docs/futures/market/get_tickers.html This is an example of the JSON response when successfully retrieving ticker data. It includes details such as symbol, mark price, last price, and trading volumes for the requested pairs. ```json {"code":0,"data":[{"symbol":"BTCUSDT","markPrice":"57892.1","lastPrice":"57891.2","open":"6.31","last":"6.31","quoteVol":"0","baseVol":"0","high":"6.31","low":"6.31"},{"symbol":"ETHUSDT","markPrice":"2000","lastPrice":"2020.1","open":"6.31","last":"6.31","quoteVol":"0","baseVol":"0","high":"6.31","low":"6.31"}],"msg":"Success"} ``` -------------------------------- ### Change Leverage Response Example (JSON) Source: https://www.bitunix.com/api-docs/futures/account/change_leverage.html This is an example of a successful response from the change leverage API. It confirms the margin coin, leverage, and symbol that were updated. ```json {"code":0,"data":[{"marginCoin":"USDT","leverage":12,"symbol":"BTCUSDT"}],"msg":"Success"} ``` -------------------------------- ### Get Position Tiers Response Example Source: https://www.bitunix.com/api-docs/futures/position/get_position_tiers.html This is an example of a successful JSON response containing position tier details, including symbol, level, value ranges, leverage, and maintenance margin rate. ```json {"code":0,"data":[{"symbol":"BTCUSDT","level":1,"startValue":"0","endValue":"50000","leverage":125,"maintenanceMarginRate":"0.004"},{"symbol":"BTCUSDT","level":2,"startValue":"50000","endValue":"200000","leverage":100,"maintenanceMarginRate":"0.005"}],"msg":"Success"} ``` -------------------------------- ### Order Detail Response Example (JSON) Source: https://www.bitunix.com/api-docs/futures/trade/get_order_detail.html An example of the JSON response structure when successfully retrieving order details. This includes information such as order ID, symbol, quantity, price, status, and PNL. ```json {"code":0,"data":{"orderId":"11111","qty":"1","tradeQty":"0.5","price":"60000","symbol":"BTCUSDT","positionMode":"HEDGE","marginMode":"ISOLATION","leverage":15,"status":"PART_FILLED","fee":"0.01","realizedPNL":"1.78","type":"LIMIT","effect":"GTC","reduceOnly":false,"clientId":"22222","tpPrice":"61000","tpStopType":"MARK","tpOrderType":"LIMIT","tpOrderPrice":"61000.1","slPrice":"59000","slStopType":"MARK","slOrderType":"LIMIT","slOrderPrice":"59000.1","source":"api","ctime":1597026383085,"mtime":1597026383085},"msg":"Success"} ``` -------------------------------- ### Request Formats (GET and POST) Source: https://www.bitunix.com/api-docs/spots Understand how to structure your requests using either the GET or POST method, depending on the operation and data transfer requirements. ```APIDOC ## Request Formats ### Description Bitunix API supports two primary request formats: GET and POST. The choice depends on the nature of the request and the amount of data being sent. ### GET Requests - **Usage**: Typically used for retrieving data. - **Parameter Transfer**: Parameters are appended to the URL as a query string. ### POST Requests - **Usage**: Typically used for submitting data, such as creating orders. - **Parameter Transfer**: Parameters are encapsulated in the request body in JSON format. - **Content-Type**: The `Content-Type` header must be set to `application/json`. ``` -------------------------------- ### Ping Response Example Source: https://www.bitunix.com/api-docs/futures/websocket/prepare/WebSocket.html Example of a successful ping response from the WebSocket server, including a pong timestamp and a new ping timestamp. ```json { "op":"ping", "pong":1732519687, "ping":1732519690 } ``` -------------------------------- ### Depth Channel Push Data Example Source: https://www.bitunix.com/api-docs/futures/websocket/public/depth%20channel.html This is an example of the data structure received when subscribed to a depth channel. It includes channel information, symbol, timestamp, and the actual depth data for bids ('b') and asks ('a'). ```json { "ch": "depth_book1", "symbol": "BTCUSDT", "ts": 1775541541009, "data":{ "b": [ [ "7403.89", "0.002" ] ], "a": [ [ "7405.96", "3.340" ] ] } } ``` -------------------------------- ### Get History Positions Request Example (cURL) Source: https://www.bitunix.com/api-docs/futures/position/get_history_positions.html Demonstrates how to make a GET request to retrieve historical futures positions using cURL. Ensure to replace placeholder values for API key, signature, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/position/get_history_positions?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Successful Response Example Source: https://www.bitunix.com/api-docs/futures/account/adjust_position_margin.html This is an example of a successful response when adjusting position margin. The response indicates success with a code of 0 and a success message. ```json {"code":0,"data":"","msg":"Success"} ``` -------------------------------- ### Get Trading Pairs Request Example Source: https://www.bitunix.com/api-docs/futures/market/get_trading_pairs.html Use this cURL command to request trading pair details. You can specify multiple symbols separated by commas. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/market/trading_pairs?symbols=BTCUSDT,ETHUSDT' ``` -------------------------------- ### Get Pending TP/SL Orders Request Example Source: https://www.bitunix.com/api-docs/futures/tp_sl/get_pending_tp_sl_order.html Use this cURL command to make a GET request to the Bitunix API to retrieve pending TP/SL orders. Ensure you replace placeholder values for API key, sign, nonce, and timestamp. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/tpsl/get_pending_orders?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### History Positions Response Example (JSON) Source: https://www.bitunix.com/api-docs/futures/position/get_history_positions.html An example of the JSON response structure when successfully retrieving historical futures positions. It includes a list of positions with detailed attributes. ```json {"code":0,"data":{"positionList":[{"positionId":"12345678","symbol":"BTCUSDT","maxQty":"0.5","entryPrice":"60000","closePrice":"61000","liqQty":"0","side":"LONG","positionMode":"HEDGE","marginMode":"ISOLATION","leverage":100,"fee":"0.1","funding":"-0.2","realizedPNL":"102.9","liqPrice":"22209","ctime":1691382137448,"mtime":1691382137448}],"total":12},"msg":"Success"} ``` -------------------------------- ### Trade Channel Push Data Example Source: https://www.bitunix.com/api-docs/futures/websocket/public/Trade%20Channel.html This is an example of the data structure received when subscribing to the trade channel. It includes trade details like price, volume, side, and timestamp. ```json { "ch": "trade", "symbol": "BTCUSDT", "ts": 1775540872598, "data": [ { "t": "2026-04-07T05:47:52Z", "p": "68621.4", "v": "0.7142", "s": "buy" }, { "t": "2026-04-07T05:47:52Z", "p": "68621.4", "v": "0.0018", "s": "sell" } ] } ``` -------------------------------- ### History Orders Response Example Source: https://www.bitunix.com/api-docs/futures/trade/get_history_orders.html This is an example of the JSON response structure when successfully retrieving order history. It includes details for each order such as order ID, quantity, status, and timestamps. ```json { "code": 0, "data": { "orderList": [ { "orderId": "11111", "qty": "1", "tradeQty": "0.5", "price": "60000", "symbol": "BTCUSDT", "positionMode": "HEDGE", "marginMode": "ISOLATION", "leverage": 15, "status": "CANCELED", "fee": "0.01", "realizedPNL": "1.78", "type": "LIMIT", "effect": "GTC", "reduceOnly": false, "clientId": "22222", "tpPrice": "61000", "tpStopType": "MARK", "tpOrderType": "LIMIT", "tpOrderPrice": "61000.1", "slPrice": "59000", "slStopType": "MARK", "slOrderType": "LIMIT", "slOrderPrice": "59000.1", "source": "api", "ctime": 1597026383085, "mtime": 1597026383085 } ], "total": 10 }, "msg": "Success" } ``` -------------------------------- ### Pending Positions Response Example Source: https://www.bitunix.com/api-docs/futures/position/get_pending_positions.html This is an example of a successful response when retrieving pending futures positions. It includes details such as position ID, symbol, quantity, side, margin mode, leverage, and PNL. ```json {"code":0,"data":[{"positionId":"12345678","symbol":"BTCUSDT","qty":"0.5","entryValue":"30000","side":"LONG","positionMode":"HEDGE","marginMode":"ISOLATION","leverage":100,"fee":"0.1","funding":"-0.2","realizedPNL":"102.9","margin":"300","unrealizedPNL":"1.5","liqPrice":"22209","marginRate":"0.01", "avgOpenPrice": "1.0","ctime":1691382137448,"mtime":1691382137448}],"msg":"Success"} ``` -------------------------------- ### Change Position Mode Request Example Source: https://www.bitunix.com/api-docs/futures/account/change_position_mode.html Use this example to send a POST request to change the user's position mode for all symbol futures. Ensure you replace placeholder values for API key, sign, nonce, and timestamp. The position mode cannot be adjusted if there are open positions or orders. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/account/change_position_mode' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"positionMode":"HEDGE"}' ``` -------------------------------- ### Modify TP/SL Order Request Example (Bash) Source: https://www.bitunix.com/api-docs/futures/tp_sl/modify_tp_sl_order.html This example demonstrates how to send a POST request to modify a TP/SL order using cURL. Ensure you replace placeholder values for API keys, nonce, and timestamp. At least one of `tpPrice` or `slPrice`, and at least one of `tpQty` or `slQty` must be provided. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/tpsl/modify_order' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"orderId":"123","tpPrice":"12","tpStopType":"LAST_PRICE","slPrice":"9","slStopType":"LAST_PRICE","tpOrderType":"LIMIT","tpOrderPrice":"11","slOrderType":"LIMIT","slOrderPrice":"8","tpQty":"1","slQty":"1"}' ``` -------------------------------- ### Change Margin Mode Request Example Source: https://www.bitunix.com/api-docs/futures/account/change_margin_mode.html Use this example to send a POST request to change the margin mode. Ensure you replace placeholder values for API key, sign, nonce, and timestamp. This endpoint cannot be used with open positions or orders. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/account/change_margin_mode' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"marginMode":"ISOLATION","symbol":"BTCUSDT","marginCoin":"USDT"}' ``` -------------------------------- ### Cancel Futures Orders Request Example Source: https://www.bitunix.com/api-docs/futures/trade/cancel_orders.html This example demonstrates how to send a POST request to the Bitunix API to cancel futures orders. Ensure you include the correct API key, signature, nonce, timestamp, and content type. The request body should specify the symbol and a list of orders to cancel, identified by orderId or clientId. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/trade/cancel_orders' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"symbol":"BTCUSDT","orderList":[{"orderId":"11111"},{"clientId":"22223"}]}' ``` -------------------------------- ### Place TP/SL Order Request Example (cURL) Source: https://www.bitunix.com/api-docs/futures/tp_sl/place_tp_sl_order.html This example demonstrates how to place a TP/SL order using a cURL command. Ensure you replace placeholder values for API keys, nonce, timestamp, and the request body with your actual data. At least one of `tpPrice` or `slPrice`, and at least one of `tpQty` or `slQty` must be provided. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/tpsl/place_order' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"symbol":"BTCUSDT","positionId":"111","tpPrice":"12","tpStopType":"LAST_PRICE","slPrice":"9","slStopType":"LAST_PRICE","tpOrderType":"LIMIT","tpOrderPrice":"11","slOrderType":"LIMIT","slOrderPrice":"8","tpQty":"1","slQty":"1"}' ``` -------------------------------- ### Place Futures Order Request Example Source: https://www.bitunix.com/api-docs/futures/trade/place_order.html Use this cURL command to send a POST request to the place_order endpoint. Ensure you replace placeholder values for API key, sign, nonce, and timestamp with your actual credentials and current time. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/trade/place_order' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"symbol":"BTCUSDT","side":"BUY","price":"60000","qty":"0.5","positionId":"111","tradeSide":"CLOSE","orderType":"LIMIT","reduceOnly":false,"effect":"GTC","clientId":"1110000aaa","tpPrice":"61000","tpStopType":"MARK","tpOrderType":"LIMIT","tpOrderPrice":"61000.1"}' ``` -------------------------------- ### Subscribe to Kline Data Source: https://www.bitunix.com/api-docs/futures/websocket/public/kline%20channel.html This example demonstrates how to subscribe to a specific kline channel for a given symbol. You can switch k-line intervals by first unsubscribing from the current channel and then subscribing to the new one. ```APIDOC ## Subscribe to Kline Data ### Description Retrieve the candlesticks data of a symbol. Data will be pushed every 500 ms. The channel will push a snapshot after successful subscription, followed by subsequent updates. ### Method WebSocket (using `op` and `args` parameters) ### Parameters #### Request Parameters - **op** (String) - Required - Operation type, e.g., "subscribe" or "unsubscribe". - **args** (List) - Required - A list of channels to subscribe to or unsubscribe from. - **ch** (String) - Required - The channel name. Format: `PriceType_klineTimeInterval`. Supported Price Types: `market`, `mark`. Supported Intervals: `1min`, `3min`, `5min`, `15min`, `30min`, `60min`, `2h`, `4h`, `6h`, `8h`, `12h`, `1day`, `3day`, `1week`, `1month`. - **symbol** (String) - Required - The product ID, e.g., "ETHUSDT". ### Request Example ```json { "op":"subscribe", "args":[ { "symbol":"BTCUSDT", "ch":"market_kline_1min" } ] } ``` ### Response #### Push Data Example ```json { "ch": "market_kline_1min", "symbol": "BTCUSDT", "ts": 1775541412718, "data":{ "o": "68581.4", "c": "68583.4", "h": "68590", "l": "68579.5", "b": "5.2395", "q": "359348.14078" } } ``` ### Push Parameters - **ch** (String) - Channel name. - **symbol** (String) - Product ID, e.g., "ETHUSDT". - **ts** (int64) - Timestamp. - **data** (Object) - Subscription data: - **o** (String) - Opening price. - **h** (String) - Highest price. - **l** (String) - Lowest price. - **c** (String) - Closing price. - **b** (String) - Trading volume of the coin. - **q** (String) - Trading volume of quote currency. ``` -------------------------------- ### Get Futures Kline Data Source: https://www.bitunix.com/api-docs/futures/market/get_kline.html Fetches historical kline data for a specified trading pair. You can filter by start and end times, and specify the kline interval and type. ```APIDOC ## GET /api/v1/futures/market/kline ### Description Interface is used to get future kline history. ### Method GET ### Endpoint /api/v1/futures/market/kline ### Parameters #### Query Parameters - **symbol** (string) - Required - Trading pair, based on the symbolName, i.e. BTCUSDT - **startTime** (int64) - Optional - The start time is to query the k-lines after this time,The millisecond format of the Unix timestamp, such as 1672410780000 - **endTime** (int64) - Optional - The end time is to query the k-lines before this time,The millisecond format of the Unix timestamp, such as 1672410780000 - **interval** (string) - Required - kline interval such as 1m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M - **limit** (int) - Optional - Default: 100, maximum: 200 - **type** (string) - Optional - Kline type, values: LAST_PRICE, MARK_PRICE; default: LAST_PRICE ### Request Example ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/market/kline?symbol=BTCUSDT&startTime=1&endTime=10234&interval=15m' ``` ### Response #### Success Response (200) - **open** (decimal) - open price - **high** (decimal) - high price - **low** (decimal) - low price - **close** (decimal) - close price - **quoteVol** (decimal) - trading amount - **quoteVol** (string) - Trading volume of the coin(last 24 hours) - **baseVol** (string) - Trading volume of the last 24 hours #### Response Example ```json { "code": 0, "data": [ { "open": 60000, "high": 60001, "close": 60000, "low": 59989.2, "time": 111111, "quoteVol": "1", "baseVol": "60000", "type": "LAST_PRICE" } ], "msg": "Success" } ``` ``` -------------------------------- ### Get Funding Rate History Source: https://www.bitunix.com/api-docs/futures/market/get_funding_rate_history.html Fetches the funding rate history for a specified trading pair. You can filter the results by start and end timestamps and set a limit for the number of records returned. ```APIDOC ## GET /api/v1/futures/market/get_funding_rate_history ### Description Get the history funding rate of the contract. ### Method GET ### Endpoint /api/v1/futures/market/get_funding_rate_history ### Parameters #### Query Parameters - **symbol** (string) - Required - Trading pair, based on the symbolName, i.e. BTCUSDT - **starTime** (int64) - Optional - Start timestamp (Funding settle time). Unix timestamp in milliseconds format, e.g. 1597026383085 - **endTime** (int64) - Optional - End timestamp (Funding settle time). Unix timestamp in milliseconds format, e.g. 1597026383085 - **limit** (int32) - Optional - Default: 100, Maximum: 200 ### Request Example ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/market/get_funding_rate_history?symbol=BTCUSDT&limit=10' ``` ### Response #### Success Response (200) - **markPrice** (string) - Mark price - **fundingRate** (string) - Funding rate - **fundingTime** (int64) - Funding timestamp #### Response Example ```json { "code": 0, "data": [ { "fundingRate": "-0.00001191", "fundingTime": "1772449200000", "markPrice": "66286.6" } ], "msg": "Success" } ``` ``` -------------------------------- ### Get History Trades Request Example Source: https://www.bitunix.com/api-docs/futures/trade/get_history_trades.html Use this cURL command to fetch historical trades. Ensure you replace placeholder values for API key, signature, nonce, and timestamp with your actual credentials and current time. ```bash curl -X 'GET' --location 'https://fapi.bitunix.com/api/v1/futures/trade/get_history_trades?symbol=BTCUSDT' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" ``` -------------------------------- ### Change Leverage Request Example (Bash) Source: https://www.bitunix.com/api-docs/futures/account/change_leverage.html Use this cURL command to send a POST request to the change leverage endpoint. Ensure your API key, sign, nonce, and timestamp are correctly set. The request body specifies the trading pair, desired leverage, and margin coin. ```bash curl -X 'POST' --location 'https://fapi.bitunix.com/api/v1/futures/account/change_leverage' \ -H "api-key:*******" \ -H "sign:*" \ -H "nonce:your-nonce" \ -H "timestamp:1659076670000" \ -H "language:en-US" \ -H "Content-Type: application/json" \ --data '{"symbol":"BTCUSDT","leverage":12,"marginCoin":"USDT"}' ``` -------------------------------- ### Funding Rate Response Example Source: https://www.bitunix.com/api-docs/futures/market/get_funding_rate.html This JSON response shows the structure of the data returned when successfully querying the funding rate. It includes details like symbol, prices, funding rate, and settlement information. ```json {"code":0,"data":[{"symbol":"BTCUSDT","markPrice":"60000","lastPrice":"60001","fundingRate":"0.0005","fundingInterval":8,"nextFundingTime":"1770710400000"}],"msg":"Success"} ``` -------------------------------- ### Flash Close Position Response Example Source: https://www.bitunix.com/api-docs/futures/trade/flash_close_position.html This is an example of a successful response when closing a futures position. It confirms the position ID that was closed. ```json {"code":0,"data":{"positionId":"19848247723672"},"msg":"Success"} ``` -------------------------------- ### Transfer Asset Response Example Source: https://www.bitunix.com/api-docs/futures/copyTrading/asset/transfer_asset_from_subaccount_to_main_account.html This is an example of a successful response when transferring assets. The 'code' field indicates success (0), and 'msg' provides a status message. ```json {"code":0,"msg":"result.success","data":"","success":true} ``` -------------------------------- ### History TP/SL Order Response Example Source: https://www.bitunix.com/api-docs/futures/tp_sl/get_history_tp_sl_order.html This is an example of the JSON response structure when successfully retrieving historical TP/SL orders. It includes details about the orders and their associated positions. ```json {"code":0,"data":[{"positionId":"12345678","symbol":"BTCUSDT","qty":"0.5","entryValue":"30000","side":"LONG","positionMode":"HEDGE","marginMode":"ISOLATION","leverage":100,"fee":"0.1","funding":"-0.2","realizedPNL":"102.9","margin":"300","unrealizedPNL":"1.5","liqPrice":"22209","marginRate":"0.01","ctime":1691382137448,"mtime":1691382137448}],"msg":"Success"} ```