Google Custom Search

Perform Google Custom Search operations

Overview

This node performs Google Custom Search operations, allowing users to query Google's search engine programmatically within an n8n workflow. It is useful for automating web searches, retrieving search results for data enrichment, monitoring content, or integrating search capabilities into other processes.

Typical use cases include:

  • Automatically searching the web or images based on dynamic input queries.
  • Filtering search results by country, safety level, file type, or site.
  • Retrieving a specific number of results or paginating through results.
  • Extracting only the relevant items from the search response for further processing.

For example, you could use this node to search for recent news articles about a topic, filter image results for marketing materials, or restrict results to a particular website domain.

Properties

Name Meaning
Query The search query string to send to Google Custom Search.
Country Code (GL) Two-letter country code to specify the geolocation of the end user, influencing search results.
Return Only Items Boolean flag to return only the array of search result items instead of the full API response.
Additional Options A collection of optional parameters to customize the search:
- Number of Results Number of search results to return (1-100).
- Start Index The index of the first result to return (for pagination).
- Safe Search Search safety level; options are "Off" or "Active".
- Search Type Type of search to perform; options are "Web" or "Image".
- Site Search Restrict results to a specific site/domain.
- File Type Restrict results to a specific file type (e.g., pdf, doc).
- Date Restrict Restrict results by date using formats like d[number], w[number], m[number].

Output

The node outputs JSON data structured as follows:

  • If Return Only Items is set to false (default), the output JSON contains the full response from the Google Custom Search API, including metadata and all fields returned by the API.
  • If Return Only Items is set to true, the output JSON consists of individual items from the items array in the API response, each emitted as a separate item in the workflow output.
  • If no items are found, a message indicating "No items found in response" is returned.
  • In case of errors, the output includes an error message describing the issue.

The node does not output binary data.

Dependencies

  • Requires a valid Google Custom Search API key and a Custom Search Engine ID (CX).
  • These credentials must be configured in n8n before using the node.
  • The node makes HTTP GET requests to the Google Custom Search API endpoint: https://www.googleapis.com/customsearch/v1.

Troubleshooting

  • No credentials found!
    This error occurs if the required API key and CX credentials are not provided. Ensure that the Google Custom Search API credentials are correctly set up in n8n.

  • Empty or no items in response
    If the search query returns no results, the node outputs a message indicating no items were found. Verify the query parameters and try adjusting filters or search terms.

  • API quota limits or errors
    Google Custom Search API has usage quotas and limits. Exceeding these may cause errors. Check your Google Cloud Console for quota status and ensure your API key is valid and enabled.

  • Invalid parameter values
    Parameters like num (number of results) must be between 1 and 100. Providing invalid values may cause API errors.

  • Network or connectivity issues
    Ensure that n8n can reach the Google API endpoint and that there are no firewall restrictions.

Links and References

Discussion