Coregit
API Reference

Code Graph & Hybrid Search

Structural code intelligence — call graphs, dependencies, impact analysis, and hybrid search.

Query structural relationships in your codebase — who calls a function, what depends on a class, what breaks if you change something. Combine with semantic search for hybrid retrieval.

How It Works

  1. Index your repository — code is parsed with Tree-sitter (30+ languages), entities and relationships extracted into a graph stored in Postgres
  2. Query the graph — 14 query types from simple symbol lookup to multi-hop impact analysis, all version-aware
  3. Hybrid search — fuses semantic (Pinecone), graph (Postgres), and keyword results with weighted RRF fusion
ComponentDescription
ParserTree-sitter (30+ languages, regex fallback)
Graph storageNeon Postgres (code_node + code_edge tables)
CachingCloudflare KV (600s TTL, X-Cache header)

Performance: Graph queries are cached in KV keyed by commit SHA + query params. Cache hit: ~5ms. Cache miss: ~50-80ms.

Index a Repository

Before querying the graph, index the repository.

POST /v1/repos/:slug/graph/index

Permission: Write access required.

{
  "branch": "main"
}
FieldRequiredDescription
branchNoBranch to index (default: repo's default branch)

Response 202

{
  "status": "accepted",
  "branch": "main"
}

Indexing is asynchronous via queue. Poll the status endpoint.

Check Index Status

GET /v1/repos/:slug/graph/index/status

Response 200

{
  "status": "ready",
  "branch": "main",
  "last_commit_sha": "e713179f57ea...",
  "nodes_count": 1247,
  "edges_count": 3891,
  "total_batches": 3,
  "processed_batches": 3,
  "indexed_at": "2026-04-08T22:34:52.464Z",
  "error": null
}
FieldDescription
statusnot_indexed, pending, indexing, ready, or failed
nodes_countTotal entities (functions, classes, etc.)
edges_countTotal relationships (calls, imports, etc.)

Graph Query

POST /v1/repos/:slug/graph/query
{
  "type": "callers",
  "name": "createUser",
  "ref": "main",
  "max_depth": 3
}
FieldRequiredDescription
typeYesQuery type (see table below)
nameDependsEntity name for most query types
file_pathDependsFile path (for file_structure)
community_idDependsCluster ID (for community)
refNoBranch or commit SHA (default: repo's default branch)
max_depthNoMax traversal depth for recursive queries (default: 3, max: 5)

Query Types

TypeRequired FieldsDescription
callersnameWho calls function X?
calleesnameWhat does function X call?
dependenciesnameWhat does X depend on? (multi-hop)
dependentsnameWhat depends on X? (multi-hop)
type_hierarchynameInheritance chain (extends/implements)
impact_analysisnameWhat breaks if X changes? (with edges)
file_structurefile_pathAll entities in a file
symbol_lookupnameFind entity by name (case-insensitive)
communitycommunity_idAll entities in a cluster
tests_fornameTests for function X
unused_exportsExported symbols with no references
circular_depsCircular import dependencies
api_routesAll API endpoints
data_flownameRead/write chain for a variable

Response 200

{
  "nodes": [
    {
      "id": "abc123:Function:handleLogin",
      "type": "Function",
      "name": "handleLogin",
      "file_path": "src/auth/login.ts",
      "blob_sha": "abc123...",
      "start_line": 15,
      "end_line": 42,
      "signature": "async function handleLogin(req: Request): Promise<Response>",
      "language": "typescript",
      "exported": true,
      "complexity": 8,
      "community_id": null
    }
  ],
  "edges": [
    {
      "source_id": "abc123:Function:handleLogin",
      "target_id": "def456:Function:createUser",
      "type": "CALLS"
    }
  ],
  "query_type": "callers",
  "ref": "main"
}

edges is only present for impact_analysis queries. The X-Cache header indicates whether the result was served from cache.

Node Types

Function, Class, Interface, Enum, Type, Variable, Module, Decorator, Test, Route, Comment, File

Edge Types

CALLS, IMPORTS, EXTENDS, IMPLEMENTS, CONTAINS, EXPORTS, USES_TYPE, RETURNS_TYPE, OVERRIDES, DECORATES, TESTS, MEMBER_OF, READS, WRITES, THROWS, DOCUMENTS

Combines semantic search (AI embeddings), graph search (structural symbol lookup), and keyword search into a single fused result set.

POST /v1/repos/:slug/hybrid-search
{
  "q": "authentication handler",
  "ref": "main",
  "strategy": "auto",
  "top_k": 10,
  "include_graph": false
}
FieldRequiredDescription
qYesSearch query (max 1000 chars)
refNoBranch or commit SHA
strategyNoauto (default), semantic, graph, or hybrid
top_kNoNumber of results (default: 10, max: 50)
include_graphNoInclude graph relationships for top results

Strategy Weights

With auto strategy, the query is classified and weights are set accordingly:

Query PatternSemanticGraphKeyword
Structural ("calls", "depends")0.10.80.1
Symbol-like (camelCase, dots)0.10.30.6
Natural language (default)0.60.20.2
Impact ("breaks", "affects")0.20.70.1

Response 200

{
  "results": [
    {
      "file_path": "src/auth/login.ts",
      "name": "handleLogin",
      "type": "Function",
      "score": 0.85,
      "sources": ["semantic", "graph"],
      "start_line": 15,
      "end_line": 42,
      "language": "typescript",
      "signature": "async function handleLogin(req: Request)"
    }
  ],
  "query": "authentication handler",
  "ref": "main",
  "strategy_used": "semantic"
}

The sources array shows which retrievers contributed to each result.

Delete Graph Index

DELETE /v1/repos/:slug/graph/index

Permission: Write access required.

Response 200

{
  "status": "deleted"
}

Auto-Indexing

When a repository has auto_index: true, both semantic and graph indexes are updated automatically on each commit. No manual reindex needed.

SDK Examples

import { createCoregitClient } from "@coregit/sdk";

const git = createCoregitClient({ apiKey: "cgk_..." });

// Trigger graph reindex
await git.graph.triggerIndex("my-app", { branch: "main" });

// Check status
const status = await git.graph.indexStatus("my-app");
console.log(status.data);

// Query: who calls createUser?
const callers = await git.graph.query("my-app", {
  type: "callers",
  name: "createUser",
});
console.log(callers.data?.nodes);

// Query: what breaks if I change UserModel?
const impact = await git.graph.query("my-app", {
  type: "impact_analysis",
  name: "UserModel",
  max_depth: 3,
});
console.log(impact.data?.nodes, impact.data?.edges);

// Hybrid search
const results = await git.graph.hybridSearch("my-app", {
  q: "authentication handler",
  strategy: "auto",
  top_k: 10,
});
console.log(results.data?.results);

// Hybrid search with graph relationships
const detailed = await git.graph.hybridSearch("my-app", {
  q: "payment processing",
  include_graph: true,
});
console.log(detailed.data?.results[0]?.relationships);

On this page