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

# getOrders

> Fetch pending, executed, or cancelled Ostium orders by hash, id, or recent trader activity.

## Poll by transaction hash

```ts theme={null}
const orders = await client.getOrders({
  initiatedTxHashes: [txHash],
});
```

## Query by order id

```ts theme={null}
const orders = await client.getOrders({ orderIds: [123] });
```

`orderIds` are on-chain keeper order ids. In the response, `oid` is the same id formatted as a base-10 numeric string, so it can be compared directly with the value returned by `extractOrderIdFromReceipt()`.

## Filter order history

Without filters, `OstiumClient.getOrders()` returns recent orders for the connected trader. Pass `user: 'ALL'` to remove the trader filter and fetch global orders. When `builder` is provided without `user`, the SDK does not add the connected-trader default.

```ts theme={null}
const globalOrders = await client.getOrders({ user: 'ALL' });

const builderOrders = await client.getOrders({
  builder: '0xBuilderAddress',
});

const pendingBtcOrders = await client.getOrders({
  isPending: true,
  pairIds: ['0'],
});

const ordersExecutedToday = await client.getOrders({
  user: 'ALL',
  start: 1765411200,
  end: 1765497599,
});

const cancelledBuilderOrders = await client.getOrders({
  user: 'ALL',
  builder: '0xBuilderAddress',
  isCanceled: true,
});
```

`orderIds` and `initiatedTxHashes` are mutually exclusive. The other filters can be combined.

`start` and `end` filter by execution time (`executedAt`) as Unix seconds UTC with inclusive bounds. Pending orders do not have execution time, so combining `start` or `end` with `isPending: true` returns no executed-time matches.

For builder analytics that should include sibling close, TP, and SL orders on the same positions, use [getBuilderOrders](/developer/reference/get-builder-orders).

## Parameters

```ts theme={null}
interface GetOrdersParams {
  orderIds?: Array<string | number>;
  initiatedTxHashes?: readonly `0x${string}`[];
  user?: `0x${string}` | 'ALL';
  builder?: string;
  isPending?: boolean;
  isCanceled?: boolean;
  isCancelled?: boolean;
  pairIds?: Array<string | number>;
  start?: number;
  end?: number;
  limit?: number;
}
```

## Response schema

```ts theme={null}
type Response = Array<{
  pairTo: string;
  pairFrom: string;
  pairId: string;
  oid: string;
  pid: string;
  trader: string;
  side: 'B' | 'S';
  action: 'Open' | 'Close' | 'Liquidation' | 'StopLoss' | 'TakeProfit' | 'RemoveCollateral' | 'CloseDayTrade';
  type: 'Market' | 'Limit' | 'REMOVE_COLLATERAL';
  px: string;
  szi: string;
  ntl: string;
  collateralUsed: string;
  builder: string;
  fees: {
    opening: string;
    rollover: string;
    liquidation: string;
    builder: string;
    priceImpact: string;
  };
  closedPnl: string;
  hash: string;
  time: number;
  timestamp: number;
  initiatedTx: string;
  initiatedTime: number;
  isPending: boolean;
  isCancelled: boolean;
  cancelReason?: string;
  initiatedBlock?: string;
}>;
```
