Skip to content

feat: add SerpBase (Google) search engine via REST API - #5

Open
gefsikatsinelou wants to merge 1 commit into
protonspy:mainfrom
gefsikatsinelou:feat/add-serpbase-search-engine
Open

feat: add SerpBase (Google) search engine via REST API#5
gefsikatsinelou wants to merge 1 commit into
protonspy:mainfrom
gefsikatsinelou:feat/add-serpbase-search-engine

Conversation

@gefsikatsinelou

Copy link
Copy Markdown

Summary

Add SerpBase as a Google search engine — returns structured Google search results via REST API with zero scraping maintenance.

Background

The project currently supports Google search via two methods: the googlesearch library (which scrapes Google and breaks when Google changes their markup) and SerpAPI (which requires a paid subscription). SerpBase offers a simpler, pay-as-you-go API that returns Google results in clean JSON without requiring proxy rotation or CAPTCHA handling.

Changes

  • New: researchers/serpbase_search.py — REST API-based search engine implementation
  • Updated: researchers/search_engine.py — registered "serpbase" as a new engine option in _perform() and error handling
  • Updated: config/environment.py — added SERPBASE_API_KEY env var and "serpbase" to the SEARCH_ENGINE Literal type
  • Updated: exceptions.py — added SerpbaseSearchError exception class

Design decisions

Decision Rationale
API key via SERPBASE_API_KEY env var Follows existing convention (BRAVE_API_KEY, TAVILY_API_KEY, etc.)
Reuses SearchResult schema directly Fields map 1:1 (title, description/snippet, link) — no new schema needed
Uses requests library Already a dependency (used by BraveSearch) — no new dependencies
Returns empty list on API failure Matches existing pattern of graceful degradation

Testing

  • When SERPBASE_API_KEY is set and SEARCH_ENGINE=serpbase: returns Google search results via the API
  • When SERPBASE_API_KEY is missing and SEARCH_ENGINE=serpbase: raises clear error at startup (same pattern as other engines)
  • Existing engines continue to work without modification

Usage

export SEARCH_ENGINE=serpbase
export SERPBASE_API_KEY=your_key_here

Free trial available at https://serpbase.dev — 100 searches, no credit card required.

- Add SerpbaseSearch researcher class following existing BaseSearchService pattern
- Add SERPBASE_API_KEY env var config with validation
- Add SerpbaseSearchError exception class
- Register 'serpbase' as a new SEARCH_ENGINE option in the orchestrator
- No new dependencies — reuses existing requests library
- Graceful API error handling matching existing engine patterns
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