> For the complete documentation index, see [llms.txt](https://dev.strixlab.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.strixlab.io/typescript-sdk/reference.md).

# SDK Reference

A lookup table for `strix-sdk`. **P** = public (no credentials), **A** = requires HMAC credentials.

### Client

```ts
const client = new StrixClient({ baseUrl, apiKey, apiSecret, apiPassphrase, timeout, retryOn429, nullOnError });
```

<table><thead><tr><th width="300">Member</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>client.ping()</code></td><td>P</td><td><code>boolean</code> — API reachable.</td></tr><tr><td><code>client.serverTime()</code></td><td>P</td><td><code>{ serverTime }</code> — Unix seconds, for drift checks.</td></tr><tr><td><code>client.wsUrl</code></td><td>—</td><td>The resolved WebSocket URL.</td></tr><tr><td><code>client.destroy()</code></td><td>—</td><td>Closes sockets and timers. Call on exit.</td></tr></tbody></table>

### `client.events` — [docs](/typescript-sdk/events-and-markets.md)

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>list(params?)</code></td><td>P</td><td><code>PaginatedResponse&#x3C;StrixEvent></code></td></tr><tr><td><code>get(idOrSlug, { marketId? })</code></td><td>P</td><td><code>StrixEvent</code></td></tr><tr><td><code>find(query)</code></td><td>P</td><td><code>StrixEvent</code> — fuzzy title; throws if ambiguous.</td></tr><tr><td><code>findMarket(idOrSlug, query)</code></td><td>P</td><td><code>EventMarket</code> — one leg of a multi-outcome event.</td></tr><tr><td><code>getTokenIds(market)</code></td><td>—</td><td><code>{ yesTokenId, noTokenId, yesOutcome, noOutcome }</code></td></tr><tr><td><code>resolution(idOrSlug, { marketId? })</code></td><td>P</td><td><code>ResolutionStatus</code></td></tr></tbody></table>

### `client.markets`

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>get(marketId)</code></td><td>P</td><td><code>EventMarket</code></td></tr><tr><td><code>resolve(eventQuery, marketQuery?)</code></td><td>P</td><td><code>ResolvedMarketInfo</code> — flat ids + YES/NO tokens + tick size.</td></tr></tbody></table>

### `client.orderbook` — [docs](/typescript-sdk/orderbook.md)

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>snapshot(tokenId, { depth? })</code></td><td>P</td><td><code>{ bids, asks }</code> — depth ≤ 200, default 50.</td></tr><tr><td><code>midpoint(tokenId)</code></td><td>P</td><td><code>{ mid }</code> — <strong>404 on a one-sided book</strong>.</td></tr><tr><td><code>price(tokenId, 'buy' | 'sell')</code></td><td>P</td><td><code>{ price }</code> — best ask / best bid.</td></tr></tbody></table>

### `client.orders` — [docs](/typescript-sdk/orders.md)

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>place(params)</code></td><td>A</td><td><code>Order</code> — GTC / GTD / FOK / FAK.</td></tr><tr><td><code>placeMarket(params)</code></td><td>A</td><td><code>{ order, executionPlan }</code> — <code>maxSpend</code> on BUY, <code>quantity</code> on SELL.</td></tr><tr><td><code>placeBatch(orders[])</code></td><td>A</td><td><code>BatchResultItem[]</code> — max 15, per-item success.</td></tr><tr><td><code>cancel(orderHash)</code></td><td>A</td><td><code>Order</code> — <em>rate limited</em>.</td></tr><tr><td><code>cancelBatch(hashes[])</code></td><td>A</td><td><code>{ cancelled, failed }</code> — max 100, exempt.</td></tr><tr><td><code>cancelAll({ tokenId?, marketId? })</code></td><td>A</td><td><code>{ cancelled, failed }</code> — the kill-switch, exempt.</td></tr><tr><td><code>list({ marketId? })</code></td><td>A</td><td><code>Order[]</code> — your open orders.</td></tr></tbody></table>

### `client.portfolio` — [docs](/typescript-sdk/portfolio.md)

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>balances()</code></td><td>A</td><td><code>PortfolioBalances</code> — cheap; use in loops.</td></tr><tr><td><code>summary()</code></td><td>A</td><td><code>PortfolioSummary</code> — adds P&#x26;L; replays the ledger.</td></tr><tr><td><code>positions()</code></td><td>A</td><td><code>Position[]</code></td></tr><tr><td><code>positionsForMarket(marketId)</code></td><td>A</td><td><code>Position[]</code></td></tr><tr><td><code>trades({ limit? })</code></td><td>A</td><td><code>Trade[]</code></td></tr><tr><td><code>deposits({ limit? })</code></td><td>A</td><td><code>DepositRecord[]</code></td></tr><tr><td><code>withdrawals({ limit? })</code></td><td>A</td><td><code>WithdrawalRecord[]</code></td></tr></tbody></table>

### `client.positions` — [docs](/typescript-sdk/portfolio.md#conditional-token-operations)

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>split({ eventId, marketId?, amount })</code></td><td>A</td><td><code>{ txHash }</code> — USDC → YES + NO.</td></tr><tr><td><code>merge({ eventId, marketId?, amount })</code></td><td>A</td><td><code>{ txHash }</code> — YES + NO → USDC.</td></tr><tr><td><code>redeem({ marketId })</code></td><td>A</td><td><code>{ txHash }</code> — after resolution.</td></tr></tbody></table>

### `client.public`

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>kline({ outcomeId, interval, from?, to? })</code></td><td>P</td><td><code>Candle[]</code> — <code>m1 m5 m15 h1 h4 d1</code>.</td></tr><tr><td><code>activity({ limit?, offset? })</code></td><td>P</td><td><code>ActivityResponse</code> — recent settled trades.</td></tr><tr><td><code>leaderboard({ period?, category?, limit? })</code></td><td>P</td><td><code>LeaderboardResponse</code></td></tr><tr><td><code>categories()</code></td><td>P</td><td><code>Category[]</code></td></tr></tbody></table>

### `client.referrals`

<table><thead><tr><th width="380">Method</th><th width="60"></th><th>Returns</th></tr></thead><tbody><tr><td><code>me()</code></td><td>A</td><td><code>{ code, total, completed, pending }</code></td></tr></tbody></table>

### `client.ws` — [docs](/typescript-sdk/websockets.md)

<table><thead><tr><th width="420">Member</th><th width="60"></th><th>Notes</th></tr></thead><tbody><tr><td><code>ws.orderbook.subscribe(tokenIds[], options)</code></td><td>P</td><td>Returns an unsubscribe function.</td></tr><tr><td><code>ws.orderbook.getBook(tokenId)</code></td><td>—</td><td>Cached book, or <code>null</code>.</td></tr><tr><td><code>ws.orderbook.getMid(tokenId)</code></td><td>—</td><td><code>{ yesMid, noMid, bestBid, bestAsk }</code>, nulls allowed.</td></tr><tr><td><code>ws.trades.subscribe(tokenIds[], handler)</code></td><td>P</td><td>Taker-side executions.</td></tr><tr><td><code>ws.user.connect()</code></td><td>A</td><td>Authenticates and re-authenticates on reconnect.</td></tr><tr><td><code>ws.user.on(event, handler)</code></td><td>A</td><td>Returns an unsubscribe function.</td></tr><tr><td><code>ws.user.connectionState</code></td><td>—</td><td><code>disconnected | connecting | connected | authenticated</code></td></tr></tbody></table>

**Subscribe options:** `depth`, `onSnapshot`, `onDelta`, `onMid`, `onLastPrice`, `onStatusUpdate`. **User events:** `order.update`, `trade.settled`, `trade.failed`, `position.update`, `portfolio.summary_update`, `error`.

### Standalone exports

```ts
import {
  StrixClient,
  getTokenIds, OUTCOME_INDEX,                    // YES = 1, NO = 0
  buildSignature, buildWsSignature, buildTimestamp,
  StrixApiError, StrixAuthError, StrixConfigError,
} from 'strix-sdk';

import type { StrixEvent, EventMarket, Outcome, Order, Position, Trade } from 'strix-sdk/shared';
```

`strix-sdk/shared` carries the types and the pure helpers with no runtime attached — safe to import in a browser bundle.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dev.strixlab.io/typescript-sdk/reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
