Skip to main content
POST
/
search
Search repositories with natural language queries.
curl --request POST \
  --url https://api.greptile.com/v2/search \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-GitHub-Token: <api-key>' \
  --data '{
  "query": "<string>",
  "repositories": [
    {
      "remote": "<string>",
      "branch": "<string>",
      "repository": "<string>"
    }
  ],
  "sessionId": "<string>",
  "stream": true
}'
[
  {
    "repository": "<string>",
    "remote": "<string>",
    "branch": "<string>",
    "filepath": "<string>",
    "linestart": 123,
    "lineend": 123,
    "summary": "<string>",
    "distance": 123
  }
]
Submit a natural language search query to find relevant code references without generating an AI response. Returns a list of relevant code files, functions, and snippets based on your search query, similar to the query endpoint but without the AI-generated answer. Use this endpoint when you only need the source references and don’t need an AI explanation. Note: Before Greptile can search a repo, it must be indexed. See Index Repository for more information.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

X-GitHub-Token
string
header
required

Body

application/json
query
string

Natural language search query to find the right code in the repo.

repositories
object[]

List of repos that Greptile should reference while answering your question.

sessionId
string

Optional, defaults to a new session. You only need this if you want to retrieve this query/response later.

stream
boolean

Optional, default false.

Response

200 - application/json

Query executed successfully. Response may be streamed.

repository
string

The name of the repository where the file resides.

remote
string

The remote service or platform where the repository is hosted.

branch
string

The branch of the repository where the file is found.

filepath
string

The relative path to the file within the repository.

linestart
integer | null

The starting line number of the code that is relevant, if applicable.

lineend
integer | null

The ending line number of the code that is relevant, if applicable.

summary
string

A summary or description of the contents and functionalities of the file.

distance
number | null

Similarity score for the source returned by the API. Lower values indicate higher similarity.

⌘I