serper

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package serper wires Serper's Google Search API into web.Searcher.

Endpoint

POST https://google.serper.dev/search

Authentication uses the X-API-KEY header (not bearer).

Parameter mapping

web.SearchRequest → Serper request:

  • Query → q (after Google site:/-site: rewriting via web.SearchRequest.QueryWithSiteOperators)
  • MaxResults → num (forwarded as-is)
  • AllowedDomains → inlined into q as `site:foo.com site:bar.com`
  • BlockedDomains → inlined into q as `-site:foo.com -site:bar.com`
  • Recency → tbs=qdr:h|d|w|m|y

Serper has no native include/exclude domain fields, so the query is rewritten with Google's site:/-site: operators. The trade-off is that the operator count counts against Google's per-query token budget.

Hardcoded: autocorrect=true.

Response mapping

Serper organic[] → []*web.SearchResult:

  • title → Title
  • link → URL
  • snippet → Snippet
  • date → PublishedTime (best-effort parse; relative strings like "2 days ago" become zero time)

Knowledge graph, answer box, people-also-ask, and related searches are ignored — only organic results are surfaced.

Serper's transport DTOs stay private; only organic results cross the provider boundary.

Reference

https://serper.dev/playground

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config Config) (*Client, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, request *web.SearchRequest) (*web.SearchResponse, error)

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL