主题
设置 Google Ads 搜索广告 SERP 任务
POST /v3/serp/google/ads_search/task_post
本接口使用 POST 方法,通过 /v3/serp/google/ads_search/task_post 创建 Google Ads 搜索广告 SERP 任务。接口基于广告透明度数据,并指定的广告主、域名、位置、平台及时间范围返回广告信息。
任务支持两种执行优级:普通优级和高优级。历史数据最早可追溯至 2018-05-31。
> 注意:每个 SERP 默认最多 40 条结果,并按每个 SERP 计费。
> 实扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
接口信息
http
POST https://api.seermartech.cn/v3/serp/google/ads_search/task_post请求限制
- 所有请求体使用 UTF-8 编码的 JSON 格式。
- 请求体是 JSON 数组,单次请求最多 100 个任务。 平台限流以认证说明中的 30/60/120 次/分钟规则为准。
- 单次请求 100 个任务时,出部分将返回错误码
40006。 - 创建任务后,可通过返回的任务 ID 获取结果。
- 也可以在请求中
pingback_url或postback_url,在任务完成后接收通知或结果。 - 如果接收通知的服务器 10 秒未响应,连接将因时中断,任务会转移到任务就绪列表。
计费说明
本接口在创建任务时计费。任务深度 40 时,如果搜索引擎返回 40 条结果,可能产生额外费用。
- 普通优级:参考价以响应头
X-SeerMarTech-Charge-CNY为准。 - 高优级:相比普通优级可能产生额外费用。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。
请求参数
主要参数
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
advertiser_ids | array | 条件填 | 广告主标识符。当未指定 target 时填。最多可传 25 个值。广告主 ID 可通过 Google Ads 广告主查询接口获取。 |
target | string | 条件填 | 广告主账户的域名。当未指定 advertiser_ids 时填。 |
location_code | integer | 否 | 搜索引擎位置代码。使用该字段后,无需同时指定 location_name 或 location_coordinate。可通过 /v3/serp/google/ads_search/locations 获取可用位置代码。例如:2840。 |
depth | integer | 否 | SERP 解析深度,即返回结果数量。默认值为 40,最大值为 700。深度 40 时,如果返回结果 40 条,可能产生额外费用。 |
priority | integer | 否 | 任务优级。可选值:1:普通优级,默认值;2:高优级。高优级任务可能产生额外费用。 |
pingback_url | string | 否 | 任务完成通知地址。任务完成后,本平台将向该地址发送 GET 请求。URL 中可使用 $id 和 $tag 占位符,发送时会替换为任务 ID 和经过 URL 编码的标签值。 |
postback_url | string | 否 | 任务结果回调地址。任务完成后,本平台将以 POST 方式向该地址发送结果,结果使用 gzip 格式压缩。URL 中可使用 $id 和 $tag 占位符。 |
postback_data | string | 条件填 | postback_url 的数据类型。指定 postback_url 时填。当前可选值:advanced。 |
位置参数说明
location_code、location_name 和 location_coordinate 三只能选择一个。
如果未指定任何位置参数,系统将在所有可用位置范围搜索广告。
| 字段 | 类型 | 说明 |
|---|---|---|
location_name | string | 搜索引擎位置的完整名称。例如:London,England,United Kingdom。使用该字段后,无需指定 location_code 或 location_coordinate。 |
location_coordinate | string | 位置 GPS 坐标,格式为 纬度,经度。例如:52.6178549,-155.352142。使用该字段后,无需指定 location_name 或 location_code。 |
参数
| 字段 | 类型 | 说明 |
|---|---|---|
tag | string | 用户自定义任务标识符,最长 255 个字符。可用于任务与结果,指定的值会出现在响应的 data 对象中。 |
platform | string | 广告投放平台。可选值:all、google_play、google_maps、google_search、google_shopping、youtube。默认值:all。 |
format | string | 广告格式。可选值:all、text、image、video。 |
date_from | string | 查询时间范围的开始日期。格式为 yyyy-mm-dd。指定 date_to 时填。最早可用日期为 2018-05-31,最晚为当前日期。例如:2020-01-01。 |
date_to | string | 查询时间范围的结束日期。格式为 yyyy-mm-dd。指定 date_from 时填。最早可用日期为 2018-05-31,最晚为当前日期。例如:2020-01-01。 |
pingback_url 示例
text
https://your-server.com/pingscript?id=$id
https://your-server.com/pingscript?id=$id&tag=$tagpostback_url 示例
text
https://your-server.com/postbackscript?id=$id
https://your-server.com/postbackscript?id=$id&tag=$tagpingback_url 和 postback_url 中的特殊字符会进行 URL 编码,例如 # 会编码为 %23。
请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/serp/google/ads_search/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_code": 2840,
"platform": "google_search",
"advertiser_ids": [
"AR13752565271262920705",
"AR02439908557932462081"
]
},
{
"location_name": "United States",
"platform": "google_search",
"advertiser_ids": [
"AR13752565271262920705",
"AR02439908557932462081"
],
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/google/ads_search/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"location_code": 2840,
"platform": "google_search",
"advertiser_ids": [
"AR13752565271262920705",
"AR02439908557932462081",
],
},
{
"location_name": "United States",
"platform": "google_search",
"advertiser_ids": [
"AR13752565271262920705",
"AR02439908557932462081",
],
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
},
]
response = requests.post(url, headers=headers, json=payload, timeout=60)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
f"请求失败,错误码:{result.get('status_code')},"
f"错误信息:{result.get('status_message')}"
)TypeScript
typescript
import axios from "axios";
const payload = [
{
location_code: 2840,
platform: "google_search",
advertiser_ids: [
"AR13752565271262920705",
"AR02439908557932462081",
],
},
{
location_name: "United States",
platform: "google_search",
advertiser_ids: [
"AR13752565271262920705",
"AR02439908557932462081",
],
priority: 2,
tag: "some_string_123",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag",
},
];
axios
.post(
"https://api.seermartech.cn/v3/serp/google/ads_search/task_post",
payload,
{
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);
});响应说明
接口返回 JSON 数据,顶层 tasks 数组。创建任务成功后,任务的 result 通常为 null,后续需要使用任务 ID 查询结果,或回调通知。
顶层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。成功通常为 20000。 |
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 格式。后续可使用该 ID 获取任务结果。 |
status_code | integer | 任务状态码,通常在 10000 至 60000 范围。 |
status_message | string | 任务状态或提示信息。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。创建任务时通常为 0。 |
path | array | 请求 URL 路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | 任务结果数组。创建任务接口返回时通常为 null。 |
响应示例
json
{
"version": "0.1.20241101",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0746 sec.",
"cost": 0.0024,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0123 sec.",
"cost": 0.0024,
"result_count": 0,
"path": [
"v3",
"serp",
"google",
"ads_search",
"task_post"
],
"data": {
"api": "serp",
"function": "task_post",
"se": "google",
"se_type": "ads_search",
"priority": 2,
"depth": 41,
"language_code": "en",
"location_code": 2840,
"location_coordinate": "53.476225,-2.243572",
"platform": "youtube",
"date_from": "2018-09-30",
"date_to": "2024-11-12",
"advertiser_ids": [
"AR13752565271262920705"
],
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}错误处理
20000:请求成功。40006:单次请求的任务数量 100 个,出限制的任务将返回该错误。- 错误码:请根据响应中的
status_code和status_message进行处理,并为网络时、回调失败、参数校验失败等设计重试或异常记录机制。
实用场景
- 监测竞争对手广告:按广告主 ID 或域名追踪 Google 搜索广告,分析竞争对手的投放范围、广告形式和持续时间。
- 对比不同地区的广告覆盖:按位置代码、位置名称或坐标创建任务,评估广告主在不同城市和国家的投放差异。
- 分析广告素材类型:通过
format区分文本、图片和视频广告,为广告创意研究和竞品报告提供数据。 - 回溯历史投放活动:使用
date_from和date_to查询历史广告,识别季节性投放、长期投放及活动周期。 - 构建广告监控告警:
pingback_url或postback_url,在任务完成后自动触发数据库、报表更新或异常告警。