Google Custom Search icon

Google Custom Search

Searches and returns the results using the Google Custom Search API

Overview

This node performs web searches using the Google Custom Search API. It allows users to query Google's index with various parameters to retrieve relevant search results programmatically within an n8n workflow. This is useful for automating data gathering, monitoring web content, or integrating search capabilities into custom automation.

Typical use cases include:

  • Automatically fetching search results for specific keywords or phrases.
  • Filtering search results by country, file type, or exact/excluded terms.
  • Paginating through search results to collect multiple pages of data.
  • Integrating search results into further processing steps in a workflow.

For example, you could use this node to monitor news articles containing a particular phrase, restrict results to a certain country, and then process or notify based on those results.

Properties

Name Meaning
Query The search query string to look up.
Page Size Number of search results per page to return. Must be between 1 and 10. The API returns a maximum of 100 results total.
Page Index The page number of results to return (starting at 1). Used for pagination.
Country Restriction Restricts search results to documents from a specified country. See Google Country Collections for valid values.
Exact Terms A phrase that all returned documents must contain.
Exclude Terms Words or phrases that should not appear in any returned documents.
File Type Restricts results to a specific file type indexable by Google. See Google Supported File Types for options.
Destination Key The key under which the search results will be stored in the output JSON. Defaults to "search".

Output

The node outputs an array of items, each containing a JSON object with the following structure under the specified destination key (default "search"):

{
  "cr": "Country Restriction value",
  "exactTerms": "Exact Terms value",
  "excludeTerms": "Exclude Terms value",
  "fileType": "File Type value",
  "pageIndex": 1,
  "pageSize": 10,
  "q": "Search query",
  "results": [
    {
      "title": "Title of the search result",
      "link": "URL of the search result",
      "snippet": "Short snippet describing the search result"
    },
    ...
  ]
}
  • results is an array of objects representing individual search results.
  • Each result includes a title, link, and snippet summarizing the content.
  • No binary data is output by this node.

Dependencies

  • Requires a valid Google Custom Search API credential with appropriate API key and Custom Search Engine ID configured in n8n.
  • Uses the official Google APIs Node.js client library (@googleapis/customsearch) bundled with the node.
  • Network access to Google APIs is required.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Exceeding the Google Custom Search API quota or rate limits will result in errors.
    • Providing invalid parameter values (e.g., page size > 10) may cause API errors.
    • Empty or malformed queries will return no results or errors.
  • Error messages:

    • Errors are prefixed with Google Custom Search failed: followed by the API error message.
    • To resolve, verify API key validity, ensure correct Custom Search Engine ID, and check parameter constraints.
    • If the node is set to continue on fail, errors for individual items will be included in the output for debugging.

Links and References

Discussion