@probeo/anyserp
v0.5.2
Published
Unified SERP API router. 11 providers — Serper, SerpAPI, Google CSE, Bing, Brave, DataForSEO, SearchAPI, ValueSERP, ScrapingDog, Bright Data, SearchCans.
Maintainers
Readme
@probeo/anyserp
Unified SERP API router. Route search requests across Google, Bing, Brave, and more with a single API. Self-hosted, zero fees.
Why anyserp?
One SDK, 11 SERP providers. Switch providers without changing your code. Every provider returns the same unified response format, so your application logic stays clean regardless of which provider is behind the request. Your API keys, your infrastructure, zero routing fees. Built-in fallback routing means if one provider fails, the next is tried automatically.
Install
npm install @probeo/anyserpQuick Start
Set your API keys as environment variables:
export SERPER_API_KEY=...
export BRAVE_API_KEY=...import { AnySerp } from "@probeo/anyserp";
const client = new AnySerp();
// Search with the first available provider
const results = await client.search("best typescript frameworks");
console.log(results.results[0].title, results.results[0].url);Supported Providers
| Provider | Env Var | Web | Images | News | Videos |
|----------|---------|-----|--------|------|--------|
| Serper | SERPER_API_KEY | Yes | Yes | Yes | Yes |
| SerpAPI | SERPAPI_API_KEY | Yes | Yes | Yes | Yes |
| Google CSE | GOOGLE_CSE_API_KEY + GOOGLE_CSE_ENGINE_ID | Yes | Yes | No | No |
| Bing | BING_API_KEY | Yes | Yes | Yes | Yes |
| Brave | BRAVE_API_KEY | Yes | Yes | Yes | Yes |
| DataForSEO | DATAFORSEO_LOGIN + DATAFORSEO_PASSWORD | Yes | No | Yes | No |
| SearchAPI | SEARCHAPI_API_KEY | Yes | Yes | Yes | Yes |
| ValueSERP | VALUESERP_API_KEY | Yes | Yes | Yes | Yes |
| ScrapingDog | SCRAPINGDOG_API_KEY | Yes | Yes | Yes | No |
| Bright Data | BRIGHTDATA_API_KEY | Yes | Yes | Yes | Yes |
| SearchCans | SEARCHCANS_API_KEY | Yes | No | Yes | No |
Provider Routing
Specify a provider with provider/query format:
// Use a specific provider
const results = await client.search("serper/typescript frameworks");
// Or just search with the first available
const results = await client.search("typescript frameworks");Search Options
const results = await client.search({
query: "typescript frameworks",
num: 20, // number of results
page: 2, // page number
country: "us", // country code
language: "en", // language code
safe: true, // safe search
type: "web", // web, images, news, videos
dateRange: "month", // day, week, month, year
});Fallback Routing
Try multiple providers in order. If one fails, the next is attempted:
const results = await client.searchWithFallback(
{ query: "typescript frameworks" },
["serper", "brave", "bing"],
);Search All Providers
Search all configured providers and get combined results:
const allResults = await client.searchAll({
query: "typescript frameworks",
});
for (const result of allResults) {
console.log(`${result.provider}: ${result.results.length} results`);
}Unified Response Format
All providers return the same SearchResponse shape:
interface SearchResponse {
provider: string;
query: string;
results: SearchResult[];
totalResults?: number;
searchTime?: number;
relatedSearches?: string[];
knowledgePanel?: KnowledgePanel;
answerBox?: AnswerBox;
}
interface SearchResult {
position: number;
title: string;
url: string;
description: string;
domain?: string;
datePublished?: string;
// Image fields
imageUrl?: string;
imageWidth?: number;
imageHeight?: number;
// News fields
source?: string;
// Video fields
duration?: string;
channel?: string;
}Configuration
Programmatic
const client = new AnySerp({
serper: { apiKey: "..." },
brave: { apiKey: "..." },
google: { apiKey: "...", engineId: "..." },
dataforseo: { login: "...", password: "..." },
searchapi: { apiKey: "..." },
valueserp: { apiKey: "..." },
scrapingdog: { apiKey: "..." },
brightdata: { apiKey: "..." },
searchcans: { apiKey: "..." },
defaults: {
num: 10,
country: "us",
language: "en",
safe: true,
},
aliases: {
fast: "serper",
default: "brave",
},
});Environment Variables
export SERPER_API_KEY=...
export SERPAPI_API_KEY=...
export GOOGLE_CSE_API_KEY=...
export GOOGLE_CSE_ENGINE_ID=...
export BING_API_KEY=...
export BRAVE_API_KEY=...
export DATAFORSEO_LOGIN=...
export DATAFORSEO_PASSWORD=...
export SEARCHAPI_API_KEY=...
export VALUESERP_API_KEY=...
export SCRAPINGDOG_API_KEY=...
export BRIGHTDATA_API_KEY=...
export SEARCHCANS_API_KEY=...People Also Ask
Available from 8 providers (Serper, SerpAPI, SearchAPI, ValueSERP, DataForSEO, ScrapingDog, Bright Data, SearchCans):
const results = await client.search("how to start an LLC");
for (const paa of results.peopleAlsoAsk ?? []) {
console.log(paa.question, paa.snippet);
}AI Overview
Fetch Google's AI-generated overview content (requires SearchAPI):
const results = await client.search({
query: "how to start an LLC",
includeAiOverview: true,
});
if (results.aiOverview) {
console.log(results.aiOverview.markdown);
for (const ref of results.aiOverview.references) {
console.log(` [${ref.index}] ${ref.title} - ${ref.url}`);
}
}See Also
| Package | Description | |---|---| | anyserp-py | Python version of this package | | anyserp-go | Go version of this package | | @probeo/anymodel | Unified LLM router for TypeScript | | @probeo/workflow | Stage-based pipeline engine for TypeScript |
Support
If anyserp is useful to you, consider giving it a star. It helps others discover the project.
License
MIT
