API 文档

集成 SerpBase Google 网页、图片、新闻和视频 API 所需的一切。

认证

请在 X-API-Key 请求头中传入你的 API key。

bash
curl -X POST https://api.serpbase.dev/google/search   -H "Content-Type: application/json"   -H "X-API-Key: your_api_key"   -d '{
    "q": "python asyncio",
    "hl": "en",
    "gl": "us",
    "page": 1
  }'
每次成功请求消耗 1 个额度。调度失败和上游超时会自动退还。

端点

POST
/google/search
search

Default Google search results with organic links and rich SERP modules.

POST
/google/images
images

Google Images results with image URLs, thumbnails, and source domains.

POST
/google/news
news

Google News results with publisher, time, snippet, and thumbnail when available.

POST
/google/videos
videos

Google Videos results with source, channel, duration, and thumbnails.

参数

q必填
string
Search query string.
hl
string
Language code, default `en`.
gl
string
Country code, default `us`.
page
number
1-based page number, default `1`.

四个端点都接受相同的请求体。端点本身决定返回的结果类型。

响应结构

所有搜索端点都返回 HTTP 200。请使用 status 字段判断业务是否成功。

statusnumber

Business status code. `0` means success.

search_typestring

Resolved response type: `search`, `images`, `news`, or `videos`.

querystring

Normalized query string from the request.

pagenumber

Current page number.

session_idstring

Worker session identifier used to serve the request.

elapsed_msnumber

Total request duration in milliseconds.

organicOrganicResult[]?

Web-only organic results.

imagesImageResult[]?

Image search results.

newsNewsResult[]?

News search results.

videosVideoResult[]?

Video search results.

top_storiesTopStory[]?

Top stories module on web SERPs.

people_also_askPAA[]?

People Also Ask data on web SERPs.

knowledge_graphKnowledgeGraph?

Knowledge panel data on web SERPs.

related_searchesstring[]?

Related searches on web SERPs.

示例

网页搜索请求

bash
curl -X POST https://api.serpbase.dev/google/search   -H "Content-Type: application/json"   -H "X-API-Key: your_api_key"   -d '{
    "q": "python asyncio",
    "hl": "en",
    "gl": "us",
    "page": 1
  }'

网页搜索响应

json
{
  "status": 0,
  "search_type": "search",
  "query": "python asyncio",
  "page": 1,
  "organic": [
    {
      "rank": 1,
      "title": "Async IO in Python",
      "link": "https://realpython.com/async-io-python/",
      "display_link": "realpython.com",
      "snippet": "A practical guide to asyncio in Python..."
    }
  ],
  "people_also_ask": [
    {
      "question": "What is asyncio in Python?",
      "answer": "asyncio is Python's asynchronous I/O framework...",
      "title": "asyncio docs",
      "link": "https://docs.python.org/3/library/asyncio.html"
    }
  ],
  "session_id": "7f2e5a8c4b",
  "elapsed_ms": 423
}

图片搜索请求

bash
curl -X POST https://api.serpbase.dev/google/images   -H "Content-Type: application/json"   -H "X-API-Key: your_api_key"   -d '{"q":"iphone 15 pro blue","hl":"en","gl":"us","page":1}'

图片搜索响应

json
{
  "status": 0,
  "search_type": "images",
  "query": "iphone 15 pro blue",
  "page": 1,
  "images": [
    {
      "title": "iPhone 15 Pro blue",
      "link": "https://store.example.com/iphone-15-pro-blue",
      "image_url": "https://img.example.com/iphone-blue.jpg",
      "thumbnail_url": "https://img.example.com/iphone-blue-thumb.jpg",
      "source": "Store Example",
      "domain": "store.example.com"
    }
  ],
  "session_id": "7f2e5a8c4b",
  "elapsed_ms": 388
}

新闻搜索响应

json
{
  "status": 0,
  "search_type": "news",
  "query": "apple event",
  "page": 1,
  "news": [
    {
      "title": "Apple announces new chips at spring event",
      "link": "https://www.theverge.com/apple-launch-event",
      "source": "The Verge",
      "time": "Apr 9, 2026",
      "snippet": "Apple used the event to introduce faster laptop and desktop silicon.",
      "thumbnail_url": "https://cdn.theverge.com/apple-event.jpg"
    }
  ],
  "session_id": "7f2e5a8c4b",
  "elapsed_ms": 401
}

视频搜索响应

json
{
  "status": 0,
  "search_type": "videos",
  "query": "python asyncio tutorial",
  "page": 1,
  "videos": [
    {
      "title": "Python asyncio tutorial for beginners",
      "link": "https://www.youtube.com/watch?v=abc123",
      "source": "Corey Schafer",
      "duration": "23:45",
      "time": "1 week ago",
      "thumbnail_url": "https://i.ytimg.com/vi/abc123/hqdefault.jpg"
    }
  ],
  "session_id": "7f2e5a8c4b",
  "elapsed_ms": 417
}

JavaScript / Node.js

javascript
const response = await fetch("https://api.serpbase.dev/google/news", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "your_api_key",
  },
  body: JSON.stringify({ q: "apple event", gl: "us", hl: "en", page: 1 }),
});

const data = await response.json();
if (data.status !== 0) throw new Error(data.error || "search failed");
for (const item of data.news ?? []) {
  console.log(item.source, item.title);
}

状态码

0
SUCCESS
Request completed successfully.
1000
INVALID_REQUEST
Missing or invalid request body or parameters.
1001
UNAUTHORIZED
Missing, invalid, or revoked API key.
1020
INSUFFICIENT_CREDITS
Account balance is not enough to run the request.
1029
RATE_LIMITED
Account QPS or concurrency limit exceeded.
1502
UPSTREAM_FAILED
Worker returned an upstream parsing or fetch error.
1503
SERVICE_UNAVAILABLE
No worker session is currently available.
1504
UPSTREAM_TIMEOUT
Gateway timed out while waiting for a worker result.
1500
INTERNAL_ERROR
Unexpected internal server error.