Skip to content

SCIP API

The SCIP API provides precise code intelligence features like go-to-definition and find-references, powered by language-specific indexers.

SCIP (Source Code Intelligence Protocol) enables precise code navigation by building a semantic index of your code. Unlike text-based search, SCIP understands the structure of your code and can:

  • Navigate to the exact definition of a symbol
  • Find all references to a function, class, or variable
  • Provide accurate results even for symbols with common names

Go to Definition

Jump to where a symbol is defined

Find References

Find all usages of a symbol

Multi-language

Supports Go, TypeScript, Java, Rust, Python, PHP

Upload Indexes

Build indexes in CI and upload them

SCIP indexers must be installed on the machine running the API server (or you can build indexes externally and upload them).

Terminal window
go install github.com/sourcegraph/scip-go@latest

Make sure $(go env GOPATH)/bin is in your PATH.

Terminal window
npm install -g @sourcegraph/scip-typescript

Or use npx (the indexer will use this automatically):

Terminal window
npx -y @sourcegraph/scip-typescript index
Terminal window
# Using Coursier
cs install scip-java

Uses rust-analyzer. Install via your package manager or:

Terminal window
rustup component add rust-analyzer
Terminal window
pip install scip-python

PHP uses per-project installation via Composer:

Terminal window
composer require --dev davidrjenni/scip-php
GET /api/v1/scip/indexers

Returns which indexers are available on the system.

Terminal window
curl "http://localhost:8080/api/v1/scip/indexers"
{
"available": {
"go": true,
"typescript": true,
"javascript": true,
"java": false,
"rust": false,
"python": false,
"php": false
},
"supported": ["go", "typescript", "javascript", "java", "rust", "python", "php"],
"instructions": {
"go": "go install github.com/sourcegraph/scip-go@latest",
"typescript": "npm install -g @sourcegraph/scip-typescript",
"java": "cs install scip-java",
"rust": "rustup component add rust-analyzer",
"python": "pip install scip-python",
"php": "composer require --dev davidrjenni/scip-php"
}
}

Check if a repository has a SCIP index.

GET /api/v1/scip/repos/{id}/status
Terminal window
curl "http://localhost:8080/api/v1/scip/repos/1/status"
{
"has_index": true,
"available_indexers": {
"go": true,
"typescript": true
},
"stats": {
"total_files": 156,
"total_symbols": 2340,
"total_occurrences": 15678,
"indexed_at": "2024-01-15T10:30:00Z"
}
}

Run SCIP indexing on a repository.

POST /api/v1/scip/repos/{id}/index
ParameterTypeRequiredDescription
languagestringNoLanguage to index (auto-detected if not specified)
Terminal window
curl -X POST "http://localhost:8080/api/v1/scip/repos/1/index" \
-H "Content-Type: application/json" \
-d '{"language": "go"}'
{
"success": true,
"language": "go",
"duration": "2.5s",
"files": 156,
"symbols": 2340,
"occurrences": 15678,
"output": "Indexing completed successfully"
}
{
"success": false,
"language": "go",
"error": "scip-go not found in PATH. Install with: go install github.com/sourcegraph/scip-go@latest",
"output": ""
}

Upload a pre-built SCIP index file. This is useful for:

  • Docker deployments where indexers aren’t installed
  • Building indexes in CI pipelines
  • Large repositories where indexing takes too long
POST /api/v1/scip/repos/{id}/upload
Content-Type: application/octet-stream
Terminal window
# Clone the repository
git clone https://github.com/myorg/myrepo
cd myrepo
# Build the SCIP index
scip-go --output index.scip
# Upload to Code Search (replace {id} with your repo ID)
curl -X POST "http://localhost:8080/api/v1/scip/repos/{id}/upload" \
--data-binary @index.scip
{
"success": true,
"message": "SCIP index uploaded successfully",
"stats": {
"total_files": 156,
"total_symbols": 2340,
"total_occurrences": 15678
}
}

Find the definition of a symbol at a given position.

