# List Trades — BitMEX

> Retrieve a list of executed trades from your BitMEX account. See the documentation

- Key: `bitmex-list-trades`
- Type: Action (Read-only)
- Version: 0.0.2
- App: BitMEX (`bitmex`) — https://pipedream.com/apps/bitmex.md
- This page (HTML): https://pipedream.com/apps/bitmex/actions/list-trades
- Hints: read-only
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/bitmex/actions/list-trades/list-trades.mjs

## Description

Retrieve a list of executed trades from your BitMEX account. [See the documentation](https://www.bitmex.com/api/explorer/#!/Execution/Execution_getTradeHistory)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `filter` | `object` | No | Generic table filter. Send JSON key/value pairs, such as {"execType": ["Settlement", "Trade"]} to filter on multiple values. For explanations on filters refer to http://www.onixs.biz/fix-dictionary/5.0.SP2/msgType_8_8.html |
| `symbol` | `string` | No | Instrument symbol. Send a bare series (e.g. XBT) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. XBT:quarterly. Timeframes are nearest, daily, weekly, monthly, quarterly, biquarterly, and perpetual. Symbols are case-insensitive. Options are loaded from the connected account. |
| `columns` | `string[]` | No | Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect. |
| `count` | `integer` | No | Number of results to fetch. Must be a positive integer. Defaults to 100 |
| `start` | `integer` | No | Starting point for results. Defaults to 0 |
| `reverse` | `boolean` | No | If true, will sort results newest first. Defaults to false |
| `startTime` | `string` | No | Starting date filter for results (format: YYYY-MM-DDTHH:mm:ss.sssZ) |
| `endTime` | `string` | No | Ending date filter for results (format: YYYY-MM-DDTHH:mm:ss.sssZ) |
| `targetAccountId` | `integer` | No | AccountId fetching the trade history, must be a paired account with main user |
| `targetAccountIds` | `string` | No | AccountIds fetching the trade history, must be a paired account with main user. Can be wildcard * to get all accounts linked to the authenticated user |

## 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": "bitmex",
      },
    },
  },
)

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: "bitmex-list-trades",
  arguments: {
    filter: "Filter",
    symbol: "Symbol",
  },
})
```

**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: "bitmex-list-trades",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    bitmex: { authProvisionId: "apn_xxxxxxx" },
    filter: "Filter",
    symbol: "Symbol",
  },
})

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": "bitmex-list-trades",
    "configured_props": {
      "bitmex": { "authProvisionId": "apn_xxxxxxx" },
      "filter": "Filter",
      "symbol": "Symbol"
    }
  }'
```

---

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