### GET Order Detail Request Example Source: https://docs.blofin.com/index.html This example demonstrates how to make a GET request to retrieve order details. Ensure you provide either orderId, clientOrderId, or algoClientOrderId. ```http GET /api/v1/trade/order-detail body { "instId": "ETH-USDT", "orderId": "29531103" } ``` -------------------------------- ### GET Currencies Request Example Source: https://docs.blofin.com/index.html This is an example of a GET request to retrieve currency information. ```http GET /api/v1/asset/currencies ``` -------------------------------- ### GET Request Example for Positions by Contract Source: https://docs.blofin.com/index.html This is an example of an HTTP GET request to retrieve position details for a specific contract. ```http GET /api/v1/copytrading/account/positions-by-contract ``` -------------------------------- ### GET Position Mode Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve the user's current position mode settings. ```http GET /api/v1/account/position-mode ``` -------------------------------- ### GET Margin Mode Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve the current margin mode settings. ```http GET /api/v1/account/margin-mode ``` -------------------------------- ### Get Account Config Response Example Source: https://docs.blofin.com/index.html This example shows the response structure for retrieving account configuration, including the account level. ```json { "code": "0", "msg": "success", "data": { "accountLevel": "0" } } ``` -------------------------------- ### Get Funding Rate Example Source: https://docs.blofin.com/index.html Example response for retrieving funding rates. Ensure 'instId' is provided. ```json { "code": "0", "msg": "success", "data": [ { "instId": "BTC-USDT", "fundingRate": "0.000335", "fundingTime": "1703462400000" } ] } ``` -------------------------------- ### GET Positions Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve position information by order. This endpoint is used to fetch details about open positions. ```http GET /api/v1/copytrading/account/positions-by-order ``` -------------------------------- ### GET Order Book HTTP Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve the order book for a specific instrument. ```http GET /api/v1/market/books?instId=BTC-USDT ``` -------------------------------- ### GET Sub Invitees Request Example Source: https://docs.blofin.com/index.html This is an example of an HTTP GET request to retrieve sub-affiliate information. It shows the endpoint path for the API call. ```http GET /api/v1/affiliate/sub-invitees ``` -------------------------------- ### GET Currencies Response Example Source: https://docs.blofin.com/index.html This example shows the response structure for retrieving currency information, including deposit and withdrawal details. ```json { "code": "0", "msg": "success", "data": [ { "currency": "USDT", "chain": "TRC20", "depositMinAmount": "1", "depositUnsafeConfirmation": 1, "depositConfirmation": 20, "withdrawMinAmount": "10", "withdrawFee": "1", "withdrawPrecision": 8, "supportMemo": 0, "isDepositAvailable": 1, "isWithdrawAvailable": 1, "recoveryEtaDeposit": 0, "recoveryEtaWithdraw": 0, "logo": "https://example.com/usdt.png" } ] } ``` -------------------------------- ### GET Sub Affiliates API Request Example Source: https://docs.blofin.com/index.html This is an example of an HTTP GET request to the sub-affiliates endpoint. It can be used to retrieve information about sub-affiliates. ```http GET /api/v1/affiliate/sub-affiliates ``` -------------------------------- ### GET Margin Mode Response Example Source: https://docs.blofin.com/index.html Example JSON response when fetching margin mode. Indicates the currently active margin mode. ```json { "code": "0", "msg": "success", "data": { "marginMode": "isolated" } } ``` -------------------------------- ### GET Spot Trade History Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve spot trade history. Ensure the instType parameter is set to SPOT. ```http GET /api/v1/spot/trade/fills-history?instType=SPOT ``` -------------------------------- ### Get Funding Rate Response Example Source: https://docs.blofin.com/index.html Example response for the GET Funding Rate endpoint, showing the instrument ID, current funding rate, and the settlement time. ```json { "code": "0", "msg": "success", "data": [ { "instId": "BTC-USDT", "fundingRate": "0.000332", "fundingTime": "1703462400000" } ] } ``` -------------------------------- ### Response Example for Get Leverage Source: https://docs.blofin.com/index.html This response provides details about the leverage, margin mode, and instrument ID after a successful leverage information query. ```json { "code": "0", "msg": "success", "data": { "leverage": "3", "marginMode": "cross", "instId": "BCH-USDT" } } ``` -------------------------------- ### Get Mark Price Response Example Source: https://docs.blofin.com/index.html Example response for the GET Mark Price endpoint, including instrument ID, index price, mark price, and timestamp. ```json { "code": "0", "msg": "success", "data": [ { "instId": "ETH-USDT", "indexPrice": "1620.78", "markPrice": "1620.58", "ts": "1695262570838" } ] } ``` -------------------------------- ### Get Instrument Details Response Example Source: https://docs.blofin.com/index.html Example response for retrieving instrument details. This includes information like contract value, minimum order size, and listing time. ```json { "code": "0", "msg": "success", "data": [ { "instId": "BTC-USDT", "baseCurrency": "BTC", "quoteCurrency": "USDT", "contractValue": "0.001", "listTime": "1638333031000", "expireTime": "1704124800000", "maxLeverage": "125", "minSize": "0.1", "lotSize": "0.1", "tickSize": "0.5", "instType": "SWAP", "contractType": "linear", "maxLimitSize": "100000000", "maxMarketSize": "1000000", "state": "live", "settleCurrency": "USDT" } ] } ``` -------------------------------- ### GET Algo Order History Request Example Source: https://docs.blofin.com/index.html This is an example of a GET request to retrieve the history of algo orders. Ensure the `orderType` parameter is set to `trigger`. ```http GET /api/v1/trade/orders-algo-history ``` -------------------------------- ### Get Trades Response Example Source: https://docs.blofin.com/index.html Example response for the GET Trades endpoint, showing trade details like ID, instrument, price, size, side, and timestamp. ```json { "code": "0", "msg": "success", "data": [ { "tradeId": "124892894", "instId": "ETH-USDT", "price": "1620.11", "size": "34", "side": "sell", "ts": "1695262343171" } ] } ``` -------------------------------- ### GET Positions Response Example Source: https://docs.blofin.com/index.html Example JSON response for the GET Positions endpoint. It includes details such as order ID, instrument ID, margin mode, leverage, and profit/loss. ```json { "code": "0", "msg": "succeed", "data": [ { "orderId": "254098", "instId": "GMT-USDT", "marginMode": "cross", "positionSide": "net", "leverage": "3", "positions": "825", "availablePositions": "825", "averagePrice": "1.212", "markPrice": "1.21", "realizedPnl": "0", "unrealizedPnl": "-1.65", "unrealizedPnlRatio": "-0.004868571595271319", "createTime": "1733472937600", "updateTime": "1733472937712" } ] } ``` -------------------------------- ### GET Tickers HTTP Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve the latest price snapshot, best bid/ask price, and trading volume for a specific instrument. ```http GET /api/v1/market/tickers?instId=BTC-USDT ``` -------------------------------- ### Get Multiple Leverage Request Example Source: https://docs.blofin.com/index.html Fetch leverage details for multiple instruments simultaneously. Provide a comma-separated list of 'instId' values (up to 20) and the 'marginMode'. ```http GET /api/v1/account/batch-leverage-info?instId=BTC-USDT,ETH-USDT&marginMode=cross ``` -------------------------------- ### GET Positions Request Example Source: https://docs.blofin.com/index.html This endpoint retrieves information about your open positions. You can filter by `instId` to get details for a specific instrument. ```http GET /api/v1/account/positions?instId=BTC-USDT ``` -------------------------------- ### Get Deposit History Response Example Source: https://docs.blofin.com/index.html This is an example response for retrieving deposit history. It includes details such as currency, chain, address, transaction ID, amount, state, and timestamp. ```json { "code": "0", "msg": "success", "data": [ { "currency": "USDT", "chain": "TRC20", "address": "EXAMPLE_WALLET_ADDRESS", "txId": "h9e69f5133c4f49f5d869d7ef6e11e0f9f5f81cd3456789012def345678901", "type": "0", "amount": "9", "state": "1", "ts": "1597026383085", "confirm": "12", "depositId": "c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8" }, { "currency": "USDT", "chain": "TRC20", "address": "EXAMPLE_WALLET_ADDRESS", "txId": "i0f70f6244d5f50f6e970e8ef7f22f1f0f6f92de456789012def3456789012", "type": "0", "amount": "9", "state": "1", "ts": "1597026383085", "confirm": "12", "depositId": "d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9" } ] } ``` -------------------------------- ### Get Position Tiers Response Example Source: https://docs.blofin.com/index.html Example JSON response for position tier data, including symbol, margin mode, minimum and maximum position size, maintenance margin rate, and maximum leverage. ```json { "code": "0", "msg": "success", "data": [ { "symbol": "BTC-USDT", "marginMode": "cross", "minSize": "0.01", "maxSize": "150", "maintenanceMarginRate": "0.004", "maxLeverage": "125" } ] } ``` -------------------------------- ### GET Order Detail Response Example Source: https://docs.blofin.com/index.html This is a successful response for the order detail request. It includes comprehensive information about the order, such as filled size, average price, and fees. ```json { "code": "0", "msg": "success", "data": { "orderId": "29531103", "clientOrderId": "", "instId": "ETH-USDT", "marginMode": "isolated", "positionSide": "net", "side": "buy", "orderType": "limit", "price": "1514.150000000000000000", "size": "1.000000000000000000", "reduceOnly": "false", "leverage": "3", "state": "live", "filledSize": "0.000000000000000000", "filled_amount": "0.000000000000000000", "averagePrice": "0.000000000000000000", "fee": "0.000000000000000000", "pnl": "0.000000000000000000", "createTime": "1697031292762", "updateTime": "1697031292788", "orderCategory": "normal", "tpTriggerPrice": "1688.000000000000000000", "slTriggerPrice": "1299.000000000000000000", "slOrderPrice": null, "tpOrderPrice": null, "algoClientOrderId": "aaa", "algoId": "11756185", "brokerId": "" } } ``` -------------------------------- ### GET Active TPSL (By Order) Response Example Source: https://docs.blofin.com/index.html This is an example of the response structure when retrieving active TPSL orders. It includes details like order ID, instrument, margin mode, position side, trigger prices, size, state, leverage, and creation time. ```json { "code": "0", "msg": "succeed", "data": [ { "orderId": "253085", "instId": "BTC-USDT", "marginMode": "cross", "positionSide": "NET", "tpTriggerPrice": "102761.4", "tpOrderPrice": "-1", "slTriggerPrice": "75281.40000000001", "slOrderPrice": "-1", "size": "0.0977", "state": "effective", "leverage": "1", "createTime": "1733467498988" } ] } ``` -------------------------------- ### Complete Trading Workflow Example (Python) Source: https://docs.blofin.com/index.html Demonstrates a full trading workflow: fetching market data, connecting to WebSocket, placing a limit order, and listening for confirmations. Replace placeholder credentials with your actual API keys. ```python async def trading_example(): """Complete trading workflow example.""" try: # Example credentials (replace with your own) api_key = "YOUR_API_KEY" secret = "YOUR_SECRET" passphrase = "YOUR_PASSPHRASE" # 1. Get order book price response = requests.get( "https://openapi.blofin.com/api/v1/market/books", params={"instId": "BTC-USDT", "size": "1"} ) response.raise_for_status() best_ask = float(response.json()["data"][0]["asks"][0][0]) # Note: data[0] for first order book entry limit_price = round(best_ask * 0.9, 1) # 10% below market, rounded to 0.1 print(f"Best ask: {best_ask}, Limit price: {limit_price}") # 2. Connect to WebSocket and authenticate ws = await websockets.connect("wss://openapi.blofin.com/ws/private") sign, timestamp, nonce = await sign_websocket_login(secret, api_key, passphrase) # Login await ws.send(json.dumps({ "op": "login", "args": [{ "apiKey": api_key, "passphrase": passphrase, "timestamp": timestamp, "sign": sign, "nonce": nonce }] })) await asyncio.sleep(1) # Subscribe to orders channel await ws.send(json.dumps({ "op": "subscribe", "args": [{"channel": "orders", "instId": "BTC-USDT"}] })) # 3. Place limit buy order order_request = { "instId": "BTC-USDT", "marginMode": "cross", "side": "buy", "orderType": "limit", "price": str(limit_price), "size": "0.1", # See /api/v1/market/instruments for contract sizes "leverage": "3", "positionSide": "net" } # order_request["brokerId"] = "your broker id" #if needed # Generate signature for REST API timestamp = str(int(time.time() * 1000)) nonce = timestamp # Use timestamp as nonce for consistency path = "/api/v1/trade/order" method = "POST" msg = f"{path}{method}{timestamp}{nonce}{json.dumps(order_request)}" hex_signature = hmac.new( secret.encode('utf-8'), msg.encode('utf-8'), hashlib.sha256 ).hexdigest().encode('utf-8') signature = base64.b64encode(hex_signature).decode() # Prepare headers with broker ID headers = { "ACCESS-KEY": api_key, "ACCESS-SIGN": signature, "ACCESS-TIMESTAMP": timestamp, "ACCESS-NONCE": nonce, "ACCESS-PASSPHRASE": passphrase, "Content-Type": "application/json" } # Place order response = requests.post( "https://openapi.blofin.com/api/v1/trade/order", headers=headers, json=order_request ) response.raise_for_status() order_response = response.json() # Verify response format and success if not isinstance(order_response, dict): raise Exception(f"Invalid order response format: {order_response}") if "code" in order_response and order_response["code"] != "0": raise Exception(f"Order API error: {order_response}") if "data" not in order_response: raise Exception(f"No data in order response: {order_response}") order_id = order_response["data"][0]["orderId"] print(f"Order placed: {order_id}") # 4. Wait for order confirmation async def listen_for_confirmation(): while True: data = json.loads(await ws.recv()) if data.get("action") == "update": for order in data.get("data", []): ``` -------------------------------- ### Request Demo Trading Funds Example Source: https://docs.blofin.com/index.html This example demonstrates how to request demo trading funds. It specifies the currency and amount to be applied. ```json POST /api/v1/asset/demo-apply-money body { "adjustType": 0, "demoApplyMoney": [ { "currency": "USDT", "amountStr": "109" } ] } ``` -------------------------------- ### Place Multiple Orders Request Example Source: https://docs.blofin.com/index.html This example demonstrates how to structure a request to place multiple orders simultaneously. Ensure all required parameters for each order are correctly specified. ```json [ { "instId": "ETH-USDT", "marginMode": "cross", "positionSide": "net", "side": "buy", "orderType": "limit", "price": "1601.1", "size": "1", "reduceOnly": "false", "clientOrderId": "eeeeee11223112", "tpTriggerPrice": "", "tpOrderPrice": "", "slTriggerPrice": "", "slOrderPrice": "" }, { "instId": "ETH-USDT", "marginMode": "cross", "positionSide": "net", "side": "buy", "orderType": "limit", "price": "1602.1", "size": "2", "reduceOnly": "false", "clientOrderId": "eeeeee1122321", "tpTriggerPrice": "", "tpOrderPrice": "", "slTriggerPrice": "", "slOrderPrice": "" } ] ``` -------------------------------- ### GET Positions History Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve historical positions, specifying the instrument ID. ```http GET /api/v1/account/positions-history?instId=BTC-USDT ``` -------------------------------- ### Response Example for Set Leverage Source: https://docs.blofin.com/index.html This response confirms the successful setting of leverage, returning the instrument ID, leverage amount, margin mode, and position side that were applied. ```json { "code": "0", "msg": "success", "data": { "leverage": "100", "marginMode": "cross", "instId": "BTC-USDT", "positionSide":"long" } } ``` -------------------------------- ### Response Example for Copy Trading Configuration Source: https://docs.blofin.com/index.html Example JSON response for the copy trading configuration endpoint, showing user's nickname and role. ```json { "code": "0", "msg": "success", "data": { "nickName": "BloFin_e2dd2d32f", "roleType": "1" } } ``` -------------------------------- ### Place Algo Order Request Example Source: https://docs.blofin.com/index.html Example of an HTTP POST request to the /api/v1/trade/order-algo endpoint. This demonstrates how to structure the request body for placing an algorithmic order, including take-profit and stop-loss parameters. ```http POST /api/v1/trade/order-algo body { "instId": "ETH-USDT", "marginMode": "cross", "positionSide": "short", "side": "sell", "size": "1", "clientOrderId":"" "orderPrice": "-1", "orderType": "trigger", "triggerPrice": "3000", "triggerPriceType": "last", "brokerId": "", "attachAlgoOrders": [{ "tpTriggerPrice":"3500", "tpOrderPrice":"3600", "tpTriggerPriceType":"last", "slTriggerPrice":"2600", "slOrderPrice":"2500", "slTriggerPriceType":"last" }] } ``` -------------------------------- ### GET Position Tiers Request Example Source: https://docs.blofin.com/index.html Example HTTP GET request to retrieve position tier data for a specific instrument and margin mode. ```http GET /api/v1/market/position-tiers?instId=BTC-USDT&marginMode=cross ``` -------------------------------- ### Response Example for Inverse Account Subscription Source: https://docs.blofin.com/index.html This is a successful response example after subscribing to the inverse account channel. It confirms the subscription with the specified channel. ```json { "event": "subscribe", "arg": { "channel": "inverse-account" } } ``` -------------------------------- ### Place TPSL Order Request Example Source: https://docs.blofin.com/index.html This example demonstrates the structure of a request to place a Take-Profit/Stop-Loss (TPSL) order. Ensure all required parameters like instrument ID, margin mode, position side, side, size, and relevant trigger/order prices are correctly populated. ```json { "instId": "ETH-USDT", "marginMode": "cross", "positionSide": "short", "side": "sell", "tpTriggerPrice": "1661.1", "tpOrderPrice": "", "slTriggerPrice": "", "slOrderPrice": "", "size": "1", "reduceOnly": "true", "clientOrderId": "" } ``` -------------------------------- ### GET Deposit History Request Example Source: https://docs.blofin.com/index.html This is an example of an HTTP GET request to retrieve deposit history. It specifies the API endpoint for fetching deposit records. ```http GET /api/v1/asset/deposit-history ``` -------------------------------- ### Place Order Request Example Source: https://docs.blofin.com/index.html Submit a trade order with specified instrument, margin mode, position side, side, price, and size. Ensure all required parameters are accurately provided. ```json { "instId":"BTC-USDT", "marginMode":"cross", "positionSide":"long", "side":"sell", "price":"23212.2", "size":"2" } ``` -------------------------------- ### GET Balance REST API Request Example Source: https://docs.blofin.com/index.html Example HTTP GET request to retrieve balances for a specific account type. The `accountType` parameter is required. ```http GET /api/v1/asset/balances?accountType=funding ``` -------------------------------- ### Get Tickers Response Example Source: https://docs.blofin.com/index.html Example response for the GET /api/v1/market/tickers endpoint. It includes the last traded price, bid/ask information, and 24-hour trading volume. ```json { "code": "0", "msg": "success", "data": [ { "instId": "BTC-USDT", "last": "27187", "lastSize": "1", "askPrice": "27187.5", "askSize": "20", "bidPrice": "27187", "bidSize": "2", "high24h": "27463.5", "open24h": "27186.5", "low24h": "26647.5", "volCurrency24h": "3224.82", "vol24h": "3224820", "ts": "1695261862487" } ] } ``` -------------------------------- ### WebSocket Positions Channel Response Example (All Instruments) Source: https://docs.blofin.com/index.html Example of a successful subscription response for the positions channel when subscribing to all instruments. This confirms the channel for which data will be pushed. ```json { "event": "subscribe", "arg": { "channel": "positions" } } ``` -------------------------------- ### Trigger Order Request Example Source: https://docs.blofin.com/index.html Example of a POST request to place a trigger order. Ensure all required parameters like instId, marginMode, positionSide, side, size, orderType, and triggerPrice are correctly provided. ```json { "code": "0", "msg": "success", "data": { "algoId": "1012", "clientOrderId": null, "code": "0", "msg": null } } ``` -------------------------------- ### Response Example for Daily Commission Source: https://docs.blofin.com/index.html Example JSON response for the daily commission endpoint, showing invitee details, commission, and trading data. ```json { "code": "0", "msg": "success", "data": [ { "uid": "30292758476", "commission": "0.032035434", "commissionTime": "1716912000000", "cashback": "0.288318906", "fee": "3.2035434", "kycLevel": "0", "tradingVolume": "200" } ] } ``` -------------------------------- ### Order Response Example Source: https://docs.blofin.com/index.html This is an example of a successful response when retrieving order data. It includes details for multiple orders, such as order ID, instrument, type, and state. ```json { "code": "0", "msg": "success", "data": [ { "orderId": "29531103", "clientOrderId": "", "instId": "ETH-USDT", "marginMode": "isolated", "positionSide": "net", "side": "buy", "orderType": "limit", "price": "1514.150000000000000000", "size": "1.000000000000000000", "reduceOnly": "false", "leverage": "3", "state": "live", "filledSize": "0.000000000000000000", "filled_amount": "0.000000000000000000", "averagePrice": "0.000000000000000000", "fee": "0.000000000000000000", "pnl": "0.000000000000000000", "createTime": "1697031292762", "updateTime": "1697031292788", "orderCategory": "normal", "tpTriggerPrice": "1688.000000000000000000", "slTriggerPrice": "1299.000000000000000000", "slOrderPrice": null, "tpOrderPrice": null, "algoClientOrderId": "aaa", "algoId": "11756185", "brokerId": "" }, { "orderId": "29530845", "clientOrderId": "", "instId": "ETH-USDT", "marginMode": "isolated", "positionSide": "net", "side": "buy", "orderType": "limit", "price": "1554.150000000000000000", "size": "2.000000000000000000", "reduceOnly": "false", "leverage": "3", "state": "live", "filledSize": "0.000000000000000000", "filled_amount": "0.000000000000000000", "averagePrice": "0.000000000000000000", "fee": "0.000000000000000000", "pnl": "0.000000000000000000", "createTime": "1697031251410", "updateTime": "1697031251430", "orderCategory": "normal", "tpTriggerPrice": null, "slTriggerPrice": null, "slOrderPrice": null, "tpOrderPrice": null, "algoClientOrderId": "", "algoId": "", "brokerId": "" } ] } ``` -------------------------------- ### GET Position Close Details Request Example Source: https://docs.blofin.com/index.html Example of an HTTP GET request to retrieve the close history of positions by order. This endpoint is useful for auditing or reviewing closed trades. ```http GET /api/v1/copytrading/account/positions-details-by-order ``` -------------------------------- ### Response Example for Copy Trading Account Balance Source: https://docs.blofin.com/index.html Example JSON response for the copy trading account balance endpoint, detailing asset balances, equity, and available amounts. ```json { "code": "0", "msg": "success", "data": { "ts": "1697021343571", "totalEquity": "10011254.077985990315787910", "isolatedEquity": "861.763132108800000000", "details": [{ "currency": "USDT", "equity": "10014042.988958415234430699548", "balance": "10013119.885958415234430699", "ts": "1697021343571", "isolatedEquity": "862.003200000000000000048", "available": "9996399.4708691159703362725", "availableEquity": "9996399.4708691159703362725", "frozen": "15805.149672632597427761", "orderFrozen": "14920.994472632597427761", "equityUsd": "10011254.077985990315787910", "isolatedUnrealizedPnl": "-22.151999999999999999952", "bonus": "0" }] } } ``` -------------------------------- ### GET Balance REST API Response Example Source: https://docs.blofin.com/index.html Example JSON response for the GET Balance API request. It includes details on currency, total balance, available balance, and frozen balance. ```json { "code": "0", "msg": "success", "data": [ { "currency": "USDT", "balance": "10012514.919418081548717298", "available": "9872132.414278782284622898", "frozen": "138556.471805965930761067", "bonus": "0" } ] } ``` -------------------------------- ### Response Example for Get Multiple Leverage Source: https://docs.blofin.com/index.html A successful response for fetching multiple leverage details includes an array of objects, each containing leverage, margin mode, instrument ID, and position side for different instruments. ```json { "code": "0", "msg": "success", "data": [ { "leverage": "50", "marginMode": "cross", "instId": "BTC-USDT", "positionSide":"net" }, { "leverage": "3", "marginMode": "cross", "instId": "ETH-USDT", "positionSide":"net" } ] } ``` -------------------------------- ### GET Trade Order Price Range Request Example Source: https://docs.blofin.com/index.html This endpoint is used to query the price limit range for trades. No specific parameters are shown in the example, suggesting it might be a simple GET request. ```http GET /api/v1/trade/order/price-range ``` -------------------------------- ### GET Candlesticks Request Example Source: https://docs.blofin.com/index.html Example HTTP request for retrieving candlestick data. 'instId' is a required parameter. ```http GET /api/v1/market/candles?instId=BTC-USDT ``` -------------------------------- ### REST Authentication - GET Request Signature Source: https://docs.blofin.com/index.html Example of how to generate the ACCESS-SIGN header for GET requests using Python and JavaScript. ```APIDOC ## REST Authentication - GET Request Signature ### Description This section details how to construct the `ACCESS-SIGN` header for GET requests to the BloFin API. It involves creating a prehash string from the request path, method, timestamp, nonce, and an empty body, then generating an HMAC-SHA256 signature and encoding it in Base64. ### Method GET ### Endpoint Example: `/api/v1/asset/balances?accountType=futures` ### Parameters #### Headers - **ACCESS-KEY** (String) - Your API Key. - **ACCESS-SIGN** (String) - The Base64-encoded signature. - **ACCESS-TIMESTAMP** (String) - The UTC timestamp of your request in milliseconds. - **ACCESS-NONCE** (String) - A unique identifier for the request. - **ACCESS-PASSPHRASE** (String) - The passphrase specified during API Key creation. ### Request Example (Python) ```python import hmac import hashlib import base64 from datetime import datetime from uuid import uuid4 secret_key = "YOUR_SECRET_KEY" path = "/api/v1/asset/balances?accountType=futures" method = "GET" timestamp = str(int(datetime.now().timestamp() * 1000)) nonce = str(uuid4()) body = "" # Empty for GET requests prehash = f"{path}{method}{timestamp}{nonce}{body}" hex_signature = hmac.new( secret_key.encode(), prehash.encode(), hashlib.sha256 ).hexdigest().encode() signature = base64.b64encode(hex_signature).decode() print(f"ACCESS-KEY: YOUR_API_KEY") print(f"ACCESS-SIGN: {signature}") print(f"ACCESS-TIMESTAMP: {timestamp}") print(f"ACCESS-NONCE: {nonce}") print(f"ACCESS-PASSPHRASE: YOUR_PASSPHRASE") ``` ### Request Example (JavaScript) ```javascript // Assuming timestamp and nonce are already generated and available const secretKey = 'YOUR_SECRET_KEY'; const path = '/api/v1/asset/balances?accountType=futures'; const method = 'GET'; const body = ''; // Empty for GET requests const prehash = path + method + timestamp + nonce + body; const hexSignature = CryptoJS.HmacSHA256(prehash, secretKey).toString(); const signature = CryptoJS.enc.Base64.stringify( CryptoJS.enc.Utf8.parse(hexSignature) ); console.log('ACCESS-KEY:', 'YOUR_API_KEY'); console.log('ACCESS-SIGN:', signature); console.log('ACCESS-TIMESTAMP:', timestamp); console.log('ACCESS-NONCE:', nonce); console.log('ACCESS-PASSPHRASE:', 'YOUR_PASSPHRASE'); ``` ``` -------------------------------- ### Response Example for Set Position Mode Source: https://docs.blofin.com/index.html This is a typical success response when setting the position mode. It confirms the operation and returns the updated 'positionMode'. ```json { "code": "0", "msg": "success", "data": { "positionMode": "net_mode" } } ```