OpenapiCode
Returns one repository's file structure with a per-file symbol count —…
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
| 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 | repoTree | ok |
200 body — 5 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
files | body | 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… |
files[].path | body | string | — | Path is the file, relative to the repo root. |
files[].symbols | body | integer | — | 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.
Examples
hanzo code treeimport { Configuration, CodeApi } from 'hanzoai';
const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeTree();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()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CodeAPI.GetCodeTree(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::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?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CodeApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new CodeApi(client).getCodeTree();curl https://api.hanzo.ai/v1/code/tree \
-H "Authorization: Bearer $HANZO_API_KEY"Tool code, op get_code_tree — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.
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": {}
}
}
}'How is this guide?