# Get Prediction Market Data — Codex

> Returns prediction market outcomes (Polymarket, Kalshi) with current prices and implied probabilities. Filter by keyword phrase, market IDs, event IDs, protocol, status, liquidity, volume, and more. Requires a Codex Growth or Enterprise…

- Key: `codex-get-prediction-market-data`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Codex (`codex`) — https://pipedream.com/apps/codex.md
- This page (HTML): https://pipedream.com/apps/codex/actions/get-prediction-market-data
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/codex/actions/get-prediction-market-data/get-prediction-market-data.mjs

## Description

Returns prediction market outcomes (Polymarket, Kalshi) with current prices and implied probabilities. Filter by keyword phrase, market IDs, event IDs, protocol, status, liquidity, volume, and more. **Requires a Codex Growth or Enterprise plan** — returns an error on free/Starter plans. Supports offset-based pagination — pass `offset` (and optional `limit`) to fetch subsequent pages (e.g., `offset: 20` with `limit: 20` fetches the second page). [See the documentation](https://docs.codex.io/api-reference/queries/filterpredictionmarkets)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `phrase` | `string` | No | Text search across market questions, event labels, and categories (e.g., Bitcoin price, US election). |
| `marketIds` | `string[]` | No | Include only specific markets by ID (e.g., 0x4d4a...f3c2). IDs are returned in the id field of previous query results. |
| `excludeMarketIds` | `string[]` | No | Exclude specific markets by ID (e.g., 0x4d4a...f3c2). IDs are returned in the id field of previous query results. |
| `eventIds` | `string[]` | No | Include markets belonging to specific events by event ID (e.g., event_abc123). Event IDs are returned in the id field of prediction market event results. |
| `excludeEventIds` | `string[]` | No | Exclude markets belonging to specific events by event ID (e.g., event_abc123). Event IDs are returned in the id field of prediction market event results. |
| `rankings` | `string` | No | Sort results by one or more attributes. Provide a JSON array of ranking objects, each with attribute (e.g., volumeUsd24h, trendingScore1h, liquidityUsd), direction (ASC or DESC), and optionally outcome (outcome0 or outcome1) and outcomeAttribute. Example: [{"attribute": "volumeUsd24h", "direction": "DESC"}]. |
| `filters` | `string` | No | Advanced market filters as a JSON object. Supports protocol (array of PredictionProtocol: POLYMARKET, KALSHI), status (array of PredictionEventStatus: OPEN, SUSPENDED, RESOLVED, CANCELLED, PENDING), categories, excludeCategories, hasCategories, resolutionSource, and NumberFilter fields for liquidity, volume, trades, scoring, and timing (e.g., liquidityUsd, volumeUsd24h, trendingScore1h, closesAt). Each NumberFilter accepts gt, gte, lt, lte, eq. Example: {"status": ["OPEN"], "liquidityUsd": {"gt": 1000}}. |
| `limit` | `integer` | No | Maximum number of results to return. |
| `offset` | `integer` | No | Number of results to skip. Use with limit to page through results (e.g., offset: 20, limit: 20 fetches the second page). |

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

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: "codex-get-prediction-market-data",
  arguments: {
    phrase: "Search Phrase",
    marketIds: ["Market IDs"],
  },
})
```

**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: "codex-get-prediction-market-data",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    codex: { authProvisionId: "apn_xxxxxxx" },
    phrase: "Search Phrase",
    marketIds: ["Market IDs"],
  },
})

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": "codex-get-prediction-market-data",
    "configured_props": {
      "codex": { "authProvisionId": "apn_xxxxxxx" },
      "phrase": "Search Phrase",
      "marketIds": ["Market IDs"]
    }
  }'
```

---

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