Code

Read repository file

Read the text content of a single file from a repository. Supports optional line-range selection via startLine/endLine to avoid fetching entire large files. The response indicates whether the content was truncated by the line range or by a byte-size limit. Supports GitHub and GitLab repositories (not Bitbucket).

post/api/v2/code/read

Request

  • Base URL
    https://zeropath.com
  • Auth
    API key in header X-ZeroPath-API-Token-Id and API key in header X-ZeroPath-API-Token-Secret

Request body

organizationIdstring

Organization that owns the repository.

repositoryIdstring required

Repository containing the file to read.

pathstring required

Full file path relative to the repository root (e.g. "src/main.py", "packages/api/index.ts").

refstring

Branch, tag, or commit SHA to read from. Omit to read from the repository's default branch.

startLineinteger

First line number to return (1-based, inclusive). Use with endLine to read a specific range instead of the whole file. Omit to start from line 1.

endLineinteger

Last line number to return (1-based, inclusive). Use with startLine to read a specific range. Omit to read to the end of the file (subject to byte-size truncation).

Response

File content

provider'github' | 'gitlab' required

Repository provider that served the request. Only providers with native code-inspection APIs are supported.

repositoryIdstring required
pathstring required
refstring nullable required
startLineinteger required
endLineinteger required
totalLinesinteger required
contentstring required
byteLengthinteger required
truncatedByLineRangeboolean required
truncatedByByteLimitboolean required
urlstring nullable required

Changes

No recorded changes to this operation across all 1 revision of this API.