---
title: "Fast code search across any public git repo. Returns file paths, line numbers, and code snippets with context. Supports regex, boolean queries, fuzzy matching, and structural filters (declarations, usages, strings, comments). Dependency/build directories excluded by default."
method: POST
path: "/api/v1/code_search"
---

# Fast code search across any public git repo. Returns file paths, line numbers, and code snippets with context. Supports regex, boolean queries, fuzzy matching, and structural filters (declarations, usages, strings, comments). Dependency/build directories excluded by default.

`POST /api/v1/code_search`

## Query parameters

- `client` string, required

## Request body

- object
  - `case_sensitive` boolean — Whether to match case-sensitively.
  - `code_filter` 'only-code' | 'only-strings' | 'only-comments' | 'only-declarations' | 'only-usages' — Structural filter to narrow matches to specific code regions. only-declarations and only-usages use heuristic patterns and support 30+ languages (Go, Python, JS/TS, Rust, Java, C/C++, C#, Ruby, PHP, Kotlin, Swift, and more). For unsupported languages, all matches are classified as usages.
  - `context_lines` integer — Lines of context before and after each match.
  - `include_all_dirs` boolean — Include dependency/build/cache directories that are excluded by default (vendor, node_modules, third_party, target, build, dist, Pods, generated, etc.). Set to true if you need to search generated/vendored code.
  - `max_results` integer — Maximum number of file results to return (cap: 100).
  - `max_matches_per_file` integer — Maximum matches to show per file (cap: 50). Keeps responses compact for files with many hits. The response includes matches_in_file (total) so you know if more exist.
  - `offset` integer — Skip this many results before returning. Use for paging.
  - `query` string, required — Search query. Keywords are ANDed — use OR for exploratory multi-term searches (e.g. auth OR login OR session). Prefer single precise terms over multi-keyword phrases. Supports OR, NOT, "phrases", regex (/pattern/), fuzzy (term~1), file:, path:, lang:, ext: filters.
  - `repository` string, required — Git URL of a public remote repository
  - `snippet_mode` 'auto' | 'grep' | 'summary' — auto (ranked relevance), grep (every matching line), or summary (1 best match per file, no context — very compact). Use auto when exploring or discovering where something is used across a codebase (e.g. "how is authentication handled?"). Use grep when you know the exact identifier or string you want every occurrence of (e.g. "find all calls to parseConfig"). Use summary for broad queries where you want a compact overview of which files match.

## Response `200`

Successful response

- object

## Other responses

- `400` — Bad request (invalid params or missing client)
- `404` — Repository or file not found
- `429` — Rate limited
- `500` — Internal server error
- `502` — Bad gateway (upstream clone failure)
- `503` — Service unavailable (clone queue full)

---

[API](https://skmtc.net/searchcode/apis/searchcode-rest-api.md) · [All operations](https://skmtc.net/searchcode/apis/searchcode-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/searchcode/searchcode-rest-api/versions/24a0730a30a6/schema)
