# List Orders — Alpaca

> Retrieves a list of orders for the account, filtered by the supplied query parameters, if no filter given all will be returned, See the docs

- Key: `alpaca-list-orders`
- Type: Action (Read-only)
- Version: 0.0.3
- App: Alpaca (`alpaca`) — https://pipedream.com/apps/alpaca.md
- This page (HTML): https://pipedream.com/apps/alpaca/actions/list-orders
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/alpaca/actions/list-orders/list-orders.mjs

## Description

Retrieves a list of orders for the account, filtered by the supplied query parameters, if no filter given all will be returned, [See the docs](https://alpaca.markets/docs/api-references/trading-api/orders/#get-a-list-of-orders)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `isPaperAPI` | `boolean` | No | Set to true if Paper API is used. Default is false. |
| `symbols` | `string[]` | No | A list of symbols to filter by (ex. AAPL,TSLA,MSFT). A currency pair is required for crypto orders (ex. BTC/USD,BCH/USD,LTC/USDT,ETC/USDT). |
| `side` | `string` | No | Filters down to orders that have a matching side field set. |
| `status` | `string` | No | Order status to be queried. open, closed or all. Defaults to open. |
| `after` | `string` | No | The response will include only ones submitted after this time, in ISO 8601 format, e.g. 2022-09-07 or 2022-09-07T13:26:53 |
| `until` | `string` | No | The response will include only ones submitted until this time, in ISO 8601 format, e.g. 2022-09-07 or 2022-09-07T13:26:53 |
| `nested` | `string` | No | If true, the result will roll up multi-leg orders under the legs field of primary order. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "alpaca",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "alpaca-list-orders",
  arguments: {
    isPaperAPI: true,
    symbols: ["Symbols"],
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "alpaca-list-orders",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    alpaca: { authProvisionId: "apn_xxxxxxx" },
    isPaperAPI: true,
    symbols: ["Symbols"],
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "alpaca-list-orders",
    "configured_props": {
      "alpaca": { "authProvisionId": "apn_xxxxxxx" },
      "isPaperAPI": true,
      "symbols": ["Symbols"]
    }
  }'
```

---

- App: https://pipedream.com/apps/alpaca.md · All apps: https://pipedream.com/apps
