Skip to content

feat: add SearchApi tool (Google Search + Google Shopping)#6378

Open
artuan wants to merge 3 commits into
crewAIInc:mainfrom
artuan:add-searchapi-tool
Open

feat: add SearchApi tool (Google Search + Google Shopping)#6378
artuan wants to merge 3 commits into
crewAIInc:mainfrom
artuan:add-searchapi-tool

Conversation

@artuan

@artuan artuan commented Jun 28, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features
    • Added two new SearchAPI-powered tools: Google Search and Google Shopping.
    • Search requests support an optional location parameter.
    • Tools are now available through the package’s public exports and tool catalog.
  • Documentation
    • Added setup and usage documentation for SearchAPI tools, including required API key configuration and examples.
  • Bug Fixes
    • Improved resilience with input validation and friendlier error messages on request failures/timeouts.
  • Tests
    • Added coverage for initialization, environment validation, request construction, and response field filtering.

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d6717c43-7b53-4a57-b70a-bdb67c87bdf9

📥 Commits

Reviewing files that changed from the base of the PR and between 84a48d3 and 79e1b47.

📒 Files selected for processing (5)
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_shopping_tool.py
  • lib/crewai-tools/tests/tools/searchapi_tool_test.py
  • lib/crewai-tools/tool.specs.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/crewai-tools/tests/tools/searchapi_tool_test.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_shopping_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py
  • lib/crewai-tools/tool.specs.json

📝 Walkthrough

Walkthrough

Adds two SearchAPI-backed tools with a shared base class, exports them from the package, registers them in tool.specs.json, and includes tests and documentation.

Changes

SearchAPI Google Search and Shopping Tools

Layer / File(s) Summary
SearchApiBaseTool shared base
lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py
Defines SEARCH_URL, SearchApiBaseTool with SEARCHAPI_API_KEY loading, _search HTTP GET with Bearer auth and timeout, and _omit_fields for response filtering.
SearchApiGoogleSearchTool implementation
lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py
Defines SearchApiGoogleSearchToolSchema and SearchApiGoogleSearchTool._run for engine=google, including conditional location, response filtering, and request error handling.
SearchApiGoogleShoppingTool implementation
lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_shopping_tool.py
Defines SearchApiGoogleShoppingToolSchema and SearchApiGoogleShoppingTool._run for engine=google_shopping, including conditional location, response filtering, and request error handling.
Package exports and tool specs
lib/crewai-tools/src/crewai_tools/tools/__init__.py, lib/crewai-tools/src/crewai_tools/__init__.py, lib/crewai-tools/tool.specs.json
Imports and __all__ entries are added for both tools, and two tool spec objects are inserted with SEARCHAPI_API_KEY, run/init schemas, and requests dependency.
Tests and README
lib/crewai-tools/tests/tools/searchapi_tool_test.py, lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/README.md
Tests cover initialization, missing API key errors, request parameter construction, field omission, and timeout handling; the README documents supported tools, environment setup, and usage examples.

Suggested reviewers

  • lorenzejay
  • greysonlalonde
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding SearchAPI tools for Google Search and Google Shopping.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/crewai-tools/tests/tools/searchapi_tool_test.py (1)

25-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a _run test for SearchApiGoogleShoppingTool.

This file only exercises the Google Search request/response path. The Shopping tool is initialization-only here, so a regression in its engine="google_shopping" params or omitted-field behavior would currently pass unnoticed.

Also applies to: 36-60

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/crewai-tools/tests/tools/searchapi_tool_test.py` around lines 25 - 27,
Add a `_run` test for SearchApiGoogleShoppingTool in searchapi_tool_test.py,
since the current coverage only checks initialization and would miss regressions
in the google_shopping engine parameters or omitted-field handling. Extend the
test coverage around SearchApiGoogleShoppingTool by exercising its _run path
with representative input and asserting the expected SearchApi request/response
behavior, alongside the existing initialization check.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py`:
- Line 5: The SearchAPI tool is exposing api_key through the Pydantic model, so
it can leak via BaseTool serialization and repr paths. Update SearchApiBaseTool
to keep api_key out of model fields by moving it to a private attribute or
otherwise excluding it from model_dump/repr, and adjust any
initialization/access in the tool methods so the credential is still available
without being part of the public schema.

In
`@lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py`:
- Around line 45-46: Broaden the error handling in
searchapi_google_search_tool’s exception path so timeouts and connection issues
are also caught, not just HTTP errors. Update the failure handler in the
relevant search method to catch requests.RequestException and return a neutral,
non-diagnostic message instead of suggesting invalid parameters; keep the
response generic and consistent with the tool’s error handling.

---

Nitpick comments:
In `@lib/crewai-tools/tests/tools/searchapi_tool_test.py`:
- Around line 25-27: Add a `_run` test for SearchApiGoogleShoppingTool in
searchapi_tool_test.py, since the current coverage only checks initialization
and would miss regressions in the google_shopping engine parameters or
omitted-field handling. Extend the test coverage around
SearchApiGoogleShoppingTool by exercising its _run path with representative
input and asserting the expected SearchApi request/response behavior, alongside
the existing initialization check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6b44b41-d464-4465-8317-deadf00f3132

📥 Commits

Reviewing files that changed from the base of the PR and between 6491f5a and 84a48d3.

📒 Files selected for processing (9)
  • lib/crewai-tools/src/crewai_tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/README.md
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/__init__.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_search_tool.py
  • lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_google_shopping_tool.py
  • lib/crewai-tools/tests/tools/searchapi_tool_test.py
  • lib/crewai-tools/tool.specs.json

Comment thread lib/crewai-tools/src/crewai_tools/tools/searchapi_tool/searchapi_base_tool.py Outdated
@artuan artuan force-pushed the add-searchapi-tool branch from 2d381db to 79e1b47 Compare June 28, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant