> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qfex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取单笔订单

可通过 `order_id` 查询已认证账户的一笔指定订单。

## 请求示例

```json theme={null}
{
  "type": "get_order",
  "params": {
    "symbol": "US500-USD",
    "order_id": "57cc1941-8ad1-4df3-b34c-bb556518befc"
  }
}
```

* `symbol`（必填）：订单对应的交易品种。
* `order_id`（必填）：要查询的订单 ID。

## 示例代码

```python python theme={null}
# Python (websocket-client)
import json, websocket

API_KEY = "YOUR_API_KEY"

def send(ws, obj): ws.send(json.dumps(obj))

def on_open(ws):
    # Authenticate
    # https://docs.qfex.com/websocket/channels/trade/authenticate#how-it-works
    send(ws, {"type": "auth", "params": { "hmac": { "public_key": "qfex_pub_xxxxx", "nonce": "c0ffee...", "unix_ts": 1760545414, "signature": "5f2e..." }}})
    # Get order
    send(ws, {"type": "get_order", "params": {"symbol": "AAPL-USD", "order_id": "57cc1941-8ad1-4df3-b34c-bb556518befc"}})

ws = websocket.WebSocketApp(
    "wss://trade.qfex.com?api_key=YOUR_API_KEY",
    on_open=on_open,
    on_message=lambda _, m: print("Message:", m)
)
ws.run_forever()
```

```javascript node theme={null}
// Node.js (ws)
import WebSocket from "ws";
const ws = new WebSocket("wss://trade.qfex.com?api_key=YOUR_API_KEY");
const API_KEY = "YOUR_API_KEY";

ws.on("open", () => {
  // Authenticate
  ws.send(JSON.stringify({ type: "auth", params: { api_key: API_KEY } }));
  // Get order
  ws.send(
    JSON.stringify({
      type: "get_order",
      params: {
        symbol: "AAPL-USD",
        order_id: "57cc1941-8ad1-4df3-b34c-bb556518befc",
      },
    })
  );
});

ws.on("message", (msg) => console.log("Message:", msg.toString()));
```

```go go theme={null}
// Go (gorilla/websocket)
package main

import (
	"log"
	"github.com/gorilla/websocket"
)

func mustWriteJSON(c *websocket.Conn, v any) {
	if err := c.WriteJSON(v); err != nil { log.Fatal("write:", err) }
}

func main() {
	c, _, err := websocket.DefaultDialer.Dial("wss://trade.qfex.com?api_key=YOUR_API_KEY", nil)
	if err != nil { log.Fatal("dial:", err) }
	defer c.Close()

	// Authenticate
	mustWriteJSON(c, map[string]any{
		"type": "auth",
		"params": map[string]any{"hmac": map[string]any{"public_key": "qfex_pub_xxxxx", "nonce": "c0ffee...", "unix_ts": 1760545414, "signature": "5f2e..."}}
	})

	// Get order
	mustWriteJSON(c, map[string]any{
		"type": "get_order",
		"params": map[string]any{"symbol": "AAPL-USD", "order_id": "57cc1941-8ad1-4df3-b34c-bb556518befc"},
	})
}
```

```java java theme={null}
// Java (OkHttp WebSocket)
import java.util.concurrent.TimeUnit;
import okhttp3.*;

public class GetOrderWs {
  public static void main(String[] args) {
    OkHttpClient client = new OkHttpClient.Builder()
        .pingInterval(20, TimeUnit.SECONDS).build();

    Request req = new Request.Builder()
        .url("wss://trade.qfex.com?api_key=YOUR_API_KEY").build();

    WebSocketListener li = new WebSocketListener() {
      @Override public void onOpen(WebSocket ws, Response r) {
        // Authenticate
        ws.send("{\"type\": \"auth\", \"params\": { \"hmac\": { \"public_key\": \"qfex_pub_xxxxx\", \"nonce\": \"c0ffee...\..\", \"unix_ts\": 1760545414, \"signature\": \"5f2e...\" }}}");
        // Get order
        ws.send("{\"type\":\"get_order\",\"params\":{\"symbol\":\"AAPL-USD\",\"order_id\":\"57cc1941-8ad1-4df3-b34c-bb556518befc\"}}");
      }
      @Override public void onMessage(WebSocket ws, String text) {
        System.out.println(text);
      }
    };

    client.newWebSocket(req, li);
    try { Thread.sleep(Long.MAX_VALUE); } catch (InterruptedException ignored) {}
  }
}
```

## 响应示例

```json theme={null}
{
  "all_orders_response": {
    "orders": [
      {
        "order_id": "2f05173c-992a-426b-bcaf-6b341644bb62",
        "symbol": "GOOG-USD",
        "status": "ACK",
        "quantity": 2.708,
        "price": 251.25,
        "take_profit": 0.0,
        "stop_loss": 0.0,
        "side": "SELL",
        "type": "LIMIT",
        "time_in_force": "GTC",
        "user_id": "0020ce8e-eaee-480e-8d7f-b9241d756ee5",
        "client_order_id": "7a257796-a9c1-49bd-a80b-bcccdc81c103",
        "quantity_remaining": 2.708,
        "update_time": 1758208770.5512846,
        "trade_id": null
      }
    ],
    "stop_orders": []
  }
}
```

> [!NOTE]
>
> 仅返回**未完成订单**（包括部分成交订单），不包含已完全成交或完全取消的订单。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.