POST /api/v1/scip/repos/{id}/definition
ParameterTypeRequiredDescription
filePathstringYesPath to the file in the repository
lineintegerYesLine number (1-indexed)
columnintegerYesColumn number (0-indexed)
Terminal window
curl -X POST "http://localhost:8080/api/v1/scip/repos/1/definition" \
-H "Content-Type: application/json" \
-d '{
"filePath": "internal/search/search.go",
"line": 42,
"column": 15
}'
{
"found": true,
"symbol": "scip-go gomod github.com/myorg/api v1.0.0 internal/search/Search#Query().",
"definition": {
"symbol": "scip-go gomod github.com/myorg/api v1.0.0 internal/search/Search#Query().",
"filePath": "internal/search/search.go",
"startLine": 15,
"startCol": 0,
"endLine": 15,
"endCol": 5,
"role": 1,
"context": "func (s *Search) Query(ctx context.Context, q string) ([]Result, error) {"
},
"info": {
"symbol": "scip-go gomod github.com/myorg/api v1.0.0 internal/search/Search#Query().",
"documentation": "Query executes a search query and returns results.",
"kind": 6,
"displayName": "Query"
},
"external": false
}
FieldTypeDescription
foundbooleanWhether a definition was found
symbolstringThe SCIP symbol identifier
definitionobjectLocation of the definition
infoobjectSymbol metadata (documentation, kind, etc.)
externalbooleanTrue if definition is in an external package

Find all references to a symbol at a given position.

POST /api/v1/scip/repos/{id}/references
ParameterTypeRequiredDescription
filePathstringYesPath to the file in the repository
lineintegerYesLine number (1-indexed)
columnintegerYesColumn number (0-indexed)
limitintegerNoMaximum references to return (default: 100)
Terminal window
curl -X POST "http://localhost:8080/api/v1/scip/repos/1/references" \
-H "Content-Type: application/json" \
-d '{
"filePath": "internal/search/search.go",
"line": 15,
"column": 10,
"limit": 50
}'
{
"found": true,
"symbol": "scip-go gomod github.com/myorg/api v1.0.0 internal/search/Search#Query().",
"definition": {
"filePath": "internal/search/search.go",
"startLine": 15,
"startCol": 0,
"endLine": 15,
"endCol": 5,
"role": 1,
"context": "func (s *Search) Query(ctx context.Context, q string) ([]Result, error) {"
},
"references": [
{
"filePath": "cmd/api/handlers/search.go",
"startLine": 42,
"startCol": 15,
"endLine": 42,
"endCol": 20,
"role": 8,
"context": " results, err := s.search.Query(ctx, req.Query)"
},
{
"filePath": "internal/search/search_test.go",
"startLine": 28,
"startCol": 18,
"endLine": 28,
"endCol": 23,
"role": 8,
"context": " results, err := search.Query(ctx, \"test\")"
}
],
"totalCount": 2
}

Search for symbols by name in a repository’s SCIP index.

POST /api/v1/scip/repos/{id}/symbols/search
ParameterTypeRequiredDescription
querystringYesSymbol name pattern to search
limitintegerNoMaximum results (default: 100)
Terminal window
curl -X POST "http://localhost:8080/api/v1/scip/repos/1/symbols/search" \
-H "Content-Type: application/json" \
-d '{"query": "Query", "limit": 10}'
{
"results": [
{
"symbol": "scip-go gomod github.com/myorg/api v1.0.0 internal/search/Search#Query().",
"name": "Query",
"kind": "function",
"filePath": "internal/search/search.go",
"line": 15
}
],
"count": 1
}

List all files in a repository’s SCIP index.

GET /api/v1/scip/repos/{id}/files
ParameterTypeRequiredDescription
limitintegerNoMaximum files (default: 100)
Terminal window
curl "http://localhost:8080/api/v1/scip/repos/1/files?limit=10"
{
"files": [
"cmd/api/main.go",
"internal/search/search.go",
"internal/search/search_test.go"
],
"count": 3
}

Remove the SCIP index for a repository.

DELETE /api/v1/scip/repos/{id}/index
Terminal window
curl -X DELETE "http://localhost:8080/api/v1/scip/repos/1/index"
{
"success": true,
"message": "SCIP index cleared"
}

The default Docker images don’t include SCIP indexers. You have two options:

Build SCIP indexes in your CI pipeline or locally, then upload them:

Terminal window
# Build locally
scip-go --output index.scip
# Upload to the server
curl -X POST "http://code-search:8080/api/v1/scip/repos/{id}/upload" \
--data-binary @index.scip

Create a custom Dockerfile that includes the indexers:

FROM code-search-api:latest
# Install Go and scip-go
RUN apk add --no-cache go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$PATH
RUN go install github.com/sourcegraph/scip-go@latest