> This page is for API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://okx-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server.

# Get order details

GET https://www.okx.com/api/v5/trade/order

Retrieve order details.

Reference: https://okx-demo.ferndocs.com/api/api-reference/trade/get-order

## 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

- `instId` (string, required) — Instrument ID, e.g. `BTC-USDT` Only applicable to live instruments
- `ordId` (string, optional) — Order ID Either `ordId` or `clOrdId` is required, if both are passed, `ordId` will be used
- `clOrdId` (string, optional) — Client Order ID as assigned by the client If the `clOrdId` is associated with multiple orders, only the latest one will be returned.

## 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 ApiV5TradeOrderGetResponsesContentApplicationJsonSchemaDataItems, optional)

## Types

### ApiV5TradeOrderGetResponsesContentApplicationJsonSchemaDataItems

- `instType` (string, optional) — Instrument type `SPOT` `MARGIN` `SWAP` `FUTURES` `OPTION` `EVENTS`
- `instId` (string, optional) — Instrument ID
- `ccy` (string, optional) — Margin currency Applicable to all `isolated` `MARGIN` orders and `cross` `MARGIN` orders in `Futures mode`, `FUTURES` and `SWAP` contracts.
- `ordId` (string, optional) — Order ID
- `clOrdId` (string, optional) — Client Order ID as assigned by the client
- `tag` (string, optional) — Order tag
- `px` (string, optional) — Price For options, use coin as unit (e.g. BTC, ETH)
- `sz` (string, optional) — Quantity to buy or sell
- `ordType` (string, optional) — Order type `market`: Market order `limit`: Limit order `post_only`: Post-only order `fok`: Fill-or-kill order `ioc`: Immediate-or-cancel order `optimal_limit_ioc`: Market order with immediate-or-cancel order `mmp`: Market Maker Protection (only applicable to Option in Portfolio Margin mode) `mmp_and_post_only`: Market Maker Protection and Post-only order(only applicable to Option in Portfolio Margin mode) `op_fok`: Simple options (fok) `rpi`: Retail Price Improvement order `elp`: Enhanced Liquidity Program order (Deprecated; use `rpi`. Accepted until October 31, 2026.)
- `side` (string, optional) — Order side
- `posSide` (string, optional) — Position side
- `tdMode` (string, optional) — Trade mode
- `accFillSz` (string, optional) — Running total of filled quantity since order creation. In WebSocket order channel push events, `accFillSz` always represents the cumulative total, not the increment since the last push. The unit is `base_ccy` for SPOT and MARGIN, e.g. BTC-USDT, the unit is BTC; The unit is contract for `FUTURES`/`SWAP`/`OPTION`
- `avgPx` (string, optional) — Average filled price. If none is filled, it will return "".
- `state` (string, optional) — Order state: `live`: on the order book, no fills yet. `partially_filled`: partially executed, still active on book. `filled`: fully executed, terminal state. `canceled`: cancelled, terminal state. For IOC orders partially filled before cancellation, `accFillSz` may be non-zero. `mmp_canceled`: automatically cancelled by Market Maker Protection, terminal state. Note: GET /api/v5/trade/orders-pending only returns `live` and `partially_filled`; GET /api/v5/trade/orders-history returns `filled`, `canceled`, and `mmp_canceled`.
- `lever` (string, optional) — Leverage, from `0.01` to `125`. Only applicable to `MARGIN/FUTURES/SWAP`
- `fee` (string, optional) — Fee amount. Sign convention: negative = net fee paid to platform; positive = net rebate received from platform. The net amount reflects fee minus rebate. For Spot and Margin (excluding maker sell orders): accumulated fee charged by the platform, always negative. For maker sell orders in Spot and Margin, Expiry Futures, Perpetual Futures and Options: accumulated fee and rebate (always in quote currency for maker sell orders in Spot and Margin). For split accounting, use `feeCcy` + `fee` together with `rebateCcy` + `rebate`. `feeCcy` and `rebateCcy` may differ.
- `feeCcy` (string, optional) — Fee currency For maker sell orders of Spot and Margin, this represents the quote currency. For all other cases, it represents the currency in which fees are charged.
- `pnl` (string, optional) — Profit and loss (excluding the fee). Applicable to orders which have a trade and aim to close position. It always is 0 in other conditions
- `uTime` (string, optional) — Update time, Unix timestamp format in milliseconds, e.g. `1597026383085`
- `cTime` (string, optional) — Creation time, Unix timestamp format in milliseconds, e.g. `1597026383085`

