> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://okx-demo.ferndocs.com/api/api-reference/grid-trading/get-grid-sub-orders/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server. # Get grid sub orders GET https://www.okx.com/api/v5/tradingBot/grid/sub-orders Retrieve the individual sub-orders (live or filled) placed by a grid algo order. Reference: https://okx-demo.ferndocs.com/api/api-reference/grid-trading/get-grid-sub-orders ## Authentication - `OK-ACCESS-KEY` header (required) — Your API key. - `OK-ACCESS-SIGN` header (required) — Base64-encoded HMAC-SHA256 signature of the prehash string. - `OK-ACCESS-TIMESTAMP` header (required) — ISO 8601 UTC timestamp, e.g. 2020-12-08T09:08:57.715Z. - `OK-ACCESS-PASSPHRASE` header (required) — The passphrase you set when creating the API key. ## Request ### Query parameters - `algoId` (string, required) — Algo ID - `algoOrdType` (enum, required) — Algo order type `grid`: Spot grid `contract_grid`: Contract grid - Allowed values: `grid`, `contract_grid`, `moon_grid` - `type` (enum, required) — Sub order state `live` `filled` - Allowed values: `live`, `filled` - `groupId` (string, optional) — Group ID - `after` (string, optional) — Pagination of data to return records earlier than the requested `ordId`. - `before` (string, optional) — Pagination of data to return records newer than the requested `ordId`. - `limit` (string, optional) — Number of results per request. The maximum is 100. The default is 100 ## Response ### 200 Successful response - `code` (string, optional) — Result code. `0` means success; any other value is an error code. - `msg` (string, optional) — Error message. Empty on success. - `data` (list of ApiV5TradingBotGridSubOrdersGetResponsesContentApplicationJsonSchemaDataItems, optional) ## Types ### ApiV5TradingBotGridSubOrdersGetResponsesContentApplicationJsonSchemaDataItems - `algoId` (string, optional) — Algo ID - `instType` (string, optional) — Instrument type - `instId` (string, optional) — Instrument ID - `algoOrdType` (string, optional) — Algo order type `grid`: Spot grid `contract_grid`: Contract grid - `groupId` (string, optional) — Group ID - `ordId` (string, optional) — Sub order ID - `cTime` (string, optional) — Sub order created time, Unix timestamp format in milliseconds, e.g. `1597026383085` - `uTime` (string, optional) — Sub order updated time, Unix timestamp format in milliseconds, e.g. `1597026383085` - `ordType` (string, optional) — Sub order type `market`: Market order `limit`: Limit order `ioc`: Immediate-or-cancel order - `state` (string, optional) — Sub order state `canceled` `live` `partially_filled` `filled` `cancelling` - `side` (string, optional) — Sub order side `buy` `sell` - `px` (string, optional) — Sub order price - `sz` (string, optional) — Sub order quantity to buy or sell - `accFillSz` (string, optional) — Sub order accumulated fill quantity - `avgPx` (string, optional) — Sub order average filled price - `fee` (string, optional) — Sub order fee amount - `feeCcy` (string, optional) — Sub order fee currency - `pnl` (string, optional) — Sub order profit and loss ## Examples **Response** ```json { "code": "0", "msg": "", "data": [ { "algoId": "448965992920907776", "instType": "SPOT", "instId": "BTC-USDC", "algoOrdType": "grid", "groupId": "3", "ordId": "449109084439187456", "cTime": "1653347949771", "uTime": "1653347949831", "ordType": "limit", "state": "live", "side": "sell", "px": "30404.3", "sz": "0.00059213", "accFillSz": "0", "avgPx": "0", "fee": "0", "feeCcy": "USDC", "pnl": "0", "algoClOrdId": "", "ccy": "", "ctVal": "", "lever": "0", "posSide": "net", "rebate": "0", "rebateCcy": "USDT", "tag": "", "tdMode": "cash" } ] } ``` **SDK Code** ```python gridTrading_getGridSubOrders_example import requests url = "https://www.okx.com/api/v5/tradingBot/grid/sub-orders" querystring = {"algoId":"448965992920907776","algoOrdType":"grid","type":"live"} headers = {"OK-ACCESS-KEY": ""} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` ```javascript gridTrading_getGridSubOrders_example const url = 'https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live'; const options = {method: 'GET', headers: {'OK-ACCESS-KEY': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go gridTrading_getGridSubOrders_example package main import ( "fmt" "net/http" "io" ) func main() { url := "https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("OK-ACCESS-KEY", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby gridTrading_getGridSubOrders_example require 'uri' require 'net/http' url = URI("https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["OK-ACCESS-KEY"] = '' response = http.request(request) puts response.read_body ``` ```java gridTrading_getGridSubOrders_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live") .header("OK-ACCESS-KEY", "") .asString(); ``` ```php gridTrading_getGridSubOrders_example request('GET', 'https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live', [ 'headers' => [ 'OK-ACCESS-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp gridTrading_getGridSubOrders_example using RestSharp; var client = new RestClient("https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live"); var request = new RestRequest(Method.GET); request.AddHeader("OK-ACCESS-KEY", ""); IRestResponse response = client.Execute(request); ``` ```swift gridTrading_getGridSubOrders_example import Foundation let headers = ["OK-ACCESS-KEY": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/tradingBot/grid/sub-orders?algoId=448965992920907776&algoOrdType=grid&type=live")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```