# User Orders

Returns all pending limit orders for the provided wallet addresses.

> **🔒 Affiliate-code gating:** Only include orders for addresses attributed to DexPal's affiliate code. If none of the provided addresses are DexPal-attributed, return `200` with `"data": []`. See the [Overview](/for-partners/dex-api-spec.md).

## Overview

|                |                |
| -------------- | -------------- |
| **Method**     | GET            |
| **Auth**       | Bearer API key |
| **Rate limit** | 120 req/min    |

## Request

### Query Parameters

| Param  | Type   | Required | Description                                        |
| ------ | ------ | -------- | -------------------------------------------------- |
| `addr` | string | yes      | Comma-separated list of wallet addresses to query. |

### Headers

| Header          | Required | Description        |
| --------------- | -------- | ------------------ |
| `Authorization` | yes      | `Bearer <api_key>` |

### Example Request

```
GET /dexpal/v1/users/orders?addr=0x1a2b...,0x9c3d...
```

## Response

Returns a `data` array of pending limit order objects.

### Fields — Order Object

| Field               | Type                                                                                                        | Required | Description                                                                                                                                                |
| ------------------- | ----------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `orderId`           | string                                                                                                      | yes      | Unique order identifier in the format `exchange:wallet:id` e.g. `"vela:0x1a2b...:85"`.                                                                     |
| `address`           | string                                                                                                      | yes      | The wallet address that placed this order.                                                                                                                 |
| `exchange`          | string                                                                                                      | yes      | DEX slug e.g. `"vela"`, `"gmx"`.                                                                                                                           |
| `side`              | enum                                                                                                        | yes      | Order direction. `long` or `short`.                                                                                                                        |
| `baseAsset`         | string                                                                                                      | yes      | Base currency symbol e.g. `"BTC"`.                                                                                                                         |
| `quoteAsset`        | string                                                                                                      | yes      | Quote currency symbol e.g. `"USD"`.                                                                                                                        |
| `assetType`         | string                                                                                                      | yes      | Asset category. See [AssetObject](/for-partners/schemas/asset-object.md) for valid values.                                                                 |
| `limitPrice`        | number                                                                                                      | yes      | Target execution price in quote currency. The order fills when the market reaches this price.                                                              |
| `positionSizeUsd`   | number                                                                                                      | yes      | Position size that will open at execution, in USD.                                                                                                         |
| `positionSizeToken` | number                                                                                                      | yes      | Position size in base currency at the limit price.                                                                                                         |
| `collateralUsd`     | number                                                                                                      | yes      | Collateral that will be posted at execution, in USD.                                                                                                       |
| `leverage`          | number                                                                                                      | yes      | Leverage that will be applied at execution.                                                                                                                |
| `feeFundingUsd`     | number                                                                                                      | no       | Estimated funding fee at time of order creation, in USD.                                                                                                   |
| `closingFeeUsd`     | number                                                                                                      | no       | Estimated closing fee if the position is closed immediately at execution, in USD.                                                                          |
| `chainId`           | integer                                                                                                     | no       | Wagmi/viem chain ID of the network where the order is placed.                                                                                              |
| `createdAt`         | ISO8601                                                                                                     | yes      | Timestamp when the order was placed.                                                                                                                       |
| `triggerOrders`     | array\[[TriggerOrder](/for-partners/schemas/trigger-order.md)]                                              | no       | Associated stop loss and take profit orders that will activate when this order fills. Empty array if none.                                                 |
| `orderType`         | string                                                                                                      | no       | Order type classification. `market`, `limit`, `stopMarket`, `stopLimit`, `trailingStop`, `twap`, `ladder`, `scale`, `oco`, `oto`, `takeProfit`, `iceberg`. |
| `orderFlags`        | array\[string]                                                                                              | no       | Execution modifier flags. Any subset of `reduceOnly`, `postOnly`, `ioc`, `fok`.                                                                            |
| `timeInForce`       | string                                                                                                      | no       | Time-in-force policy. `gtc` (good till cancelled), `ioc` (immediate or cancel), `fok` (fill or kill), `gtt` (good till time).                              |
| `expiresAt`         | ISO8601                                                                                                     | no       | Expiry timestamp. Only set when `timeInForce` is `gtt`.                                                                                                    |
| `stopPrice`         | number                                                                                                      | no       | Trigger price for stop orders. Set on `stopMarket` and `stopLimit` orders.                                                                                 |
| `trailAmount`       | number                                                                                                      | no       | Trail distance. Units depend on `trailType`.                                                                                                               |
| `trailType`         | string                                                                                                      | no       | Trail amount unit. `percent` or `absolute`.                                                                                                                |
| `activationPrice`   | number                                                                                                      | no       | Price at which trailing stop begins tracking.                                                                                                              |
| `triggerPriceType`  | string                                                                                                      | no       | Price feed used to evaluate the trigger. `mark`, `last`, or `index`.                                                                                       |
| `twapConfig`        | [TwapConfig](https://github.com/dexpal-analytics/dexpal/blob/main/docs/dex-api-spec/schemas/twap-config.md) | no       | TWAP execution parameters. Only present on `twap` orders.                                                                                                  |
| `linkedOrderId`     | string                                                                                                      | no       | Partner order ID for OCO (one-cancels-other) pairs.                                                                                                        |
| `isSystemGenerated` | boolean                                                                                                     | no       | `true` if created automatically by the DEX (e.g. mandatory stop-loss).                                                                                     |
| `accountId`         | string                                                                                                      | no       | Subaccount or portfolio ID.                                                                                                                                |

## Example Response

```json
{
  "success": true,
  "data": [
    {
      "orderId": "vela:0x1a2b3c4d5e6f7890abcdef1234567890abcdef12:85",
      "address": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12",
      "exchange": "vela",
      "side": "long",
      "baseAsset": "BTC",
      "quoteAsset": "USD",
      "assetType": "crypto",
      "limitPrice": 40500.0,
      "positionSizeUsd": 200.0,
      "positionSizeToken": 0.00493,
      "collateralUsd": 20.0,
      "leverage": 10,
      "feeFundingUsd": 0.0,
      "closingFeeUsd": 0.0,
      "chainId": 42161,
      "createdAt": "2024-09-05T19:48:05Z",
      "triggerOrders": [
        {
          "action": "takeProfit",
          "triggerPrice": 45000.0,
          "amountPercent": 100.0,
          "createdAt": "2024-09-05T19:48:05Z"
        }
      ]
    }
  ]
}
```

## Error Responses

| Status | Error                                | When                      |
| ------ | ------------------------------------ | ------------------------- |
| `400`  | `"Missing required parameter: addr"` | `addr` absent             |
| `401`  | `"Invalid or missing API key"`       | Bad or absent auth header |
| `500`  | `"Internal server error"`            | Unexpected failure        |

## Notes

* Only return orders with status `pending` (not yet filled, cancelled, or expired). Filled orders appear in [`history`](/for-partners/endpoints/user-history.md).
* If none of the provided addresses have pending orders, return `"data": []`.
* `positionSizeToken` should be calculated at the `limitPrice`, not the current market price.
* Not all DEXes support trigger orders on limit orders. Return an empty `triggerOrders` array if not applicable.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dexpal.io/for-partners/endpoints/user-orders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
