---
title: "Code Chunker"
method: POST
path: "/v1/chunk/code"
---

# Code Chunker

`POST /v1/chunk/code`

Splits code into chunks based on its structure, leveraging Abstract Syntax Trees (ASTs) to create contextually relevant segments.

## Response `200`

Successful Response: A list of `CodeChunk` objects.

- CodeChunkSchema[] — A list containing `CodeChunk` objects, each detailing a segment of the original code and optionally the corresponding AST nodes.
  - `text` string — The actual code text content of the chunk.
  - `start_index` integer — The starting character index of the chunk within the original input code.
  - `end_index` integer — The ending character index (exclusive) of the chunk within the original input code.
  - `token_count` integer — The number of tokens in this specific chunk, according to the tokenizer used.
  - `nodes` NodeSchema[], nullable — Optional list of AST `Node` objects corresponding to this code chunk (present if `include_nodes` is true).
    - `text` string — The text content of the node.
    - `start_byte` integer — The starting byte index of the node within the original code text.
    - `end_byte` integer — The ending byte index (exclusive) of the node within the original code text.
    - `type` string — The type of the AST node (e.g., 'function_definition', 'identifier').

## Changes

- **2025-04-27** `bc64e1775952` — 1 info
  - endpoint added
- **2025-04-27** `5c8e44804806` — 1 breaking
  - api removed without deprecation
- **2025-04-27** `7e3cb743a9ed` — 1 warning
  - removed the request property `text`
- **2025-04-22** `29d7b471b697` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/feyninc/apis/chonkie-api/changes/v1/chunk/code/post.md)

---

[API](https://skmtc.dev/feyninc/apis/chonkie-api.md) · [All operations](https://skmtc.dev/feyninc/apis/chonkie-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/feyninc/chonkie-api/revisions/33dc37e4abcd/schema)
