Hanzo
OpenapiCode

Finds code in the caller org's index across three orthogonal retrieval tiers…

Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized…

GET /v1/code/search

Addresshttps://api.hanzo.ai/v1/code/search
MethodGET
Operationget_code_search
AuthAuthorization: Bearer $HANZO_API_KEY

Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized text), symbolic (real definition and reference edges), and semantic (embedding cosine over AST-boundary chunks). Pick one tier with type, or leave it to run all three as hybrid, which is what a coding agent usually wants. It is FAIL-HONEST: a retrieval outage answers 200 with an empty result set and "degraded": true rather than a 5xx, so an agent degrades instead of stalling. A malformed regex is a 400.

Request

4 fields.

FieldInTypeRequiredDescription
qquerystringQ is the search query.
typequerystringType selects the retrieval tier: "text" (FTS5 trigram), "regex", "symbol" (definitions), "semantic" (embeddings) or "hybrid".
repoquerystringRepo narrows to one repository.
limitqueryintegerLimit caps how many spans come back: default 20, maximum 100.

Response

StatusBodyMeaning
200searchResultsok

200 body — 14 fields.

FieldInTypeAlwaysDescription
degradedbodybooleanDegraded is true when retrieval failed and the empty result set is an outage rather than a real absence of matches.
querybodystringQuery echoes the query that was run.
resultsbodySpan[]Results are the matching spans, best first.
results[].endLinebodyintegerEndLine is the last line of the span, inclusive.
results[].filebodystringFile is the path inside the repo, relative to its root and never absolute.
results[].kindbodystringKind is what the indexer decided this chunk IS — "func", "method", "type", "struct", "interface", "var", "const", or "block" for a run of code that declares…
results[].linebodyintegerLine is where the span starts, 1-based, as an editor counts.
results[].repobodystringRepo is the indexed repository the span was found in, as it was indexed ("owner/name").
results[].rolebodystringcontext: match | definition | caller
results[].scorebodynumberScore ranks this span against the OTHERS IN THE SAME RESPONSE and means nothing across responses or between tiers: the hybrid tier's number is a…
results[].snippetbodystringSnippet is the code itself: a bounded excerpt on /search, the whole chunk on /context — which is why the same type serves both and why a /context span is the…
results[].symbolbodystringSymbol is the declared name, when the span declares one.
results[].tierbodystringTier is which retrieval produced the span: "hybrid" (the default — all three fused), "text" (trigram/FTS), "regex", "semantic" (vector), or "symbol".
typebodystringType echoes the retrieval tier that ran, after defaulting.

Failure carries the platform error shape — see Errors.

Examples

hanzo code search

Code API · All Hanzo APIs · Interactive reference

How is this guide?

On this page