> 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/built-in-services/iwebsearchservice.md).

# IWebSearchService

## Overview

The [IWebSearchService](/ai/components/api/services/iwebsearchservice.md) offers web search capabilities. Currently, the only implemented consumer of this service is the [`WebSearchTools`](/ai/components/api/tools/wisej.ai.tools.websearchtools.md). However, you can also incorporate this service into your own tools as needed.

Implementing this service is straightforward, as it requires only a single property and one method. The property, `MaxSites`, is used to limit the number of search results returned. The [SearchAsync(query)](/ai/components/api/services/iwebsearchservice.md#searchasync-query) method is responsible for returning the search results.

The result is a single string that is included in the RAG (Retrieve-and-Generate) context. You can format this string as you wish, but it's essential that the AI can discern both the URL and a snippet or abstract text from it. The built-in services typically format the result as follows:

```
URL: url
Abstract: text
===
```

## Default Implementation

The IWebSearchService interface offers several built-in implementations: [BingWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bingwebsearchservice.md), [BraveWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bravewebsearchservice.md), and [GoogleWebSearchService](/ai/components/api/services/iwebsearchservice/wisej.ai.services.googlewebsearchservice.md).

You can download the [`BingWebSearchService` ](/ai/components/api/services/iwebsearchservice/wisej.ai.services.bingwebsearchservice.md)implementation below, which serves as a basic guideline for setting up your own web search service.

{% file src="/files/rAc7PaYl2sFjb7cm2OkR" %}

{% file src="/files/ldhckdxKF1jJAPP5cUcr" %}

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

<pre class="language-csharp"><code class="lang-csharp">internal static class Program
<strong>{
</strong>  static Program()
  {
    Application.Services
      .AddOrReplaceService&#x3C;IWebSearchService, MySerpAPIService>();
  }
}
</code></pre>

{% endtab %}

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

```vbnet
Module Program
    Shared Sub New()
        Application.Services.AddOrReplaceService( _
            Of IWebSearchService, MySerpAPIService)()
    End Sub
End Class
```

{% endtab %}
{% endtabs %}


---

# 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/built-in-services/iwebsearchservice.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.
