---
title: "Get code from a remote public git repository — either a specific function/class by name, a line range, or a full file. PREFERRED WORKFLOW: When search results or findings have already identified a specific function, method, or class, use symbol_name to extract just that declaration. This avoids fetching entire files and keeps context focused. Only fetch full files when you need a broad understanding of a file you haven't seen before. For supported languages (Go, Python, TypeScript, JavaScript, Java, C, C++, C#, Kotlin, Swift, Rust) the response includes a symbols list of declarations with line ranges. This is not a first-call tool — use code_analyze or code_search first to identify targets, then extract precisely what you need."
method: POST
path: "/api/v1/code_get_file"
---

# Get code from a remote public git repository — either a specific function/class by name, a line range, or a full file. PREFERRED WORKFLOW: When search results or findings have already identified a specific function, method, or class, use symbol_name to extract just that declaration. This avoids fetching entire files and keeps context focused. Only fetch full files when you need a broad understanding of a file you haven't seen before. For supported languages (Go, Python, TypeScript, JavaScript, Java, C, C++, C#, Kotlin, Swift, Rust) the response includes a symbols list of declarations with line ranges. This is not a first-call tool — use code_analyze or code_search first to identify targets, then extract precisely what you need.

`POST /api/v1/code_get_file`

## Query parameters

- `client` string, required

## Request body

- object
  - `end_line` integer — Last line to return (inclusive). If omitted, returns to end of file. Cannot combine with symbol_name.
  - `include_adjacent_symbols` boolean — When true and symbol_name is set, includes structurally related declarations (nearby siblings) alongside the target symbol.
  - `max_lines` integer — Lines to return (max: 2000). When reading an unfamiliar file for orientation, set this to 2000. When you already know which function or class you need (from search or findings results), prefer symbol_name instead — it returns only the relevant declaration and avoids pulling unnecessary context.
  - `path` string, required — File path relative to repository root
  - `repository` string, required — Git URL of a public remote repository
  - `start_line` integer — First line to return (1-based). Cannot combine with symbol_name.
  - `symbol_name` string — PREFERRED for targeted retrieval. Name of a function/method/class to extract — returns only that declaration. Use this when search results or findings have pointed you to a specific symbol, instead of fetching the entire file. Cannot combine with start_line/end_line. Response includes a symbols list for supported languages.

## 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.dev/searchcode/apis/searchcode-rest-api.md) · [All operations](https://skmtc.dev/searchcode/apis/searchcode-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/searchcode/searchcode-rest-api/revisions/24a0730a30a6/schema)
