google-search

Search the web using Google Custom Search Engine (PSE). Use this when you need live information

What Is This?

Overview

Google Search provides AI agents with access to Google's web search capabilities through the Custom Search API. It covers live information retrieval that fetches current web data for queries requiring up-to-date facts, documentation lookup that finds technical references and API docs across official sources, topic research that gathers multiple perspectives and sources on complex subjects, result filtering that restricts searches to specific domains or site patterns, and structured result formatting that returns clean titles, snippets, and URLs suitable for AI processing. The skill helps agents access information published after their training data cutoff, making it particularly valuable for time-sensitive applications.

Who Should Use This

This skill serves AI assistant developers adding real-time information lookup, research automation tools requiring diverse web sources, and agent workflows needing current event awareness for context-sensitive responses. It is also well suited for teams building knowledge retrieval pipelines that must surface accurate, up-to-date content without manual intervention.

Why Use It?

Problems It Solves

AI models cannot answer questions about events occurring after their training data cutoff date. Manual web searches interrupt automated workflows and require human intervention for simple lookups. Building custom search integrations requires managing API keys, rate limits, and response parsing logic. Generic search APIs may not provide the same quality and sophisticated relevance ranking as Google's algorithms.

Core Highlights

Search engine queries Google Custom Search API for current web results. Domain filter restricts results to specific sites or URL patterns. Result parser extracts titles, snippets, and links into structured format. Query optimizer handles natural language questions and keyword extraction.

How to Use It?

Basic Usage

import os
import requests

api_key = os.environ['GOOGLE_API_KEY']
cx = os.environ['GOOGLE_CX_ID']

response = requests.get(
    'https://www.googleapis.com/customsearch/v1',
    params={
        'key': api_key,
        'cx': cx,
        'q': 'Python 3.13 release date'
    }
)

data = response.json()
for item in data.get('items', []):
    print(f"{item['title']}\n{item['link']}\n{item['snippet']}\n")

Real-World Examples

docs_response = requests.get(
    'https://www.googleapis.com/customsearch/v1',
    params={
        'key': api_key,
        'cx': cx,
        'q': 'asyncio event loop',
        'siteSearch': 'docs.python.org',
        'num': 5
    }
)

news_response = requests.get(
    'https://www.googleapis.com/customsearch/v1',
    params={
        'key': api_key,
        'cx': cx,
        'q': 'AI regulation',
        'dateRestrict': 'm1',
        'sort': 'date'
    }
)

image_response = requests.get(
    'https://www.googleapis.com/customsearch/v1',
    params={
        'key': api_key,
        'cx': cx,
        'q': 'architecture diagram',
        'searchType': 'image'
    }
)

for img in image_response.json().get('items', []):
    print(img['link'])

Advanced Tips

Use the siteSearch parameter to restrict results to authoritative domains when accuracy matters. Set num to a small value like three to five results to reduce token usage in downstream AI processing. Combine date restriction with news queries to focus on recent developments rather than historical context. When constructing queries programmatically, prefer specific technical terms over broad phrases to improve result relevance and reduce noise in the returned data.

When to Use It?

Use Cases

Build a research assistant that gathers information from multiple web sources on technical topics. Add current event awareness to an AI chatbot by searching for recent news before generating responses. Create a comprehensive documentation finder tool that searches official docs systematically for API references and detailed code examples. You can also use this skill to monitor specific domains for newly published content, enabling agents to detect changes in third-party documentation or policy pages over time.

Related Topics

Web search APIs, Google Custom Search, information retrieval, real-time data access, AI agent tools, and search integration.

Important Notes

Requirements

A valid Google API key for authenticating Custom Search API requests. A Custom Search Engine ID configured with the sites and settings for your use case. Network access to Google API endpoints for submitting queries and receiving results.

Usage Recommendations

Do: use site-restricted searches when you need authoritative sources like official documentation. Cache search results for identical queries to reduce API calls and improve response latency. Implement rate limiting and retry logic to handle API quotas gracefully.

Don't: rely on search results for safety-critical decisions without verifying sources manually. Send excessive queries for the same information when cached results remain valid. Assume all results are equally credible since search engines return both authoritative and low-quality sources.

Limitations

Google Custom Search API has daily query quotas that restrict free tier usage to 100 queries per day. Search result quality depends on query phrasing and may miss relevant content with poor keyword selection. Custom Search Engines must be configured with allowed sites and may not cover the entire web like standard Google search.