Skip to main content

SerpAPI Plugin

The SerpAPI plugin provides web search capabilities through the SerpAPI service with support for multiple search engines including Google, Bing, Yahoo, DuckDuckGo, Baidu, and Yandex. It uses plain fetch() with no SDK dependency, keeping the plugin lightweight.

Source: packages/plugins/serpapi/src/serpapi.plugin.ts

Overview

PropertyValue
Plugin IDserpapi
Categorysearch
Capabilitiessearch
Version1.0.0
Configuration Modehybrid
Auto-enableNo
Built-inYes
System PluginNo
SDKNone (plain fetch)

The plugin implements IPlugin and ISearchPlugin.

Architecture

The plugin constructs a query URL with parameters, sends a single HTTP request to the SerpAPI endpoint, and parses the JSON response into the standardized SearchResponse format.

Configuration

Settings Schema

SettingTypeDefaultDescription
apiKeystring--Required. Your SerpAPI key
enginestring"google"Search engine to use
maxResultsnumber10Default maximum results per search (1--100)

Supported Engines

EngineValueDescription
GooglegoogleDefault. Most comprehensive results
BingbingMicrosoft search engine
YahooyahooYahoo search
DuckDuckGoduckduckgoPrivacy-focused search
BaidubaiduChinese search engine
YandexyandexRussian search engine

Environment Variables

VariableDescription
PLUGIN_SERPAPI_API_KEYSerpAPI key fallback

Settings Resolution

API keys are resolved through the standard 4-level hierarchy:

  1. Work settings (highest priority)
  2. User settings
  3. Admin settings
  4. Environment variables (lowest priority)

Features

SerpAPI is unique among Ever Works search plugins in supporting six different search engines through a single API. The engine can be configured globally via plugin settings or overridden per request.

Search Options

The search() method supports these options:

OptionSerpAPI ParameterDescription
queryqThe search query string
limitnumMaximum results to return
pagestartPage number for pagination (converted to offset)
regionglCountry code for localized results
languagehlLanguage code for result language
safeSearchsafeSafe search level: off, moderate, or strict
siteQuery prefixRestricts results to a specific domain
fileTypeQuery prefixRestricts results to a specific file type

Query Prefixes

When site or fileType options are provided, the plugin prepends standard search operator prefixes to the query:

site:example.com my search query
filetype:pdf my search query

Safe Search Mapping

SerpAPI uses different safe search values than the plugin interface:

Plugin ValueSerpAPI Value
offoff
moderatemedium
strictactive

Search Results

Each result in the response includes:

FieldDescription
titleThe page title
urlThe destination URL (from link)
snippetText excerpt from the page
displayUrlThe displayed URL format
faviconUrlThe site's favicon URL
sourceThe source attribution
positionThe result's position in the search page
publishedDatePublication date when available

The response includes relatedSearches -- an array of related query suggestions from the search engine. These can be useful for expanding search coverage.

Pagination

SerpAPI supports multi-page results:

  • The page option specifies which page to retrieve (1-based)
  • The offset is calculated as (page - 1) * limit
  • The response includes hasMore to indicate additional pages
  • nextPage is set to page + 1 when more results are available

Usage in Pipelines

When enabled and set as the active search provider, SerpAPI is used during work generation to find information about each item. It is called by the search facade, which manages provider selection and settings resolution.

SerpAPI is a good choice when:

  • You need results from a specific search engine (e.g., Bing or Yandex)
  • You want to target specific regions or languages
  • You need structured organic results with metadata

Getting Started

  1. Create an account at serpapi.com
  2. Copy your API key from the SerpAPI dashboard
  3. Enable the SerpAPI plugin on the Plugins page
  4. Enter your API key in the settings panel
  5. Optionally select a preferred search engine
  6. Set SerpAPI as the active search provider for your work

API Reference

Class: SerpApiSearchPlugin

class SerpApiSearchPlugin implements IPlugin, ISearchPlugin {
readonly id: 'serpapi';
readonly category: 'search';

search(options: SearchOptions): Promise<SearchResponse>;
isAvailable(): Promise<boolean>;
getRateLimitInfo(): Promise<RateLimitInfo>;
}

Key Interfaces

InterfacePurpose
SearchOptionsInput for a search (query, limit, region, engine, etc.)
SearchResponseArray of results with pagination and related searches
SearchResultIndividual result with title, URL, snippet, and metadata
RateLimitInfoRate limit status (SerpAPI returns -1 for unknown limits)

Comparison with Other Search Plugins

FeatureSerpAPIBraveExaTavilyValyu
Engines6 (Google, Bing, Yahoo, etc.)1 (Brave)1 (Exa)1 (Tavily)Multi-source
Content extractionNoNoYesYesYes
Site filteringYes (query prefix)NoDomain filterDomain filterDomain filter
File type filteringYes (query prefix)NoNoNoNo
PaginationYesYesNoNoNo
Related searchesYesYesNoNoNo
Safe searchYes (3 levels)YesNoNoNo
SDK requiredNo (plain fetch)No (plain fetch)YesYesYes