List 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

Addresshttps://api.hanzo.ai/v1/code/tree
MethodGET
Operationget_code_tree
AuthAuthorization: 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.

FieldInTypeRequiredDescription
repoquerystring—Repo is the repository to walk.

Response

StatusBodyMeaning
200code.repoTreeok
defaultproblem-detailsrefused

200 body — 5 fields.

FieldInTypeAlwaysDescription
filesbodycode.TreeEntry[]—Files are the repo's indexed files in path order, each with its language and how many symbols it defines.
files[].langbodystring—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[].pathbodystring—Path is the file, relative to the repo root.
files[].symbolsbodyinteger (int64)—Symbols is how many top-level declarations the file defines.
repobodystring—Repo echoes the repository that was walked.

Failure carries the platform error shape — see Errors.

Examples

hanzo code tree
import { 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 := 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
}
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?;
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();
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": {}
         }
       }
     }'

Code API · All Hanzo APIs · Interactive reference

Was this page useful?