source-graph-stream-client
    Preparing search index...

    Class SourceGraphClient

    Client for interacting querying Sourcegraph's search streaming API.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    headers: Headers

    Methods

    • Returns the raw SSE messages from Sourcegraph search API

      The Sourcegraph messages are stringified JSON objects, this method parses the objects so that the data field of each message is an object (or array) instead of a string. In case of parsing error, the original string is kept.

      Parameters

      Returns AsyncGenerator<SSEMessage>

    • Search Sourcegraph with the given query. Returns an async generator yielding search results as they are received.

      Parameters

      Returns AsyncGenerator<SearchResult>

      const client = new SourceGraphClient({
      url: "https://example.sourcegraph.com/.api/search/stream",
      accessToken: "your-token
      });

      for await (const result of client.search("search-term")) {
      console.log(result);
      }