> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/brave.md).

# Brave

Brave Search is a search engine service built on an independent index by Brave. It does not rely on third-party indexes such as Google or Bing, and has strong privacy protection features. Its Search API supports web search, news search, image search, and video search, suitable for data retrieval in AI applications.

## MCP Tools

### Web Search

Search web content from an independent large-scale web index.

#### Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`

**Body Parameters**

* `q` (string, required): User search query, cannot be empty, max 400 characters / 50 words | Example: `Brave Search`
* `country` (string, optional): 2-letter country code for search results | Example: `US`
* `search_lang` (string, optional): 2+ character language code for search results | Example: `en`
* `ui_lang` (string, optional): Preferred UI language in the response, usually `<language_code>-<country_code>` format | Example: `en-US`
* `count` (integer, optional): Number of search results to return, max 20. Actual count may be less than requested. Applies only to web results | Default: `10`
* `offset` (integer, optional): Zero-based offset to skip result pages, max 9. Used with `count` for pagination | Default: `0`
* `safesearch` (string, optional): Filter adult content. Options: `off` (no filter), `moderate` (filter explicit content but keep adult domains), `strict` (fully filter adult content) | Default: `moderate`
* `spellcheck` (boolean, optional): Whether to spellcheck the query, always uses corrected query when enabled | Default: `false`
* `freshness` (string, optional): Filter results by page date. Options: `pd` (24h), `pw` (7d), `pm` (31d), `py` (365d), `YYYY-MM-DDtoYYYY-MM-DD` (custom range)
* `text_decorations` (boolean, optional): Whether to include decorations like highlights in result excerpts | Default: `false`
* `result_filter` (string\[], optional): Comma-separated list of result types. Options: `discussions`, `faq`, `infobox`, `news`, `query`, `summarizer`, `videos`, `web`, `locations`
* `units` (string, optional): Units of measurement. Options: `metric`, `imperial`
* `extra_snippets` (boolean, optional): Whether to return up to 5 extra excerpt snippets | Default: `false`
* `summary` (boolean, optional): Whether to enable summary key generation in web search results (required for summarizer feature) | Default: `false`

### News Search

Search news content from an independent large-scale web index.

#### Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`

**Body Parameters**

* `q` (string, required): User search query, max 400 characters / 50 words | Example: `machine learning`
* `country` (string, optional): 2-letter country code, or `ALL` for global | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `ui_lang` (string, optional): Preferred UI language
* `safesearch` (string, optional): Filter adult content. Options: `off`, `moderate`, `strict` | Default: `moderate`
* `count` (integer, optional): Number of news results, max 50 | Default: `10`
* `offset` (integer, optional): Pages to skip, max 9. Used with `count` for pagination | Default: `0`
* `spellcheck` (boolean, optional): Whether to enable spellcheck | Default: `false`
* `freshness` (string, optional): Time filter. Options: `pd` (24h), `pw` (7d), `pm` (31d), `py` (365d), `YYYY-MM-DDtoYYYY-MM-DD`
* `extra_snippets` (boolean, optional): Whether to return up to 5 extra snippets | Default: `false`

### Image Search

Search images from an independent large-scale image index.

#### Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`

**Query Parameters**

* `q` (string, required): User search query, max 400 characters / 50 words | Example: `mountain landscape`
* `country` (string, optional): 2-letter country code, or `ALL` for global | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `safesearch` (string, optional): Content filter. Options: `off` (only filter illegal content), `strict` (filter all adult content) | Default: `strict`
* `count` (integer, optional): Number of results, max 200 | Default: `10`
* `spellcheck` (boolean, optional): Whether to enable spellcheck | Default: `false`

### Video Search

Search video content from an independent large-scale web index.

#### Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`

**Body Parameters**

* `q` (string, required): User search query, max 400 characters / 50 words | Example: `machine learning tutorial`
* `country` (string, optional): 2-letter country code, or `ALL` for global | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `ui_lang` (string, optional): Preferred UI language
* `safesearch` (string, optional): Filter adult content. Options: `off`, `moderate`, `strict` | Default: `moderate`
* `count` (integer, optional): Number of results, max 50 | Default: `10`
* `offset` (integer, optional): Pages to skip, max 9 | Default: `0`
* `spellcheck` (boolean, optional): Whether to enable spellcheck | Default: `false`
* `freshness` (string, optional): Time filter. Options: `pd` (24h), `pw` (7d), `pm` (31d), `py` (365d), `YYYY-MM-DDtoYYYY-MM-DD`

### MCP Cline Configuration

This server needs to be configured through your MCP client. Here is an example:

Replace your Tenant ID and API Key (required)

```
{
  "mcpServers": {
    "brave": {
      "type": "streamable_http",
      "url": "https://mcp.ecn.ai/{Tenant ID}/brave/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

## API

### Web Search

#### Request Information

* **Method**: POST
* **Endpoint**: `/brave/res/v1/web/search`

#### Request Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`
* `Content-Type` (string, required): `application/json`

**Body Parameters**

* `q` (string, required): Search query, max 400 characters / 50 words | Example: `Brave Search`
* `country` (string, optional): 2-letter country code | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `ui_lang` (string, optional): UI language code | Example: `en-US`
* `count` (integer, optional): Number of results, max 20 | Default: `10`
* `offset` (integer, optional): Pagination offset, max 9 | Default: `0`
* `safesearch` (string, optional): Content filter level | Options: `off`, `moderate`, `strict`
* `spellcheck` (boolean, optional): Whether to enable spellcheck | Default: `false`
* `freshness` (string, optional): Time filter | Options: `pd`, `pw`, `pm`, `py`, `YYYY-MM-DDtoYYYY-MM-DD`
* `text_decorations` (boolean, optional): Whether to include excerpt decorations | Default: `false`
* `result_filter` (string, optional): Result type filter, comma-separated | Options: `discussions`, `faq`, `infobox`, `news`, `query`, `summarizer`, `videos`, `web`, `locations`
* `extra_snippets` (boolean, optional): Whether to return extra snippets | Default: `false`
* `summary` (boolean, optional): Whether to enable summary key generation | Default: `false`

