Skip to main content

Sourcegraph API (experimental!)

You can use the mergestat command to query the Sourcegraph API.

Authenticating​

You must provide an authentication token in order to use the Sourcegraph API tables. You can create a personal access token following these instructions. The mergestat command will look for a SOURCEGRAPH_TOKEN environment variable when executing, to use for authentication. This is also true if running as a runtime loadable extension.

Table-valued-function that returns results from a Sourcegraph search.

ColumnType
__typenameTEXT
resultsTEXT

__typename will be one of Repository, CommitSearchResult, or FileMatch. results will be the JSON value of a search result (will match what's returned from the API)

Params:

  1. query - a sourcegraph search query (docs)
SELECT sourcegraph_search('mergestat');