# Google Search

> Google Custom Search API for performing web searches using a configured search engine.

Source: https://cotera.co/docs/reference/tools/individual-tools/google-search

---

**Authentication Type:** API Key
**Description:** Google Custom Search API for performing web searches using a configured search engine.

***

## Authentication

To authenticate, you'll need a Google Cloud API key with the Custom Search API enabled, and a Custom Search Engine ID (cx).

1. Create an API key in the [Google Cloud Console](https://console.cloud.google.com/apis/credentials)
2. Enable the [Custom Search API](https://console.cloud.google.com/apis/library/customsearch.googleapis.com)
3. Create a Custom Search Engine at [Programmable Search Engine](https://programmablesearchengine.google.com/)

***

## Web Search

Perform web searches using Google Custom Search API with customizable parameters.

### Search Web

Search the web using Google Custom Search. Requires a Custom Search Engine ID (cx) and supports various filtering options like language, country, date restrictions, and content types. Returns up to 10 results per request with title, snippet, URL, and metadata.

**Operation Type:** Query (Read)

**Parameters:**

* **q** `string` (required): Search query - the terms to search for
* **cx** `string` (required): Custom Search Engine ID - identifies which search engine to use. Defaults to "230935ee073314dc5"
* **num** `number` (nullable): Number of search results to return (1-10, default 10)
* **start** `number` (nullable): Index of the first result to return (1-based, max 91 for 10 results per page)
* **lr** `string` (nullable): Language restrict - restricts search to documents in a particular language
* **safe** `string` (nullable): Safe search setting - filters explicit content when active. Options: "active", "off"
* **cr** `string` (nullable): Country restrict - restricts search to documents from a particular country
* **dateRestrict** `string` (nullable): Date restrict - restricts results to a particular time period (e.g., "d1" for past day)
* **exactTerms** `string` (nullable): Exact terms that must appear in the search results
* **excludeTerms** `string` (nullable): Terms to exclude from search results
* **fileType** `string` (nullable): File type to restrict results to (e.g., "pdf", "doc")
* **filter** `string` (nullable): Filter duplicate content - "1" to filter, "0" to include duplicates
* **gl** `string` (nullable): Geolocation of end user - helps return region-appropriate results
* **hl** `string` (nullable): Interface language - language for the search interface
* **orTerms** `string` (nullable): Additional search terms with OR logic
* **relatedSite** `string` (nullable): Site to find related pages for
* **rights** `string` (nullable): Licensing filter - filters results by usage rights
* **searchType** `string` (nullable): Search type - set to null for web search, set to "image" for image search
* **siteSearch** `string` (nullable): Site to search within - restricts results to a specific site
* **siteSearchFilter** `string` (nullable): Include ("i") or exclude ("e") the siteSearch parameter
* **sort** `string` (nullable): Sort expression for ordering results

**Returns:**

* **kind** `string`: The type of search performed
* **url** `object` (nullable): URL template information
  * **type** `string`: URL type
  * **template** `string`: URL template
* **queries** `object` (nullable): Information about the current and related queries
  * **request** `array of objects` (nullable): Current query information
  * **nextPage** `array of objects` (nullable): Next page query information
  * **previousPage** `array of objects` (nullable): Previous page query information
* **context** `object` (nullable): Context information about the search engine
  * **title** `string`: Search engine title
  * **facets** `array` (nullable): Search facets
* **searchInformation** `object` (nullable): Information about the search
  * **searchTime** `number`: Time taken to perform the search in seconds
  * **formattedSearchTime** `string`: Formatted search time for display
  * **totalResults** `string`: Total number of search results
  * **formattedTotalResults** `string`: Formatted total results for display
* **items** `array of objects` (nullable): Array of search results
  * **kind** `string`: Result type
  * **title** `string`: The title of the search result
  * **htmlTitle** `string`: The title with HTML formatting
  * **link** `string`: The URL of the search result
  * **displayLink** `string`: The display URL
  * **snippet** `string`: A snippet of text from the page
  * **htmlSnippet** `string`: The snippet with HTML formatting
  * **formattedUrl** `string`: The formatted URL for display
  * **htmlFormattedUrl** `string`: The formatted URL with HTML
  * **pagemap** `object` (nullable): Structured data from the page
  * **image** `object` (nullable): Image information if this is an image search result
* **spelling** `object` (nullable): Spelling correction suggestions
  * **correctedQuery** `string`: Corrected query
  * **htmlCorrectedQuery** `string`: Corrected query with HTML formatting
* **promotions** `array` (nullable): Promoted search results

**Example Usage:**

```json
{
  "q": "artificial intelligence machine learning trends 2024",
  "cx": "230935ee073314dc5",
  "num": 10,
  "start": 1,
  "lr": "lang_en",
  "safe": "active",
  "cr": "countryUS",
  "dateRestrict": "m1",
  "exactTerms": null,
  "excludeTerms": "cryptocurrency bitcoin",
  "fileType": null,
  "filter": "1",
  "gl": "us",
  "hl": "en",
  "orTerms": "deep learning neural networks",
  "relatedSite": null,
  "rights": null,
  "searchType": null,
  "siteSearch": null,
  "siteSearchFilter": null,
  "sort": null
}
```

***

## Common Use Cases

**Research and Information Gathering:**

* Search for academic papers and technical documentation using file type filters
* Find recent news and articles with date restrictions for timely research
* Exclude irrelevant terms to refine search results for specific topics

**Content Discovery:**

* Search within specific websites using siteSearch parameter for targeted content
* Use language and country restrictions to find region-specific information
* Find related pages and similar content using relatedSite parameter

**Competitive Analysis:**

* Monitor competitor mentions and industry trends with targeted queries
* Search for specific licensing and usage rights for content research
* Use exact terms to find specific mentions of brands or products

**Development and Integration:**

* Integrate search functionality into applications using Custom Search Engine
* Implement pagination with start parameter for large result sets
* Use safe search and content filtering for family-friendly applications

