Skip to content

Add serpingapi as a web search provider - #497

Merged
aandrew-me merged 1 commit into
aandrew-me:mainfrom
musabgultekin:serpingapi_search_provider
Sep 14, 2026
Merged

Add serpingapi as a web search provider#497
aandrew-me merged 1 commit into
aandrew-me:mainfrom
musabgultekin:serpingapi_search_provider

Conversation

@musabgultekin

@musabgultekin musabgultekin commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Following up on our email thread.

Adds serpingapi as an optional third choice for --search-provider, next to exa and google. Opt-in only: exa stays the default and nothing changes for existing users.

What it adds

  • src/search/search.go: serpingapiSearch / parseSerpingapiResponse alongside googleSearch (POST https://api.serpingapi.com/v1/search, X-API-Key header, organic[] title/link/snippet mapped into the existing SearchResult), plus PerformSerpingapiSearchWithParams, which goes through the same is-fast content extraction and formatResultsForAI path as the Google provider. The extraction loop is factored into extractContentForResults so both providers share it.
  • Site filters from query optimization are sent as a site: operator in the query, since the API has no separate parameter.
  • main.go, src/helper/helper.go, src/structs/structs.go, md/usage.md: flag help text and provider validation.
  • SEARCH_SETUP.md: a short configuration section.
  • No new dependencies.

How to configure

export SERPINGAPI_API_KEY="your_key"
tgpt --search-provider serpingapi -f "your question"   # or SEARCH_PROVIDER=serpingapi

A free plan exists (1,000 searches/month, no card). API reference: https://serpingapi.com/docs

How it was tested

  • go build ./... and go vet ./... clean; gofmt clean on the touched Go files.
  • go test ./...: everything passes except src/helper TestDetectPackageManager (Windows-path subtests), which fails identically on unmodified main when run on macOS.
  • New unit tests in src/search/search_test.go cover the response mapping (invalid links skipped, empty and malformed JSON) and the site-filter query.
  • A live request with an invalid key returns the documented 401 invalid_api_key through the existing error path. Happy to paste a full tgpt -f run with a real key if useful.

Adds "serpingapi" as an opt-in choice for --search-provider / SEARCH_PROVIDER
next to exa and google. It calls POST https://api.serpingapi.com/v1/search
with the SERPINGAPI_API_KEY header and maps organic results into the existing
SearchResult flow, reusing the is-fast content extraction and formatting used
by the google provider. Adds unit tests for the response mapping and
documents configuration in SEARCH_SETUP.md.
@gitar-bot

gitar-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds serpingapi as an optional third web search provider alongside exa and google. The implementation includes response parsing, content extraction shared with the Google provider, site filter handling, and comprehensive unit tests. No issues found.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@aandrew-me

Copy link
Copy Markdown
Owner

Great!

@aandrew-me
aandrew-me merged commit 79cd0df into aandrew-me:main Sep 14, 2026
1 check passed
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.

2 participants