> For the complete documentation index, see [llms.txt](https://docs.dexpal.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dexpal.io/for-partners/endpoints/user-orders.md).

# User Orders

Returns all pending limit orders for the provided wallet addresses.

> **Collection endpoint:** Return pending orders for any requested address the DEX can read, even if the wallet has not used DexPal's affiliate code. If none of the provided addresses have pending orders, 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](/for-partners/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.
