SerpHubAPI
接入

接入 SerpHubAPI

按用法分四条线:Agent 里用、写代码调接口、先试试、批量跑数据。四条线共用同一个 Key、同一个钱包。

先去 /dashboard/keys 拿一个 Key(新账号送 1,000 积分)。MCP Server 是本地包 serphubapi-mcp(0.1.0 版,stdio 方式),不是托管端点,你的 Key 只留在你自己的客户端配置里。

在 Agent 里用:MCP

Claude Code 一行装好,其他客户端都是同一段 stdio 配置——命令 uvx、参数 serphubapi-mcp、Key 放环境变量。

claude mcp add serphubapi -e SERPHUBAPI_API_KEY=shapi_xxxxxxxx -- uvx serphubapi-mcp

装好就这些:你的 Agent 得到 list_services、search、batch、fetch 四个工具。需要先装 uv(它提供 uvx),Server 会连 https://api.serphubapi.com。

Cursor

文件:~/.cursor/mcp.json(或项目里的 .cursor/mcp.json)。

{
  "mcpServers": {
    "serphubapi": {
      "command": "uvx",
      "args": ["serphubapi-mcp"],
      "env": { "SERPHUBAPI_API_KEY": "shapi_xxxxxxxx" }
    }
  }
}

VS Code

文件:.vscode/mcp.json。VS Code 的顶层字段是 servers,不是 mcpServers。

{
  "servers": {
    "serphubapi": {
      "command": "uvx",
      "args": ["serphubapi-mcp"],
      "env": { "SERPHUBAPI_API_KEY": "shapi_xxxxxxxx" }
    }
  }
}

Windsurf

文件:~/.codeium/windsurf/mcp_config.json。

{
  "mcpServers": {
    "serphubapi": {
      "command": "uvx",
      "args": ["serphubapi-mcp"],
      "env": { "SERPHUBAPI_API_KEY": "shapi_xxxxxxxx" }
    }
  }
}

Cline

在 Cline 里打开 MCP Servers 设置,贴入同一段配置。

{
  "mcpServers": {
    "serphubapi": {
      "command": "uvx",
      "args": ["serphubapi-mcp"],
      "env": { "SERPHUBAPI_API_KEY": "shapi_xxxxxxxx" }
    }
  }
}

OpenCode

文件:opencode.json。OpenCode 用 type local 加命令列表来描述本地 Server。

{
  "mcp": {
    "serphubapi": {
      "type": "local",
      "command": ["uvx", "serphubapi-mcp"],
      "environment": { "SERPHUBAPI_API_KEY": "shapi_xxxxxxxx" }
    }
  }
}

工具与价格:list_services 免费;search 按服务价(例如 google/web 10 积分,cache_first 半价,缓存命中 0)另加正文每页 3 积分;fetch 每页 3 积分、失败免费;batch 按条按 search 计费。完整说明:MCP 文档 →

Skill:直接调 API 的 Agent 用这个

如果你的 Agent 自己调 HTTP 而不用 MCP,把仓库根目录的 SKILL.md 给它。里面写了什么时候搜索、什么时候要带引用的答案、什么时候抓正文、怎么批量搜索。

# In your agent's skills folder, or pasted into its instructions:
# https://github.com/sou2026x/serp/blob/main/SKILL.md

不用 MCP 时也是同一批接口:POST /v1/search、POST /v1/ai-search、POST /v1/fetch、POST /v1/batch,都带 X-API-Key 请求头。

工具没出现时

  • 终端里跑 uvx serphubapi-mcp:能启动说明包没问题,问题在客户端配置。
  • 检查 Key:以 shapi_ 开头(老 fapi_ Key 仍可用)。
  • 改完配置重启客户端,并在 /dashboard/logs 里看调用记录。

写代码调接口:纯 REST

不需要 Agent。每次调用就是一个 POST,Key 放 X-API-Key 请求头;失败、空结果、缓存命中不计费。完整说明:API 文档 →

curl -s https://api.serphubapi.com/v1/search \
  -H "X-API-Key: shapi_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"q": "best espresso machine 2026", "engine": "google", "num": 5}'
import json, urllib.request

req = urllib.request.Request(
    "https://api.serphubapi.com/v1/search",
    data=json.dumps({"q": "best espresso machine 2026", "engine": "google", "num": 5}).encode(),
    headers={"X-API-Key": "shapi_xxxxxxxx", "Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as r:
    print(json.load(r)["results"])

同一个 Key 上的其他接口:POST /v1/ai-search 拿带引用的答案,POST /v1/fetch 把网页转成 Markdown,POST /v1/batch 一次跑最多 5 条搜索。

先试试:Playground

零配置:登录后直接在控制台 Playground 里试,按标准价计费。新账号送 1,000 积分。

打开 Playground →

批量跑数据:batch 搜索

给数据管线和横向对比用:一次调用跑最多 5 条独立搜索。每条按单次搜索计费,一条失败不阻塞其余条。

curl -s https://api.serphubapi.com/v1/batch \
  -H "X-API-Key: shapi_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"queries": [{"q": "espresso", "engine": "google"}, {"q": "espresso", "engine": "xiaohongshu", "type": "notes"}]}'

返回始终是 JSON,每条有自己的结果,整单总计费在 meta.total_credits_charged 里。

一个 Key,用遍所有搜索。

注册即送 1,000 积分,无需绑卡。