Skip to content

Search API

The Search API allows you to search across all indexed repositories.

Search for code across repositories.

POST /api/v1/search
ParameterTypeRequiredDescription
querystringYesSearch query
is_regexbooleanNoTreat query as regular expression
case_sensitivebooleanNoCase-sensitive search
reposstring[]NoFilter by repository names (regex patterns)
languagesstring[]NoFilter by languages
file_patternsstring[]NoFilter by file patterns (e.g., *.go)
limitintegerNoMax results (default: unlimited)
context_linesintegerNoLines of context before/after (default: 2)
Terminal window
curl -X POST "http://localhost:8080/api/v1/search" \
-H "Content-Type: application/json" \
-d '{
"query": "handleRequest",
"languages": ["go", "typescript"],
"limit": 100
}'
{
"results": [
{
"repo": "github.com/myorg/api",
"file": "src/handlers/request.go",
"line": 42,
"column": 5,
"content": "func handleRequest(w http.ResponseWriter, r *http.Request) {",
"context": {
"before": ["", "// handleRequest processes incoming HTTP requests"],
"after": [" ctx := r.Context()", " logger := log.FromContext(ctx)"]
},
"language": "go",
"match_start": 5,
"match_end": 18
}
],
"total_count": 156,
"truncated": false,
"duration": "23ms",
"stats": {
"files_searched": 15234,
"repos_searched": 45
}
}
FieldTypeDescription
resultsarrayList of search results
results[].repostringRepository name (with host)
results[].filestringFile path
results[].lineintegerLine number
results[].columnintegerColumn position of match
results[].contentstringLine content
results[].contextobjectLines before/after the match
results[].languagestringDetected language
results[].match_startintegerStart position of match in line
results[].match_endintegerEnd position of match in line
total_countintegerTotal number of matches
truncatedbooleanWhether results were truncated
durationstringSearch duration (e.g., “23ms”)
statsobjectSearch statistics

For real-time results, use the streaming endpoint:

POST /api/v1/search/stream

Returns Server-Sent Events (SSE) with events:

  • progress - Search progress updates
  • result - Individual search results
  • done - Search complete with summary
  • error - Error occurred

Get autocomplete suggestions for the search bar:

GET /api/v1/search/suggestions

Returns available repositories, languages, and filter keywords.

The search query supports special operators:

{"query": "handleRequest"}

Searches for the literal string.

Enable with is_regex: true:

{"query": "func.*Handler", "is_regex": true}

Enable with case_sensitive: true:

{"query": "HandleRequest", "case_sensitive": true}

Use repos array with regex patterns:

{"query": "handler", "repos": ["^github\\.com/myorg/api$"]}
{"query": "handler", "languages": ["go", "typescript"]}
{"query": "handler", "file_patterns": ["*.go", "src/**/*.ts"]}
Terminal window
# Basic search
curl -X POST "http://localhost:8080/api/v1/search" \
-H "Content-Type: application/json" \
-d '{"query": "handleRequest"}'
# With filters
curl -X POST "http://localhost:8080/api/v1/search" \
-H "Content-Type: application/json" \
-d '{"query": "handleRequest", "languages": ["go"], "limit": 50}'
# Regex search
curl -X POST "http://localhost:8080/api/v1/search" \
-H "Content-Type: application/json" \
-d '{"query": "func.*Handler", "is_regex": true}'
{
"error": {
"code": "invalid_query",
"message": "Query is required",
"details": {
"parameter": "q"
}
}
}
{
"error": {
"code": "invalid_regex",
"message": "Invalid regular expression",
"details": {
"pattern": "[invalid(",
"position": 8
}
}
}
  1. Use specific queries: More specific queries are faster
  2. Filter by repository: Reduces search scope
  3. Filter by language: Reduces files to search
  4. Limit results: Use pagination appropriately