主题
设置 Google Ads 网站任务
POST /v3/keywords_data/google_ads/keywords_for_site/task_post
本接口使用 POST 方法,路径为:
/v3/keywords_data/google_ads/keywords_for_site/task_post
本接口用于根据指定域名或网页获取,并返回出价、上月搜索量、过去一年搜索量趋势及竞争程度等数据。该接口采用标准任务模式:提交任务后,系统完成采集,再通过任务结果接口获取数据。
如果业务需要实时返回结果,可使用 Live 方法。历史数据最长支持查询 4 年。
请求地址
text
POST https://api.seermartech.cn/v3/keywords_data/google_ads/keywords_for_site/task_post认证方式
请求头使用 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json计费说明
- 本接口在成功创建任务时计费。 平台限流以认证说明中的 30/60/120 次/分钟规则为准条;无论返回 1 条还是 2000 条,单次任务价格相同。 平台限流以认证说明中的 30/60/120 次/分钟规则为准。
- 每个 POST 请求最多 100 个任务,部分的任务将返回错误码
40006。 - 参考价约 ¥0.36 / 任务;批量任务的价格以账户为准。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。
任务完成后,可以通过任务 id 查询结果,也可以在提交任务时 postback_url 或 pingback_url,由本平台主动通知。
> 如果回调服务器在 10 秒未响应,连接会因时中断,任务将转移至 tasks_ready 列表。
请求参数
请求体为 UTF-8 编码的 JSON 数组:
json
[
{
"target": "example.com",
"target_type": "site",
"location_name": "United States",
"language_name": "English"
}
]任务参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
target | string | 是 | 目标域名或网页 URL。合 target_type 指定获取整个网站或单个页面的。 |
target_type | string | 否 | 目标类型。可选值:site、page。默认值为 page。site 表示整个网站,page 表示指定网页。 |
location_name | string | 否 | 搜索引擎地域的完整名称。不填写时返回范围结果。使用该参数后,无需同时指定 location_code 或 location_coordinate。可通过以下接口获取可用地域:/v3/keywords_data/google_ads/locations。示例:London,England,United Kingdom |
location_code | integer | 否 | 搜索引擎地域代码。不填写时返回范围结果。使用该参数后,无需同时指定 location_name 或 location_coordinate。可通过 /v3/keywords_data/google_ads/locations 获取。示例:2840 |
location_coordinate | string | 否 | 地域 GPS 坐标,格式为 "纬度,经度"。数据将该坐标所属国家返回。使用该参数后,无需同时指定 location_name 或 location_code。示例:52.6178549,-155.352142 |
language_name | string | 否 | 搜索引擎语言的完整名称。可通过 /v3/keywords_data/google_ads/languages 获取可用语言。示例:English |
language_code | string | 否 | 搜索引擎语言代码。可通过 /v3/keywords_data/google_ads/languages 获取。示例:en |
search_partners | boolean | 否 | 是否 Google 搜索合作伙伴网络的数据。true 表示;默认值为 false,返回 Google 搜索网站数据。 |
date_from | string | 否 | 数据时间范围的开始日期,格式为 yyyy-mm-dd。默认查询过去 12 个月。最早可查询当前日期前 4 年的数据。该日期不能晚于 date_to 或昨天。 |
date_to | string | 否 | 数据时间范围的结束日期,格式为 yyyy-mm-dd。不能晚于昨天;未填写时默认使用昨天。示例:2022-11-30 |
include_adult_keywords | boolean | 否 | 是否与成人的。默认值为 false。即使设为 true,受广告政策限制,也可能没有数据。 |
sort_by | string | 否 | 结果排序字段,支持:relevance、search_volume、competition_index、low_top_of_page_bid、high_top_of_page_bid。结果按降序排列。默认值为 relevance。 |
postback_url | string | 否 | 任务完成后,本平台向该地址发送结果的 POST 请求,请求使用 gzip 压缩。URL 中可使用 $id 和 $tag 占位符。 |
pingback_url | string | 否 | 任务完成后,本平台向该地址发送 GET 请求通知。URL 中可使用 $id 和 $tag 占位符。 |
tag | string | 否 | 用户自定义任务标识,最长 255 个字符。可用于匹任务与结果,提交的值会在响应的 data 对象中返回。 |
日期参数说明
date_from和date_to须使用yyyy-mm-dd格式。date_to不能晚于昨天。- 如果状态接口
/v3/keywords_data/google_ads/status的actual_data为false,date_from最早可设置为上上个月及更早日期。 - 如果
actual_data为true,date_from可设置为上个月及更早日期。
回调地址说明
postback_url 示例:
text
https://your-server.com/postbackscript?id=$id&tag=$tagpingback_url 示例:
text
https://your-server.com/pingscript?id=$id&tag=$tag本平台会在发送请求前替换 $id 和 $tag。回调地址中的特殊字符会进行 URL 编码,例如 # 会编码为 %23。
响应字段
接口返回 JSON 数据 tasks 数组。
顶层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。 |
status_message | string | 请求级状态说明。 |
time | string | 请求执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 中的任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。 |
status_code | integer | 任务状态码,通常在 10000 至 60000 范围。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。任务刚创建时通常为 0。 |
path | array | 请求路径信息。 |
data | object | 提交任务时使用的参数,同时接口上下文信息。 |
result | array | 任务结果。任务创建成功时为 null,需在任务完成后查询。 |
请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/keywords_data/google_ads/keywords_for_site/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_name": "United States",
"target": "example.com",
"target_type": "site"
},
{
"location_code": 2840,
"target": "example.com",
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
"location_name": "United States",
"target": "example.com",
"postback_url": "https://your-server.com/postbackscript"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/keywords_data/google_ads/keywords_for_site/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
post_data = [
{
"location_name": "United States",
"target": "example.com",
"target_type": "site",
},
{
"location_code": 2840,
"target": "example.com",
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
},
{
"location_name": "United States",
"target": "example.com",
"postback_url": "https://your-server.com/postbackscript",
},
]
response = requests.post(url, headers=headers, json=post_data)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,状态码:%s,消息:%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
const postData = [
{
location_name: "United States",
target: "example.com",
target_type: "site",
},
{
location_code: 2840,
target: "example.com",
tag: "some_string_123",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag",
},
{
location_name: "United States",
target: "example.com",
postback_url: "https://your-server.com/postbackscript",
},
];
axios
.post(
"https://api.seermartech.cn/v3/keywords_data/google_ads/keywords_for_site/task_post",
postData,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error("请求失败:", error.response?.data || error.message);
});成功响应示例
以下示例展示任务创建成功时的响应结构。示例中的 cost 为人民币参考展示值,扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
json
{
"version": "0.1.20200130",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1108 sec.",
"cost": 1.08,
"tasks_count": 3,
"tasks_error": 0,
"tasks": [
{
"id": "01301901-1535-0108-0000-daf9eadecca9",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0019 sec.",
"cost": 0.36,
"result_count": 0,
"path": [
"v3",
"keywords_data",
"google_ads",
"keywords_for_site",
"task_post"
],
"data": {
"api": "keywords_data",
"function": "keywords_for_site",
"se": "google_ads",
"location_name": "United States",
"target": "example.com"
},
"result": null
},
{
"id": "01301901-1535-0108-0000-d86ef6dbd3a8",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0018 sec.",
"cost": 0.36,
"result_count": 0,
"path": [
"v3",
"keywords_data",
"google_ads",
"keywords_for_site",
"task_post"
],
"data": {
"api": "keywords_data",
"function": "keywords_for_site",
"se": "google_ads",
"location_name": "United States",
"language_name": null,
"target": "example.com",
"postback_url": "https://your-server.com/postbackscript"
},
"result": null
}
]
}常见状态码
| 状态码 | 含义 |
|---|---|
20000 | 请求成功。 |
20100 | 任务创建成功。 |
40006 | 单个 POST 请求中的任务数量 100 个。 |
完整错误码请参考错误码文档。
实用场景
- 挖掘竞争对手网站:提交竞争对手域名并获取、搜索量和竞争指数,支持竞品 SEO 差距分析。
- 评估网页覆盖范围:指定页面获取建议,识别页面已有及潜在的主题。
- 制定选题计划:结合搜索量趋势和性排序,筛选适合创作的,提升选题决策效率。
- 比较不同地域的需求:按国家、城市或坐标提交任务,对比不同市场的搜索量和竞争程度,支持本地化 SEO 策略。
- 规划付费搜索投放:依据顶部展示位出价、搜索量和竞争指数筛选,为 Google Ads 预算与投放组合提供依据。