Skip to main content
POST
/
api
/
search
Search code
curl --request POST \
  --url https://api.example.com/api/search \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "query": "<string>",
  "matches": 123,
  "contextLines": 123,
  "whole": true,
  "isRegexEnabled": true,
  "isCaseSensitivityEnabled": true
}
'
{
  "stats": {
    "actualMatchCount": 123,
    "totalMatchCount": 123,
    "duration": 123,
    "fileCount": 123,
    "filesSkipped": 123,
    "contentBytesLoaded": 123,
    "indexBytesLoaded": 123,
    "crashes": 123,
    "shardFilesConsidered": 123,
    "filesConsidered": 123,
    "filesLoaded": 123,
    "shardsScanned": 123,
    "shardsSkipped": 123,
    "shardsSkippedFilter": 123,
    "ngramMatches": 123,
    "ngramLookups": 123,
    "wait": 123,
    "matchTreeConstruction": 123,
    "matchTreeSearch": 123,
    "regexpsConsidered": 123,
    "flushReason": "<string>"
  },
  "files": [
    {
      "fileName": {
        "text": "<string>",
        "matchRanges": [
          {
            "start": {
              "byteOffset": 123,
              "lineNumber": 123,
              "column": 123
            },
            "end": {
              "byteOffset": 123,
              "lineNumber": 123,
              "column": 123
            }
          }
        ]
      },
      "webUrl": "<string>",
      "repository": "<string>",
      "repositoryId": 123,
      "language": "<string>",
      "chunks": [
        {
          "content": "<string>",
          "matchRanges": [
            {
              "start": {
                "byteOffset": 123,
                "lineNumber": 123,
                "column": 123
              },
              "end": {
                "byteOffset": 123,
                "lineNumber": 123,
                "column": 123
              }
            }
          ],
          "contentStart": {
            "byteOffset": 123,
            "lineNumber": 123,
            "column": 123
          },
          "symbols": [
            {
              "symbol": "<string>",
              "kind": "<string>",
              "parent": {
                "symbol": "<string>",
                "kind": "<string>"
              }
            }
          ]
        }
      ],
      "externalWebUrl": "<string>",
      "branches": [
        "<string>"
      ],
      "content": "<string>"
    }
  ],
  "repositoryInfo": [
    {
      "id": 123,
      "codeHostType": "github",
      "name": "<string>",
      "displayName": "<string>",
      "webUrl": "<string>"
    }
  ],
  "isSearchExhaustive": true
}

Usage

The query field supports literal, regexp, and symbol searches with filters for repository, file, language, branch, and more. See the search syntax reference for the full query language.

Authorizations

Authorization
string
header
required

Send either a Sourcebot API key (sbk_...) or, on EE instances with OAuth enabled, an OAuth access token (sboa_...) in the Authorization header.

Body

application/json
query
string
required
matches
number
required
contextLines
number
whole
boolean
isRegexEnabled
boolean
isCaseSensitivityEnabled
boolean

Response

Search results.

stats
object
required
files
object[]
required
repositoryInfo
object[]
required
isSearchExhaustive
boolean
required