feat: add SerpBase (Google SERP API) as a fourth search engine - #14
Open
gefsikatsinelou wants to merge 1 commit into
Open
gefsikatsinelou wants to merge 1 commit into
gefsikatsinelou wants to merge 1 commit into
Conversation
- scripts/search_query.py: register serpbase engine (GET https://api.serpbase.dev/google/search, X-API-Key header) and normalize organic[] hits into the shared {rank,title,url,snippet} contract - runner/capabilities.py: audit SERPBASE_API_KEY alongside brave/tavily/exa - docs: capability_discovery.md, source_dispatch.md, scripts/README.md and a new references/api_sources/search/serpbase.md card (mirrors serpapi.md) - tests: request-shape test + live-search-key wiring test
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds SerpBase (
serpbaseengine) as a fourth direct search-engine API inscripts/search_query.py, alongside brave/tavily/exa. SerpBase returns real Google organic results over a REST API — useful for SEO/competitive-intel sub-questions where the current three engines (own-index/semantic) don't reflect actual Google ranking.Background
The skill already documents that a second search axis is required when an engine key is present (
references/capability_discovery.md,references/source_dispatch.md), and it already keeps a reference card for SerpAPI (references/api_sources/search/serpapi.md) — but SerpAPI is explicitly marked "не используется — платный, без free tier" in the env-audit table and stays out ofKNOWN_KEYS(see the comment inrunner/capabilities.pyandDEAD_SEARCH_KEYSintests/test_docs_swarm.py). SerpBase covers that same "real Google" niche with a free tier (100 free searches, no credit card) and pay-as-you-go pricing, so it passes the exact gate SerpAPI fails: it's a search engine the skill actually calls, not one it advertises and can't use.Changes
scripts/search_query.py— newserpbaseengine:_request_serpbase(GEThttps://api.serpbase.dev/google/search,X-API-Keyheader,q/numparams),_normalize_serpbase(organic[]→title/link/snippet), registered inENV_VARS,BUILDERS,NORMALIZERS; docstring updated. Key:SERPBASE_API_KEY.runner/capabilities.py—SERPBASE_API_KEYadded toKNOWN_KEYS(18 keys), so Phase 3.5 env audit surfaces it as an available second search engine.references/api_sources/search/serpbase.md(new) — reference card mirroring theserpapi.md/exa.mdformat: contract, auth, when-to-use, example Phase-4 queries, fallback order.references/capability_discovery.md,references/source_dispatch.md,scripts/README.md— engine list and env-key rows extended to include serpbase.tests/test_search_query.py::test_serpbase_request_shape(request shape + normalization, mirrors the brave/tavily/exa tests);SERPBASE_API_KEYadded toLIVE_SEARCH_KEYSintests/test_docs_swarm.pyso the wiring test covers it; key-count assertion updated intests/test_capabilities.py.Design decisions
X-API-Keyheader authSERPBASE_API_KEYenv convention matches*_API_KEYpattern of the other enginesorganic[]→ shared{rank,title,url,snippet}shapenormalize()/run_query()KNOWN_KEYS(unlike SerpAPI)capability_discovery.md/source_dispatch.md; code without docs would be a dead engine the skill never callsTesting
python3 -m pytest tests/test_search_query.py tests/test_capabilities.py tests/test_docs_swarm.py— 28 passedSERPBASE_API_KEYset,run_query("serpbase", ...)issuesGET https://api.serpbase.dev/google/searchwithX-API-Keyand normalizesorganic[]; emptyorganic→[](no crash); missing key → exit 2 with the env-var name, same as the other engines.ruff checkon changed files: no new findings (repo-wide pre-existing findings unchanged).