> 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/spread-trading/get-trades/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server. # Get spread trades GET https://www.okx.com/api/v5/sprd/trades Retrieve the recently filled transaction details of spread orders for the last 7 days. Reference: https://okx-demo.ferndocs.com/api/api-reference/spread-trading/get-trades ## 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 - `sprdId` (string, optional) — Spread ID, e.g. BTC-USDT_BTC-USDT-SWAP. - `tradeId` (string, optional) — Trade ID. - `ordId` (string, optional) — Order ID. - `beginId` (string, optional) — Start trade ID the request to begin with. Pagination of data to return records newer than the requested tradeId, not including beginId. - `endId` (string, optional) — End trade ID the request to end with. Pagination of data to return records older than the requested tradeId, not including endId. - `begin` (string, optional) — Filter with a begin timestamp. Unix timestamp in milliseconds. - `end` (string, optional) — Filter with an end timestamp. Unix timestamp in milliseconds. - `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 ApiV5SprdTradesGetResponsesContentApplicationJsonSchemaDataItems, optional) ## Types ### ApiV5SprdTradesGetResponsesContentApplicationJsonSchemaDataItems - `sprdId` (string, optional) — Spread ID. - `tradeId` (string, optional) — Trade ID. - `ordId` (string, optional) — Order ID. - `clOrdId` (string, optional) — Client Order ID as assigned by the client. - `tag` (string, optional) — Order tag. - `fillPx` (string, optional) — Filled price. - `fillSz` (string, optional) — Filled quantity. - `side` (string, optional) — Order side. - `state` (string, optional) — State of the trade. - `execType` (string, optional) — Liquidity taker or maker. T: taker; M: maker. - `ts` (string, optional) — Trade time, Unix timestamp in milliseconds. - `legs` (list of ApiV5SprdTradesGetResponsesContentApplicationJsonSchemaDataItemsLegsItems, optional) — Individual leg fills that compose the spread trade. ### ApiV5SprdTradesGetResponsesContentApplicationJsonSchemaDataItemsLegsItems - `instId` (string, optional) — Instrument ID of the leg. - `px` (string, optional) — Filled price of the leg. - `sz` (string, optional) — Filled quantity of the leg. - `side` (string, optional) — Leg order side. - `fee` (string, optional) — Fee incurred on the leg. - `szCont` (string, optional) — Filled quantity of the leg in contracts, only applicable to contracts. - `feeCcy` (string, optional) — Fee currency of the leg. - `tradeId` (string, optional) — Trade ID of the leg fill. ## Examples **Response** ```json { "code": "0", "msg": "", "data": [ { "sprdId": "BTC-USDT-SWAP_BTC-USDT-200329", "tradeId": "123", "ordId": "123445", "clOrdId": "b16", "tag": "", "fillPx": "999", "fillSz": "3", "side": "buy", "state": "filled", "execType": "M", "ts": "1597026383085", "legs": [ { "instId": "BTC-USDT-SWAP", "px": "20000", "sz": "3", "side": "buy", "fee": "", "szCont": "0.03", "feeCcy": "", "tradeId": "1232342342", "fillPnl": "" }, { "instId": "BTC-USDT-200329", "px": "21000", "sz": "3", "side": "sell", "fee": "", "szCont": "0.03", "feeCcy": "", "tradeId": "5345646634", "fillPnl": "" } ], "code": "", "msg": "" } ] } ``` **SDK Code** ```python spreadTrading_getTrades_example import requests url = "https://www.okx.com/api/v5/sprd/trades" headers = {"OK-ACCESS-KEY": ""} response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript spreadTrading_getTrades_example const url = 'https://www.okx.com/api/v5/sprd/trades'; 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 spreadTrading_getTrades_example package main import ( "fmt" "net/http" "io" ) func main() { url := "https://www.okx.com/api/v5/sprd/trades" 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 spreadTrading_getTrades_example require 'uri' require 'net/http' url = URI("https://www.okx.com/api/v5/sprd/trades") 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 spreadTrading_getTrades_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://www.okx.com/api/v5/sprd/trades") .header("OK-ACCESS-KEY", "") .asString(); ``` ```php spreadTrading_getTrades_example request('GET', 'https://www.okx.com/api/v5/sprd/trades', [ 'headers' => [ 'OK-ACCESS-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp spreadTrading_getTrades_example using RestSharp; var client = new RestClient("https://www.okx.com/api/v5/sprd/trades"); var request = new RestRequest(Method.GET); request.AddHeader("OK-ACCESS-KEY", ""); IRestResponse response = client.Execute(request); ``` ```swift spreadTrading_getTrades_example import Foundation let headers = ["OK-ACCESS-KEY": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/sprd/trades")! 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() ```