Google Search API
Google Search API 允许您执行网页搜索并接收结构化结果。它支持多种搜索类型、地理定位、设备模拟以及两种结果深度模式。
端点
Bash
POST https://api.scavio.dev/api/v1/google请求头
| 请求头 | 值 | 必填 |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | 是 |
Content-Type | application/json | 是 |
请求体
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
query | string | -- | 必填。 搜索查询(1-500 个字符)。 |
search_type | string | classic | 可选值: classic, news, maps, images, lens |
country_code | string | -- | ISO 3166-1 alpha-2 国家代码(例如 us, gb, de)。 查看完整列表。 |
language | string | -- | ISO 639-1 语言代码(例如 en, fr, es) |
page | number | 1 | 结果页码(从 1 开始) |
device | string | desktop | desktop 或 mobile。新闻搜索仅支持 desktop。 |
nfpr | boolean | false | 设置为 true 以禁用查询自动纠正 |
light_request | boolean | 省略(轻量模式) | 省略则使用轻量模式(1 积分)。设置为 false 以获取完整结果(2 积分),包括知识图谱、相关搜索等。 |
积分消耗
| 场景 | 积分 |
|---|---|
light_request 省略或未发送 | 1 |
"light_request": false | 2 |
最简示例
curl -X POST 'https://api.scavio.dev/api/v1/google' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{"query": "Scavio search API"}'完整示例(包含所有参数)
curl -X POST 'https://api.scavio.dev/api/v1/google' \
-H 'Authorization: Bearer sk_live_your_key' \
-H 'Content-Type: application/json' \
-d '{
"query": "AI startups funding",
"search_type": "news",
"country_code": "us",
"language": "en",
"page": 1,
"device": "desktop",
"nfpr": false,
"light_request": false
}'约束条件
- 当
search_type为news时,device仅允许desktop。发送mobile将返回 400 错误。 - 无效的
search_type值(例如shopping,ai_mode)将返回 400 验证错误。 device仅接受desktop或mobile。不支持tablet。
响应格式
所有成功的响应都返回一个 JSON 对象。部分字段始终存在,而其他字段仅在非空时出现(通常在完整模式下)。
核心字段(始终存在)
| 字段 | 类型 | 描述 |
|---|---|---|
results | array | 自然搜索结果对象数组 |
results[].title | string | 搜索结果页面的标题 |
results[].url | string | 结果的完整 URL |
results[].content | string | 页面的摘要或元描述 |
results[].position | number | 在结果中的位置(从 1 开始) |
query | string | 执行的查询 |
page | number | 返回的页码 |
country_code | string | 搜索使用的国家代码 |
language | string | 搜索使用的语言代码 |
response_time | number | 服务器端响应时间(毫秒) |
credits_used | number | 消耗的积分数量(1 或 2) |
credits_remaining | number | 当前计费周期内的剩余积分 |
可选字段(非空时存在)
这些字段通常在完整模式("light_request": false)下返回,但在数据可用时也可能在轻量模式下出现。
| 字段 | 类型 | 描述 |
|---|---|---|
top_stories | array | 头条新闻轮播项 |
news_results | array | 新闻文章,包含 title, link, source, snippet, date, relative_date, domain, position |
knowledge_graph | object | 知识面板,包含 title, subtitle 和 factoids 数组 |
questions | array | "其他人还在问",包含 question 和 answer |
related_searches | array | 相关查询,每项包含 query, link, type, position |
total_results | number | 该查询的估计总结果数 |
search_url | string | 该查询对应的原始搜索引擎 URL |
轻量模式响应示例
JSON
{
"results": [
{
"title": "Scavio - Search API for Developers",
"url": "https://scavio.dev",
"content": "One API to search every platform. Structured JSON results.",
"position": 1,
"displayed_url": "https://scavio.dev",
"domain": "scavio.dev",
"date": null,
"rich_snippet": {},
"sitelinks": []
}
],
"query": "Scavio search API",
"page": 1,
"country_code": "us",
"language": "en",
"response_time": 450,
"credits_used": 1,
"credits_remaining": 999
}完整模式响应示例
JSON
{
"results": [
{
"title": "Scavio - Search API for Developers",
"url": "https://scavio.dev",
"content": "One API to search every platform. Structured JSON results.",
"position": 1,
"displayed_url": "https://scavio.dev",
"domain": "scavio.dev",
"date": null,
"rich_snippet": {},
"sitelinks": []
}
],
"query": "Scavio search API",
"page": 1,
"country_code": "us",
"language": "en",
"response_time": 620,
"total_results": 1250000,
"search_url": "https://www.google.com/search?q=...",
"knowledge_graph": {
"title": "Scavio",
"subtitle": "Search API Platform",
"factoids": [
{ "title": "Type", "content": "Developer API" }
]
},
"related_searches": [
{ "query": "scavio api pricing", "link": null, "type": null, "position": 0 },
{ "query": "scavio search api docs", "link": null, "type": null, "position": 1 }
],
"questions": [
{
"question": "What is Scavio?",
"answer": "Scavio is a multi-platform search API..."
}
],
"credits_used": 2,
"credits_remaining": 998
}新闻结果示例
当 search_type 为 news 时,news_results 字段将被填充:
JSON
{
"news_results": [
{
"title": "AI Startups Raise Record Funding in Q1 2026",
"link": "https://example.com/ai-funding",
"source": "TechCrunch",
"snippet": "AI companies raised over $15B in Q1 2026...",
"date": "2026-03-31T20:00:00.000Z",
"relative_date": "2 hours ago",
"domain": "techcrunch.com",
"position": 1
}
]
}注意事项
results数组按相关性排序(位置 1 最相关)- 可选字段仅在非空时存在 -- 访问前请务必检查其是否存在
- 轻量模式(1 积分)返回核心结果。完整模式(2 积分)可能包含所有可选字段。
相关文档
- YouTube API -- 搜索和元数据
- Amazon API -- 产品搜索和详情
- Country Codes -- 支持的国家代码
- Errors -- 错误代码和处理