OpenapiCode
Returns the INDEXED content of one file — read_file over the chunks the search…
Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found.
GET /v1/code/file
| Address | https://api.hanzo.ai/v1/code/file |
| Method | GET |
| Operation | get_code_file |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Returns the INDEXED content of one file — read_file over the chunks the search tiers hold, for pulling up code an agent just found. It is NOT byte-verbatim: the git object plane is the source of record for exact bytes, history and blame. A file absent from the index is a 404, so an agent can tell "not indexed" from "empty file".
Request
2 fields.
| Field | In | Type | Required | Description |
|---|---|---|---|---|
path | query | string | — | Path is the file's repo-relative path. |
repo | query | string | — | Repo is the repository the file belongs to. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | fileContent | ok |
200 body — 4 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
content | body | string | — | Content is the file's text as the index stored it. |
lang | body | string | — | Lang is the detected language. |
path | body | string | — | Path echoes the file that was read. |
repo | body | string | — | Repo echoes the repository it came from. |
Failure carries the platform error shape — see Errors.
Examples
hanzo code fileimport { Configuration, CodeApi } from 'hanzoai';
const api = new CodeApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getCodeFile();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_file()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CodeAPI.GetCodeFile(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_file(&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).getCodeFile();curl https://api.hanzo.ai/v1/code/file \
-H "Authorization: Bearer $HANZO_API_KEY"Tool code, op get_code_file — 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_file",
"input": {}
}
}
}'How is this guide?