> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md).

# GoogleWebSearchService

Namespace: **Wisej.AI.Services**

Assembly: **Wisej.AI** (3.5.0.0)

* [WebSearchServiceBase](https://github.com/iceteagroup/wisej-docs-ai/blob/master/components/api/websearchservicebase/README.md)
  * [GoogleWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md)

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

{% tabs %}
{% tab title="C#" %}

```csharp
public class GoogleWebSearchService : WebSearchServiceBase
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class GoogleWebSearchService
    Inherits WebSearchServiceBase
```

{% endtab %}
{% endtabs %}

This class extends the [WebSearchServiceBase](https://github.com/iceteagroup/wisej-docs-ai/blob/master/components/api/websearchservicebase/README.md) to provide functionality for performing web searches using Google's Custom Search API.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) GoogleWebSearchService(engineID, url)

Initializes a new instance of the [GoogleWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md) class.

| Name         | Type                                                          | Description                                                                                               |
| ------------ | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| **engineID** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The unique identifier for the search engine.                                                              |
| **url**      | [String](https://docs.microsoft.com/dotnet/api/system.string) | The base URL for the Google Custom Search API. Default is "<https://www.googleapis.com/customsearch/v1>". |

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) Authentication

[String](https://docs.microsoft.com/dotnet/api/system.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

### ![](/files/ptrKjmmRoQB76pvrIqh0) SearchAsync(query)

Performs an asynchronous web search using the specified query.

| Parameter | Type                                                          | Description              |
| --------- | ------------------------------------------------------------- | ------------------------ |
| **query** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The search query string. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). 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.

```csharp

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

```

## Implements

| Name                                                                  | Description                                       |
| --------------------------------------------------------------------- | ------------------------------------------------- |
| [IWebSearchService](/ai/components/api/services/iwebsearchservice.md) | Represents a service for performing web searches. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
