anyserp
Unified SERP API router for Python. 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 code. Every provider returns the same unified response format, so your application logic stays consistent regardless of which provider you use. Self-hosted with your own API keys and zero routing fees. Built-in fallback routing means if one provider fails, the next is tried automatically. Zero heavy dependencies. Just httpx.
Install
pip install anyserp
Quick Start
Set your API keys as environment variables:
export SERPER_API_KEY=...
export BRAVE_API_KEY=...
import asyncio
from anyserp import AnySerp
async def main():
client = AnySerp()
# Search with the first available provider
results = await client.search("best python frameworks")
print(results["results"][0]["title"], results["results"][0]["url"])
asyncio.run(main())
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
results = await client.search("serper/python frameworks")
# Or just search with the first available
results = await client.search("python frameworks")
Search Options
results = await client.search({
"query": "python 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:
results = await client.search_with_fallback(
{"query": "python frameworks"},
["serper", "brave", "bing"],
)
Search All Providers
Search all configured providers and get combined results:
all_results = await client.search_all({"query": "python frameworks"})
for result in all_results:
print(f"{result['provider']}: {len(result['results'])} results")
Unified Response Format
All providers return the same response shape:
{
"provider": "serper",
"query": "python frameworks",
"results": [
{
"position": 1,
"title": "...",
"url": "...",
"description": "...",
"domain": "...",
"datePublished": "...",
# Image fields
"imageUrl": "...",
"imageWidth": 800,
"imageHeight": 600,
# News fields
"source": "...",
# Video fields
"duration": "...",
"channel": "...",
}
],
"totalResults": 1000000,
"searchTime": 250,
"relatedSearches": ["..."],
"peopleAlsoAsk": [{"question": "...", "snippet": "...", "title": "...", "url": "..."}],
"knowledgePanel": {"title": "...", "type": "...", "description": "..."},
"answerBox": {"snippet": "...", "title": "...", "url": "..."},
"aiOverview": {"markdown": "...", "textBlocks": [...], "references": [...]},
}
Configuration
Programmatic
client = AnySerp({
"serper": {"api_key": "..."},
"brave": {"api_key": "..."},
"google": {"api_key": "...", "engine_id": "..."},
"dataforseo": {"login": "...", "password": "..."},
"searchapi": {"api_key": "..."},
"valueserp": {"api_key": "..."},
"scrapingdog": {"api_key": "..."},
"brightdata": {"api_key": "..."},
"searchcans": {"api_key": "..."},
"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):
results = await client.search("how to start an LLC")
for paa in results.get("peopleAlsoAsk", []):
print(paa["question"], paa.get("snippet", ""))
AI Overview
Fetch Google's AI-generated overview content (requires SearchAPI):
results = await client.search({
"query": "how to start an LLC",
"includeAiOverview": True,
})
if results.get("aiOverview"):
print(results["aiOverview"]["markdown"])
for ref in results["aiOverview"]["references"]:
print(f" [{ref['index']}] {ref['title']} - {ref['url']}")
See Also
| Package | Description |
|---|---|
| @probeo/anyserp | TypeScript version of this package |
| anyserp-go | Go version of this package |
| anymodel-py | Unified LLM router for Python |
| workflow-py | Stage-based pipeline engine for Python |
Support
If anyserp is useful to you, consider giving it a star. It helps others discover the project.
License
MIT
Metadata
Release files for anyserp-py 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| anyserp_py-0.2.2.tar.gz | 28.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anyserp_py-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.7 kB
Release files / anyserp_py-0.2.2.tar.gz
| Download URL | anyserp_py-0.2.2.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78891418cb3ce79929146b66ec2d1e99e747b720f0f1be6a9037e02da53f8652
|
|
BLAKE2b-256 checksum How to use checksums |
00bd97b466da1934882ac3511f6b2cae07ffbb2029aaea14ba271ed45d77335d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / anyserp_py-0.2.2-py3-none-any.whl
| Download URL | anyserp_py-0.2.2-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01e3e7f2711afeccb01a3e73b8bdaf9d1d7542cd54afc63d6a44c4a8cb364023
|
|
BLAKE2b-256 checksum How to use checksums |
75fb3ea103b6ba2e2c5c44e89ef9f808456eb9f6e48d5e2f50511d67059ed4d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|