Skip to main content

Overview

Search Google for web results, images, news, and places through a simple Python interface.
from ziet.integrations import google

# Search Google
results = google.search("best restaurants in SF")

# Search images
images = google.images("golden gate bridge")

# Search news
news = google.news("latest AI developments")

# Search maps/places
places = google.maps("coffee shops", location="San Francisco")

How It Works

Default (Ziet’s Keys)

No setup required - start searching immediately:
from ziet.integrations import google

results = google.search("machine learning")
Free tier: 100 searches/day

Bring Your Own Keys

For higher limits:
  1. Get API key from Google Cloud Console
  2. Get Search Engine ID from Programmable Search Engine
  3. Add both to Ziet DashboardGoogle
Your code stays the same - Ziet uses your keys automatically.

Methods

Search Google for web results:
results = google.search(
    query="python tutorials",
    num_results=10
)
Parameters:
  • query (string, required): Search query
  • num_results (int, default 10): Number of results (max 100)
Returns:
[
    {
        "title": "Learn Python - Tutorial",
        "url": "https://example.com/python",
        "snippet": "Complete Python tutorial for beginners...",
        "position": 1
    },
    ...
]
Example:
from ziet import Action, memory
from ziet.integrations import google

@Action(
    id="search_python",
    name="Search Python",
    description="Search for Python tutorials"
)
def search_python() -> None:
    results = google.search("python tutorials", num_results=10)
    memory.add(key="search_results", value=results)

images()

Search Google Images:
images = google.images(
    query="golden gate bridge",
    num_results=10
)
Returns:
[
    {
        "title": "Golden Gate Bridge",
        "url": "https://example.com/image.jpg",
        "thumbnail": "https://example.com/thumb.jpg",
        "width": 1920,
        "height": 1080
    },
    ...
]

news()

Search Google News:
news = google.news(
    query="artificial intelligence",
    num_results=10
)
Returns:
[
    {
        "title": "Latest AI Breakthrough",
        "url": "https://news.example.com/article",
        "snippet": "Scientists announce major advancement...",
        "source": "Tech News",
        "published": "2 hours ago"
    },
    ...
]

maps()

Search Google Maps/Places:
places = google.maps(
    query="coffee shops",
    location="San Francisco, CA"
)
Returns:
[
    {
        "name": "Blue Bottle Coffee",
        "address": "66 Mint St, San Francisco, CA 94103",
        "rating": 4.5,
        "reviews": 1234,
        "phone": "+1 510-653-3394",
        "hours": "Open until 6:00 PM"
    },
    ...
]

Complete Example

from ziet import Action, Agent, memory
from ziet.integrations import google, openai

@Action(
    id="search_topic",
    name="Search Topic",
    description="Search Google for a topic"
)
def search_topic(topic: str) -> None:
    results = google.search(topic, num_results=10)
    memory.add(key="search_results", value=results)

@Action(
    id="get_news",
    name="Get News",
    description="Get latest news on topic"
)
def get_news(topic: str) -> None:
    news = google.news(topic, num_results=5)
    memory.add(key="news_results", value=news)

@Action(
    id="summarize_findings",
    name="Summarize Findings",
    description="Summarize research findings"
)
def summarize_findings() -> None:
    search = memory.get("search_results")
    news = memory.get("news_results")
    
    prompt = f"Summarize this research:\n\nWeb: {search}\n\nNews: {news}"
    summary = openai.chat([{"role": "user", "content": prompt}])
    
    memory.add(key="final_summary", value=summary)

@Agent(
    id="research_agent",
    name="ResearchAgent",
    instructions="""
    Research a topic comprehensively:
    1. Search Google for web results
    2. Get latest news
    3. Summarize all findings
    Store everything in memory for later retrieval.
    """,
    actions=["search_topic", "get_news", "summarize_findings"]
)
class ResearchAgent:
    pass

Best Practices

Avoid redundant searches:
from ziet import memory

# Check cache first
cached = memory.get(f"search_{query}")
if cached:
    return

# Search and cache
results = google.search(query)
memory.add(key=f"search_{query}", value=results)
Post-process for better quality:
results = google.search("python tutorials")

# Filter by domain
official = [r for r in results if "python.org" in r["url"]]

# Filter by keywords
advanced = [r for r in results if "advanced" in r["title"].lower()]
from ziet import Action, memory
from ziet.integrations import google

@Action(
    id="safe_search",
    name="Safe Search",
    description="Search with error handling",
    retries=2
)
def safe_search(query: str) -> None:
    try:
        results = google.search(query)
        memory.add(key="results", value=results)
    except Exception as e:
        memory.add(key="error", value=str(e))
        memory.add(key="results", value=[])

Next Steps

Apify

Scrape search results for detailed data

OpenAI

Summarize search results with AI

Memory

Cache and store search results

Actions

Build search actions