Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI SerpApi Google Shopping Tool

From Leeroopedia
Knowledge Sources
Domains Tools, Web_Search, E_Commerce
Last Updated 2026-02-11 00:00 GMT

Overview

SerpApiGoogleShoppingTool searches Google Shopping for product listings using the SerpApi service and returns cleaned shopping results.

Description

SerpApiGoogleShoppingTool extends SerpApiBaseTool and configures itself with arbitrary_types_allowed and validate_assignment via ConfigDict. SerpApiGoogleShoppingToolSchema defines the input with a mandatory search_query string and an optional location string for geo-targeted product searches. The _run() method calls self.client.search() with a dictionary that includes "engine": "google_shopping" (to target the shopping search engine), the query (q), and location. The response is converted to a dict via .as_dict(), then the inherited _omit_fields() strips search_metadata, search_parameters, fields matching serpapi_.+, filters, and pagination. HTTPError exceptions are caught and returned as descriptive error strings.

Usage

Use this tool when agents need to search for product listings, compare prices, or discover products through Google Shopping. It enables e-commerce research and product discovery tasks. Requires a SERPAPI_API_KEY environment variable.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/tools/serpapi_tool/serpapi_google_shopping_tool.py
  • Lines: 1-61

Signature

class SerpApiGoogleShoppingToolSchema(BaseModel):
    search_query: str = Field(..., description="Mandatory search query you want to use to Google shopping.")
    location: str | None = Field(None, description="Location you want the search to be performed in.")

class SerpApiGoogleShoppingTool(SerpApiBaseTool):
    name: str = "Google Shopping"
    description: str = "A tool to perform search on Google shopping with a search_query."
    args_schema: type[BaseModel] = SerpApiGoogleShoppingToolSchema

    def _run(self, **kwargs) -> Any

Import

from crewai_tools import SerpApiGoogleShoppingTool

I/O Contract

Inputs

Name Type Required Description
search_query str Yes The product search query to send to Google Shopping
location str or None No Geographic location for the search

Outputs

Name Type Description
_run() returns dict or str Cleaned Google Shopping results as a dictionary, or error message string on failure

Usage Examples

Basic Usage

from crewai_tools import SerpApiGoogleShoppingTool

tool = SerpApiGoogleShoppingTool()
result = tool._run(search_query="wireless headphones under $100")

# With location targeting
result = tool._run(search_query="organic coffee beans", location="Seattle, WA")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment