OriginService

POST /v1/origin/repos/{ownerSlug}/{repoName}:grep

Searches the text of the files in the repository at a ref and returns the lines that match, plus any requested surrounding context lines. The search is line-oriented: a pattern never matches across a line break, and each returned entry is one line. The response is complete only when limit_hit is false; see max_results. An empty repository (no refs) returns no matches and limit_hit false. Uses POST because the search parameters travel in the request body.

Request

  • Base URL
    https://api.cursor.com
  • Auth
    HTTP bearer

Path parameters

ownerSlugstring required

Owning entity's unique slug.

repoNamestring required

Repo name, unique to the owner entity.

Request body

refstring

Commit, branch, tag, or symbolic ref (for example HEAD) to search. Empty means the repository's default branch.

querystring required

The pattern to search for. By default it is a regular expression supporting character classes, quantifiers, alternation, groups, and anchors; set literal to search for the text exactly instead. Whitespace is significant and is searched for as given. When literal is false, case-insensitive matching is a leading (?i) in the pattern (for example (?i)launch) and whole-word matching is \b around it (for example \blaunch\b). An empty pattern is rejected with INVALID_ARGUMENT. Maximum UTF-8 size: 4096 bytes.

literalboolean

Search for query as exact text rather than as a regular expression.

caseInsensitiveboolean

Match upper and lower case as equivalent. Applied only when literal is true. Ignored for a regular-expression search; write a leading (?i) in query instead.

wholeWordboolean

Match only complete words. Applied only when literal is true. Ignored for a regular-expression search; write \b around the pattern instead.

contextBeforeinteger

How many lines immediately before each matching line to return as context. Values above 10 are reduced to 10.

contextAfterinteger

How many lines immediately after each matching line to return as context. Values above 10 are reduced to 10.

filterPathstring

Restrict the search to this file or directory, relative to the repository root. Empty searches the whole repository. Maximum UTF-8 size: 4096 bytes.

includesstring[]

Glob patterns naming the paths to search. Matching is case-insensitive; a pattern containing no / matches at any depth, * matches within one path segment, and ** matches across segments. When any include is present, a path matching none of them is not searched. At most 20 entries. Maximum UTF-8 size per pattern: 4096 bytes.

excludesstring[]

Glob patterns naming paths to leave out, in the same syntax as includes. An exclude beats an include, and excluding a directory leaves out everything beneath it. At most 20 entries. Maximum UTF-8 size per pattern: 4096 bytes.

maxResultsinteger

The most matching occurrences to return. Zero requests the default of 1000, and values above 1000 are reduced to 1000. Context lines do not count toward the cap.

Response

OK

limitHitboolean

Whether the search reached max_results. Narrow query, filter_path, or the glob lists to search a smaller set of files.

Changes

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