## Examples

**Response**

```json
{
  "code": "0",
  "msg": "",
  "data": [
    {
      "instType": "SPOT",
      "instId": "BTC-USDT",
      "ccy": "",
      "ordId": "680800019749904384",
      "clOrdId": "",
      "tag": "",
      "px": "",
      "sz": "100",
      "ordType": "market",
      "side": "buy",
      "posSide": "net",
      "tdMode": "cash",
      "accFillSz": "0.00192834",
      "avgPx": "51858",
      "state": "filled",
      "lever": "",
      "fee": "-0.00000192834",
      "feeCcy": "BTC",
      "pnl": "0",
      "uTime": "1708587373362",
      "cTime": "1708587373361",
      "algoClOrdId": "",
      "algoId": "",
      "attachAlgoClOrdId": "",
      "attachAlgoOrds": [],
      "cancelSource": "",
      "cancelSourceReason": "",
      "category": "normal",
      "fillPx": "51858",
      "fillSz": "0.00192834",
      "fillTime": "1708587373361",
      "isTpLimit": "false",
      "linkedAlgoOrd": {
        "algoId": ""
      },
      "pxType": "",
      "pxUsd": "",
      "pxVol": "",
      "quickMgnType": "",
      "rebate": "0",
      "rebateCcy": "USDT",
      "reduceOnly": "false",
      "slOrdPx": "",
      "slTriggerPx": "",
      "slTriggerPxType": "",
      "source": "",
      "stpId": "",
      "stpMode": "",
      "tgtCcy": "quote_ccy",
      "tpOrdPx": "",
      "tpTriggerPx": "",
      "tpTriggerPxType": "",
      "tradeId": "744876980",
      "tradeQuoteCcy": "USDT"
    }
  ]
}
```

**SDK Code**

```python trade_getOrder_example
import requests

url = "https://www.okx.com/api/v5/trade/order"

querystring = {"instId":"BTC-USDT"}

headers = {"OK-ACCESS-KEY": "<apiKey>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript trade_getOrder_example
const url = 'https://www.okx.com/api/v5/trade/order?instId=BTC-USDT';
const options = {method: 'GET', headers: {'OK-ACCESS-KEY': '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go trade_getOrder_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://www.okx.com/api/v5/trade/order?instId=BTC-USDT"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("OK-ACCESS-KEY", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby trade_getOrder_example
require 'uri'
require 'net/http'

url = URI("https://www.okx.com/api/v5/trade/order?instId=BTC-USDT")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["OK-ACCESS-KEY"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java trade_getOrder_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://www.okx.com/api/v5/trade/order?instId=BTC-USDT")
  .header("OK-ACCESS-KEY", "<apiKey>")
  .asString();
```

```php trade_getOrder_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://www.okx.com/api/v5/trade/order?instId=BTC-USDT', [
  'headers' => [
    'OK-ACCESS-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp trade_getOrder_example
using RestSharp;

var client = new RestClient("https://www.okx.com/api/v5/trade/order?instId=BTC-USDT");
var request = new RestRequest(Method.GET);
request.AddHeader("OK-ACCESS-KEY", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift trade_getOrder_example
import Foundation

let headers = ["OK-ACCESS-KEY": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/trade/order?instId=BTC-USDT")! 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()
```