Google 搜索结果 API

获取 Google 公开搜索结果与相关问题,返回结构化结果。

USD 0.001000 / 次成功呼叫

公開 ID: web.search.serp · 版本 1

定價

USD 0.001000 / 次成功呼叫

快速開始

使用 API 金鑰探索此工具,再透過回傳的 provider 和 endpoint 檢查介面後執行。

將 GLOOP_API_BASE 設為 API 位址,GLOOP_API_KEY 設為伺服器端金鑰。

curl

curl --fail-with-body "${GLOOP_API_BASE%/}/v1/discover" \
  -H "Authorization: Bearer $GLOOP_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "limit": 5,
  "query": "Google 搜索结果"
}'

Python

import os, json, urllib.request

url = os.environ['GLOOP_API_BASE'].rstrip('/') + "/v1/discover"
headers = {'Authorization': 'Bearer ' + os.environ['GLOOP_API_KEY']}
headers['Content-Type'] = 'application/json'
data = "{\n  \"limit\": 5,\n  \"query\": \"Google 搜索结果\"\n}".encode('utf-8')
request = urllib.request.Request(url, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
    print(json.load(response))

Node.js

const url = process.env.GLOOP_API_BASE.replace(/\/$/, '') + "/v1/discover";
const headers = { Authorization: `Bearer ${process.env.GLOOP_API_KEY}` };
headers['Content-Type'] = 'application/json';
const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify({
  "limit": 5,
  "query": "Google 搜索结果"
}) });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
工具 API 文件 · POST /v1/inspect

輸入結構

{
  "additionalProperties": false,
  "properties": {
    "query": {
      "maxLength": 2000,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "query"
  ],
  "type": "object"
}

輸出結構

{
  "type": "object"
}

同類型工具