Skip to main content

GoogleWebSearchService

Namespace: Wisej.AI.Services

Assembly: Wisej.AI

Represents a web search service using Google's Custom Search API.

public class GoogleWebSearchService : WebSearchServiceBase

This class extends the WebSearchServiceBase to provide functionality for performing web searches using Google's Custom Search API.

Constructors​

GoogleWebSearchService(engineID, url)​

Initializes a new instance of the GoogleWebSearchService class.

NameTypeDescription
engineIDStringThe unique identifier for the search engine.
urlStringThe base URL for the Google Custom Search API. Default is "https://www.googleapis.com/customsearch/v1".

Properties​

Authentication​

String: Gets the authentication method for the service. (Default: "api-key")

This property returns null as authentication is handled via API keys in the request URL.

Methods​

SearchAsync(query)​

Performs an asynchronous web search using the specified query.

ParameterTypeDescription
queryStringThe search query string.

Returns: Task<String>. A task that represents the asynchronous operation. The task result contains the search results as a formatted string.

This method sends a request to the Google Custom Search API and processes the response to extract and format the search results.


var service = new GoogleWebSearchService("your-engine-id");
string results = await service.SearchAsync("example query");
Console.WriteLine(results);

Implements​

NameDescription
IWebSearchServiceRepresents a service for performing web searches.