# List tree

URL: https://docs.hanzo.ai/docs/openapi/code/get-code-tree

> Returns one repository's file structure with a per-file symbol count — get_repo_structure over the org's own index, with no git checkout involved.

`GET /v1/code/tree`

> [Code →](https://docs.hanzo.ai/docs/openapi/code) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/code/tree`    |
| **Method**    | `GET`                                  |
| **Operation** | `get_code_tree`                        |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Returns one repository's file structure with a per-file symbol count —
get\_repo\_structure over the org's own index, with no git checkout involved. A
repository that has not been indexed answers an empty tree rather than an
error, so an agent can tell "nothing here" without handling a failure.

## Request

1 field.

| Field  | In    | Type   | Required | Description                     |
| ------ | ----- | ------ | -------- | ------------------------------- |
| `repo` | query | string | —        | Repo is the repository to walk. |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | code.repoTree   | ok      |
| `default` | problem-details | refused |

`200` body — 5 fields.

| Field             | In   | Type              | Always | Description                                                                                                                                                                                                  |
| ----------------- | ---- | ----------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `files`           | body | code.TreeEntry\[] | —      | Files are the repo's indexed files in path order, each with its language and how many symbols it defines.                                                                                                    |
| `files[].lang`    | body | string            | —      | Lang is the language the indexer parsed the file as ("go", "python", …), or empty when it recognised none — in which case Symbols is 0 because nothing was extracted, not because the file declares nothing. |
| `files[].path`    | body | string            | —      | Path is the file, relative to the repo root.                                                                                                                                                                 |
| `files[].symbols` | body | integer (int64)   | —      | Symbols is how many top-level declarations the file defines.                                                                                                                                                 |
| `repo`            | body | string            | —      | Repo echoes the repository that was walked.                                                                                                                                                                  |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo code tree
```

**SDK**

**.ts**

```ts
import { Configuration, CodeApi } from 'hanzoai';

const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeTree();
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CodeApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CodeApi(client).get_code_tree()
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.CodeAPI.GetCodeTree(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, code_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = code_api::get_code_tree(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new CodeApi(client).getCodeTree();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/code/tree \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

Tool `code`, op `get_code_tree` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "code",
         "arguments": {
           "op": "get_code_tree",
           "input": {}
         }
       }
     }'
```

---

[Code API](https://docs.hanzo.ai/docs/openapi/code) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
