> 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/events-and-markets.md).

# Events & Markets

Everything on this page is **public** — no API keys needed.

### List events

```ts
const { items, total, limit, offset } = await client.events.list({
  status: 'open',
  category: 'crypto',
  limit: 20,
  offset: 0,
});
```

<table><thead><tr><th width="160">Parameter</th><th width="150">Type</th><th>Notes</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>'open' | 'closed' | 'resolved'</code></td><td>Trade only <code>open</code> markets.</td></tr><tr><td><code>category</code></td><td><code>string</code></td><td>Category slug — <code>crypto</code>, <code>sports</code>, <code>politics</code>, …</td></tr><tr><td><code>tag</code></td><td><code>string</code></td><td>Tag slug, for finer filtering within a category.</td></tr><tr><td><code>search</code></td><td><code>string</code></td><td>Server-side title search.</td></tr><tr><td><code>limit</code></td><td><code>number</code></td><td>1–100, defaults to 20.</td></tr><tr><td><code>offset</code></td><td><code>number</code></td><td>Defaults to 0.</td></tr><tr><td><code>includeTotal</code></td><td><code>boolean</code></td><td>Set <code>false</code> to skip the count query on hot paths.</td></tr></tbody></table>

{% code title="Paging through every open event" %}

```ts
const all = [];
for (let offset = 0; ; offset += 100) {
  const page = await client.events.list({ status: 'open', limit: 100, offset, includeTotal: false });
  all.push(...page.items);
  if (page.items.length < 100) break;
}
```

{% endcode %}

### Get one event

```ts
const byId   = await client.events.get('clx8a9b2c0000');
const bySlug = await client.events.get('will-btc-close-above-100k-in-2026');
```

`events.find()` is the forgiving version — it takes a partial, case-insensitive title, with an exact ID/slug fast path. It throws when nothing matches or the query is ambiguous, which makes it good for scripts and CLIs and bad for hot loops.

```ts
const event = await client.events.find('BTC above 100k');
```

### Get the tokenIds

```ts
import { getTokenIds } from 'strix-sdk';

const market = event.markets[0];
const { yesTokenId, noTokenId, yesOutcome, noOutcome } = getTokenIds(market);
```

{% hint style="info" %}
`client.events.getTokenIds(market)` is the same function on the client. Both resolve YES/NO from `outcomeIndex` (**1 = YES, 0 = NO**), never from array order or display name. See [Core Concepts](/get-started/concepts.md#yes-is-index-1-no-is-index-0).
{% endhint %}

For a multi-outcome event, drill into a single leg by name:

```ts
const brazil = await client.events.findMarket('2026-world-cup-winner', 'Brazil');
const { yesTokenId } = getTokenIds(brazil);
```

### What an event looks like

{% code title="Shape (abridged)" %}

```ts
interface StrixEvent {
  id: string;
  slug: string;
  title: string;
  category?: string | null;
  marketType: 'CTF' | 'NEG_RISK' | 'OOV3_CTF' | 'OOV3_NEG_RISK';
  status: 'open' | 'closed' | 'resolved';
  tickSize: string;          // "0.01" | "0.001" — the price grid for every market inside
  expiryTime: string;        // ISO 8601
  markets: EventMarket[];
}

interface EventMarket {
  id: string;
  title: string | null;      // null on a single-market event
  status: 'open' | 'closed' | 'resolved';
  enableOrderBook: boolean;  // false → not tradeable right now
  volume: string;
  winningOutcome: Outcome | null;
  outcomes: Outcome[];
}

interface Outcome {
  id: string;                // database id — NOT the tokenId
  name: string;
  tokenId: string;           // ← what you trade with
  outcomeIndex: number;      // 1 = YES, 0 = NO
  lastPrice: string;
}
```

{% endcode %}

{% hint style="warning" %}
`outcome.id` and `outcome.tokenId` are different identifiers and both are strings. Orders, order books and WebSocket subscriptions take **`tokenId`**. Passing `id` produces a `token_not_found`, or worse, silently matches nothing.
{% endhint %}

### Market types

<table><thead><tr><th width="220">Type</th><th>Shape</th></tr></thead><tbody><tr><td><code>CTF</code></td><td>Binary event — one market, YES and NO.</td></tr><tr><td><code>NEG_RISK</code></td><td>Multi-outcome event — N binary markets, at most one of which resolves YES.</td></tr><tr><td><code>OOV3_CTF</code> / <code>OOV3_NEG_RISK</code></td><td>Same shapes, resolved through the optimistic oracle rather than manually.</td></tr></tbody></table>

### A single market

When you already know the market id:

```ts
const market = await client.markets.get('mkt_abc123');
```

### The one-call shortcut

`markets.resolve()` collapses "find the event → pick the market → pull the tokenIds" into a single call, and returns a flat object with everything needed to start trading:

{% code title="resolve.ts" %}

```ts
// Binary event — the title is enough
const info = await client.markets.resolve('BTC above 100k');

info.marketId;       // "mkt_abc123"
info.tickSize;       // 0.01  (a number here, not a string)
info.yes.tokenId;    // trade / subscribe with this
info.yes.name;       // "Yes"
info.no.tokenId;

// Multi-outcome event — name the leg too
const brazil = await client.markets.resolve('2026 World Cup winner', 'Brazil');
```

{% endcode %}

It is built on `events.find()`, so it throws on an ambiguous title. Resolve once at startup, cache the ids, and trade from the cache.

### Resolution status

After a market closes, follow its on-chain resolution:

```ts
const status = await client.events.resolution(eventId);
// multi-outcome: client.events.resolution(eventId, { marketId })

console.log(status.resolverType);          // 'MANUAL' | 'OOV3_CTF' | 'OOV3_NEG_RISK'
console.log(status.finalOutcome);          // null while pending
console.log(status.assertionInProgress);   // true during the oracle challenge window
for (const step of status.timeline) console.log(step.timestamp, step.event, step.txHash);
```

### Price history

OHLCV candles for any outcome, public:

```ts
const candles = await client.public.kline({
  outcomeId: tokenId,           // accepts the tokenId or the outcome's database id
  interval:  'h1',              // 'm1' | 'm5' | 'm15' | 'h1' | 'h4' | 'd1'
  from:      '2026-08-01T00:00:00Z',
  to:        '2026-08-22T00:00:00Z',
});

// [{ timestamp, open, high, low, close, volume }, …] — all decimal strings
```

### Other public reads

```ts
const categories  = await client.public.categories();                       // category list for filtering
const activity    = await client.public.activity({ limit: 50 });            // recent settled trades, platform-wide
const leaderboard = await client.public.leaderboard({ period: 'weekly' });  // 'today' | 'weekly' | 'monthly' | 'all'
```


---

# 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/events-and-markets.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.
