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

# Polymarket plugin

> Polymarket prediction markets and perps: markets, events, tags, series, sports and search (Gamma), positions, trades, activity, holders and leaderboards (Data API), order books, prices, price history, orders, API keys and rewards (CLOB), deposits and withdrawals (Bridge), gasless transactions (Relayer), RFQ and combo quotes, and the Perps exchange (276 operations).

Use **Polymarket** through Corsair: one client, typed API calls.

Market data needs no key: Gamma (`gamma.*`: markets, events, tags,
series, sports, search), the Data API (`data.*`: positions, trades,
activity, holders, leaderboards, open interest), CLOB prices and books
(`clob.books.get`, `clob.prices.get`, `clob.pricesHistory.get` ...), Perps
market info (`perps.instruments`, `perps.book` ...) and the Bridge.

* **Trading on the CLOB** (`clob.orders.*`, balances, rewards,
  notifications, `combos.*`) needs a CLOB API key set: connect with the API
  key as the key and its `secret`, `passphrase` and wallet `address`. Make
  one with `clob.apiKeys.create` or `clob.apiKeys.derive`, which take your
  wallet's EIP-712 ClobAuth signature as `poly_address`, `poly_signature`,
  `poly_timestamp` and `poly_nonce` (the plugin never holds a private
  key). Each call is signed with the secret (HMAC-SHA256).
* **Orders are signed by your wallet.** `clob.orders.create` takes the
  order your wallet signed (the TypeScript or Python SDK builds it);
  Perps orders, withdrawals and transfers carry their own signature too.
* **Perps account reads** (`perps.account.*`) take the `perps` option
  `{ proxy, secret }` from `perps.proxy.create`; **RFQ partner** routes the
  `rfq` option `{ keyId, secret }`; the **Relayer** the `relayer` option (a
  relayer API key, or builder credentials).
* **Risk.** Placing orders, withdrawals, transfers, leverage and margin
  changes, quotes, submitting transactions and minting API keys are
  `destructive`, as is every cancel and delete. Lookups sent as POST
  (batch prices, books, midpoints) are `read`.
* Token ids are long decimal strings (keep them as strings);
  condition ids and addresses are 0x hex.

**What you get:**

* 276 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/polymarket better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/polymarket better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/polymarket better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/polymarket better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { polymarket } from '@corsair-dev/polymarket';

export const corsair = createCorsair({
	plugins: [
		polymarket(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the Polymarket API key before the first call: `pnpm corsair setup --plugin=polymarket --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> polymarket()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'polymarket',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**`bridge.quote`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.polymarket.api.bridge.quote({});
```

**`bridge.deposit`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.polymarket.api.bridge.deposit({});
```

See the full list on the [API](https://docs.corsair.dev/plugins/polymarket/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/polymarket/api.md)
>
> Every `polymarket.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.