Sourcegraph API

Starting in Sourcegraph 7.0, a new versioned external API is being introduced for custom integrations (see the announcement). The currently available API surface can be seen in /api-reference (e.g. https://sourcegraph.example.com/api-reference). From this page, integrators can view the available operations and download the OpenAPI schema. We are committed to supporting integrations built on top of these new APIs with backwards compatibility and migration assistance for breaking changes.

The new Sourcegraph API is a work in progress, and capabilities are gradually being ported over. If you have an integration you'd like to build that is not currently served by the new Sourcegraph API, please reach out at support@sourcegraph.com.

For specific types of integrations, Sourcegraph also offers the following APIs:

For diagnostics use cases, the Sourcegraph GraphQL debug API is also available without any compatibility guarauntees.

The Sourcegraph GraphQL API has historically been an internal interface without formal compatibility guarantees. For external integrations, Sourcegraph 7.0 introduces a new, supported API at /api-reference. The GraphQL API remains available, but we recommend migrating to the new API for a stable integration experience.

If you have a use case that is not currently served by the new Sourcegraph API, please reach out at support@sourcegraph.com.

Tracking integration usage

If you'd like our help breaking down and analyzing API usage across different integrations, include some or all of the following headers in your requests:

  • X-Requested-With: <your-app-name>/<version> — a stable identifier for the calling integration
  • X-Sourcegraph-API-Client-Name: <caller-name> — the caller's name, for example, my-integration
  • X-Sourcegraph-API-Client-Feature: <feature-or-tool> — the feature or tool making the request, so that different call sites from the same integration are distinguishable
  • X-Sourcegraph-API-Client-Version: <version> — the integration's build or version

When an API request triggers a telemetry event, Sourcegraph includes the values of these headers in the event.

Previous
Editor integrations