#### Response

* **200 Success**
  * Content-Type: `application/json`

#### Request Example

```bash
curl --location --request POST 'https://api.ecn.ai/brave/res/v1/web/search' \
	--header 'Content-Type: application/json' \
	--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
	--data-raw '{
  "q": "Brave Search",
  "country": "US",
  "search_lang": "en",
  "count": 10
}'
```

#### Response Example

```json
{
  "type": "search",
  "query": {
    "original": "Brave Search",
    "altered": "",
    "spellcheck_off": false,
    "show_strict_warning": false
  },
  "web": {
    "type": "search",
    "results": [
      {
        "title": "Brave Search",
        "url": "https://search.brave.com",
        "description": "Brave Search is a privacy-preserving search engine...",
        "age": "2024-01-15T00:00:00Z",
        "extra_snippets": []
      }
    ]
  }
}
```

### News Search

#### Request Information

* **Method**: POST
* **Endpoint**: `/brave/res/v1/news/search`

#### Request Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`
* `Content-Type` (string, required): `application/json`

**Body Parameters**

* `q` (string, required): Search query | Example: `machine learning`
* `country` (string, optional): 2-letter country code or `ALL` | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `safesearch` (string, optional): Content filter level | Options: `off`, `moderate`, `strict`
* `count` (integer, optional): Number of results, max 50 | Default: `10`
* `offset` (integer, optional): Pagination offset, max 9 | Default: `0`
* `freshness` (string, optional): Time filter | Options: `pd`, `pw`, `pm`, `py`, `YYYY-MM-DDtoYYYY-MM-DD`
* `extra_snippets` (boolean, optional): Whether to return extra snippets | Default: `false`

#### Response

* **200 Success**
  * Content-Type: `application/json`

#### Request Example

```bash
curl --location --request POST 'https://api.ecn.ai/brave/res/v1/news/search' \
	--header 'Content-Type: application/json' \
	--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
	--data-raw '{
  "q": "machine learning",
  "country": "US",
  "search_lang": "en",
  "count": 20
}'
```

#### Response Example

```json
{
  "type": "news",
  "query": {
    "original": "machine learning"
  },
  "results": [
    {
      "title": "Latest Advances in Machine Learning",
      "url": "https://example.com/ml-news",
      "description": "Researchers have developed...",
      "age": "2024-03-10T08:00:00Z",
      "source": "TechNews"
    }
  ]
}
```

### Image Search

#### Request Information

* **Method**: GET
* **Endpoint**: `/brave/res/v1/images/search`

#### Request Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`

**Query Parameters**

* `q` (string, required): Search query | Example: `mountain landscape`
* `country` (string, optional): 2-letter country code or `ALL` | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `safesearch` (string, optional): Content filter | Options: `off`, `strict`
* `count` (integer, optional): Number of results, max 200 | Default: `10`
* `spellcheck` (boolean, optional): Whether to enable spellcheck | Default: `false`

#### Response

* **200 Success**
  * Content-Type: `application/json`

#### Request Example

```bash
curl --location --request GET 'https://api.ecn.ai/brave/res/v1/images/search?q=mountain+landscape&count=10' \
	--header 'Authorization: Bearer {{YOUR_API_KEY}}'
```

#### Response Example

```json
{
  "type": "images",
  "query": {
    "original": "mountain landscape"
  },
  "results": [
    {
      "title": "Beautiful Mountain Landscape",
      "url": "https://example.com/image.jpg",
      "source": "https://example.com",
      "thumbnail": {
        "src": "https://example.com/thumb.jpg",
        "width": 200,
        "height": 150
      }
    }
  ]
}
```

### Video Search

#### Request Information

* **Method**: POST
* **Endpoint**: `/brave/res/v1/videos/search`

#### Request Parameters

**Header Parameters**

* `Authorization` (string, optional): API KEY | Example: `Bearer {{YOUR_API_KEY}}`
* `Content-Type` (string, required): `application/json`

**Body Parameters**

* `q` (string, required): Search query | Example: `machine learning tutorial`
* `country` (string, optional): 2-letter country code or `ALL` | Example: `US`
* `search_lang` (string, optional): Language code | Example: `en`
* `safesearch` (string, optional): Content filter level | Options: `off`, `moderate`, `strict`
* `count` (integer, optional): Number of results, max 50 | Default: `10`
* `offset` (integer, optional): Pagination offset, max 9 | Default: `0`
* `freshness` (string, optional): Time filter | Options: `pd`, `pw`, `pm`, `py`, `YYYY-MM-DDtoYYYY-MM-DD`

#### Response

* **200 Success**
  * Content-Type: `application/json`

#### Request Example

```bash
curl --location --request POST 'https://api.ecn.ai/brave/res/v1/videos/search' \
	--header 'Content-Type: application/json' \
	--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
	--data-raw '{
  "q": "machine learning tutorial",
  "country": "US",
  "search_lang": "en",
  "count": 20
}'
```

#### Response Example

```json
{
  "type": "videos",
  "results": [
    {
      "title": "Machine Learning Tutorial for Beginners",
      "url": "https://www.youtube.com/watch?v=example",
      "description": "Learn machine learning from scratch...",
      "publisher": "TechChannel"
    }
  ]
}
```


---

# 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:

```
GET https://docs.console.zenlayer.com/api-reference/compute/mcpg/web-search/brave.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
