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

# GET /api/threads/:id/chapters

> List chapters within a thread, derived from market groupings

Fetches all chapters within a thread. Chapters are logical groupings of markets derived from denormalized fields on the markets table, ordered by position.

## Endpoint

```
GET https://app.kash.bot/api/threads/:id/chapters
```

## Path Parameters

<ParamField path="id" type="string" required>
  The unique thread identifier (UUID format)
</ParamField>

## Response

<ResponseField name="chapters" type="array">
  Array of chapter summary objects, ordered by position

  <Expandable title="Chapter Object">
    <ResponseField name="chapterId" type="string">
      Unique chapter identifier
    </ResponseField>

    <ResponseField name="title" type="string">
      Chapter title (nullable)
    </ResponseField>

    <ResponseField name="position" type="number">
      Chapter position within the thread (nullable, used for ordering)
    </ResponseField>

    <ResponseField name="total" type="number">
      Total number of chapters in the thread (nullable)
    </ResponseField>

    <ResponseField name="marketCount" type="number">
      Number of markets in this chapter
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="_meta" type="object">
  Request metadata

  <Expandable title="Metadata Properties">
    <ResponseField name="threadId" type="string">
      The thread ID that was queried
    </ResponseField>

    <ResponseField name="requestedAt" type="string">
      ISO 8601 timestamp of request processing
    </ResponseField>
  </Expandable>
</ResponseField>

## Rate Limit

<Info>
  **100 requests per minute** per IP address
</Info>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.kash.bot/api/threads/7c9e6679-7425-40de-944b-e07fc1f90ae7/chapters"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://app.kash.bot/api/threads/7c9e6679-7425-40de-944b-e07fc1f90ae7/chapters'
  );
  const data = await response.json();
  console.log(`Found ${data.chapters.length} chapters`);
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://app.kash.bot/api/threads/7c9e6679-7425-40de-944b-e07fc1f90ae7/chapters'
  )
  data = response.json()
  print(f"Found {len(data['chapters'])} chapters")
  ```
</CodeGroup>

## Example Response

```json 200 - Success theme={null}
{
  "chapters": [
    {
      "chapterId": "ch-group-stage",
      "title": "Group Stage",
      "position": 1,
      "total": 4,
      "marketCount": 24
    },
    {
      "chapterId": "ch-round-of-16",
      "title": "Round of 16",
      "position": 2,
      "total": 4,
      "marketCount": 8
    },
    {
      "chapterId": "ch-quarter-finals",
      "title": "Quarter Finals",
      "position": 3,
      "total": 4,
      "marketCount": 4
    },
    {
      "chapterId": "ch-finals",
      "title": "Semi Finals & Final",
      "position": 4,
      "total": 4,
      "marketCount": 3
    }
  ],
  "_meta": {
    "threadId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "requestedAt": "2026-03-04T12:00:00Z"
  }
}
```

```json 404 - Thread Not Found theme={null}
{
  "error": "Thread not found",
  "message": "No thread exists with ID: 7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "code": "NOT_FOUND"
}
```

## Common Use Cases

### Build a chapter navigation sidebar

```javascript theme={null}
async function buildChapterNav(threadId) {
  const { chapters } = await fetch(
    `https://app.kash.bot/api/threads/${threadId}/chapters`
  ).then(r => r.json());

  return chapters.map(ch => ({
    id: ch.chapterId,
    label: ch.title || `Chapter ${ch.position}`,
    marketCount: ch.marketCount,
    active: false,
  }));
}
```

### Fetch markets for a specific chapter

Use the `chapterId` from this endpoint to filter markets:

```javascript theme={null}
async function getChapterMarkets(threadId, chapterId) {
  // Get chapter info
  const { chapters } = await fetch(
    `https://app.kash.bot/api/threads/${threadId}/chapters`
  ).then(r => r.json());

  const chapter = chapters.find(ch => ch.chapterId === chapterId);

  // Get markets filtered by chapterId
  const { markets } = await fetch(
    `https://app.kash.bot/api/markets?` +
    new URLSearchParams({ chapterId, status: 'active' })
  ).then(r => r.json());

  return { chapter, markets };
}
```

### Build a complete thread page with chapters

```javascript theme={null}
async function buildThreadWithChapters(threadId) {
  // Fetch thread details and chapters in parallel
  const [threadRes, chaptersRes] = await Promise.all([
    fetch(`https://app.kash.bot/api/threads/${threadId}`),
    fetch(`https://app.kash.bot/api/threads/${threadId}/chapters`),
  ]);

  const { thread } = await threadRes.json();
  const { chapters } = await chaptersRes.json();

  // Fetch markets for each chapter
  const chaptersWithMarkets = await Promise.all(
    chapters.map(async (chapter) => {
      const { markets } = await fetch(
        `https://app.kash.bot/api/markets?chapterId=${chapter.chapterId}`
      ).then(r => r.json());
      return { ...chapter, markets };
    })
  );

  return { thread, chapters: chaptersWithMarkets };
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="GET /api/threads/:id" href="/developer-docs/public-embed-api/endpoints/thread-detail">
    Get thread details
  </Card>

  <Card title="GET /api/threads/:id/markets" href="/developer-docs/public-embed-api/endpoints/thread-markets">
    Get all markets in a thread
  </Card>

  <Card title="GET /api/markets" href="/developer-docs/public-embed-api/endpoints/markets">
    Filter markets by chapterId
  </Card>
</CardGroup>
