主题
Google Ads 按获取广告流量预测(实时)
POST /v3/keywords_data/google_ads/ad_traffic_by_keywords/live
接口说明
POST /v3/keywords_data/google_ads/ad_traffic_by_keywords/live
本接口用于根据、出价、匹类型、地域、语言和预测时间范围,获取 Google Ads 广告流量预测数据平均每次点击费用、预计点击次数和广告费用等指标。相比常规搜索量数据,本接口更适合评估特定的广告需求。
返回结果与 Google Ads 账户的历史广告数据、账户中已有的广告素材及因素。建议设置较高的 bid,以降低账户历史因素对预测结果的影响。
> 自 6 月 1 日起,本接口返回整个广告系列的批量数据,即返回任务中指定的数据。
调用限制
- 每个 Google Ads 账户通过 Live 接口每分钟最多发送 12 个请求。
- 每个 Live 请求只能 1 个任务。
keywords数组最多 1000 个。- 无论一次请求 1 个还是 1000 个,均按请求计费。
- 所有 POST 请求使用 UTF-8 编码的 JSON 格式。
预测时间范围
可以通过以下两种方式指定预测时间范围:
- 使用
date_from和date_to指定确切的未来日期; - 使用
date_interval指定预设时间范围:next_week:下周next_month:下月next_quarter:下季度
如果未指定上述任一方式,默认使用 next_month。
计费说明
每次请求都会产生费用。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
请求体是 JSON 数组,且每个 Live 请求只能一个任务对象。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keywords | array | 是 | 要查询的数组。最多 1000 个;每个最多 80 个字符、最多 10 个单词。会被转换为小写格式。部分组合可能没有可用数据。Google Ads 不支持部分特殊符号、Unicode 符号和表符号。 |
bid | integer | 是 | 最大自定义出价,表示愿意为广告点击支付的最高金额。出价越高,返回的预测指标和费用通常越高。 |
match | string | 是 | 匹类型。可选值:exact、broad、phrase。 |
location_name | string | 否 | 搜索引擎地域的完整名称,例如 London,England,United Kingdom。未指定时返回范围结果。使用此参数后,无需同时指定 location_code 或 location_coordinate。 |
location_code | integer | 否 | 搜索引擎地域代码,例如 2840。未指定时返回范围结果。使用此参数后,无需同时指定 location_name 或 location_coordinate。 |
location_coordinate | string | 否 | 地域 GPS 坐标,格式为 "纬度,经度",例如 52.6178549,-155.352142。返回结果将基于该坐标所属国家。使用此参数后,无需同时指定 location_name 或 location_code。 |
language_name | string | 否 | 搜索引擎语言名称,例如 English。 |
language_code | string | 否 | 搜索引擎语言代码,例如 en。 |
date_from | string | 条件填 | 预测时间范围的开始日期。指定 date_to 时同时指定。格式为 yyyy-mm-dd,最早可设置为明天。date_from 不得晚于 date_to。指定该参数和 date_to 后,无需指定 date_interval。 |
date_to | string | 条件填 | 预测时间范围的结束日期。指定 date_from 时同时指定。最早可设置为 date_from 后一天,最晚可设置为当前日期对应月份的下一年。格式为 yyyy-mm-dd。 |
date_interval | string | 否 | 预设预测时间范围。可选值:next_week、next_month、next_quarter。默认值为 next_month。指定该参数后,无需指定 date_from 和 date_to。 |
sort_by | string | 否 | 结果排序字段,按降序排列。可选值:relevance、impressions、ctr、average_cpc、cost、clicks。默认值为 relevance。 |
tag | string | 否 | 用户自定义任务标识,最多 255 个字符。该值会原样返回在响应任务的 data 对象中,可用于请求与结果。 |
地域和语言
可通过以下接口获取可用地域和语言:
- 地域列表:
GET /v3/keywords_data/google_ads/locations - 语言列表:
GET /v3/keywords_data/google_ads/languages
日期参数补说明
如果 Google Ads 状态接口 /v3/keywords_data/google_ads/status 返回的 actual_data 为:
false:date_from可以设置为前两个月及更早时间;true:date_from可以设置为上个月及更早时间。
请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/keywords_data/google_ads/ad_traffic_by_keywords/live" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_name": "United States",
"language_name": "English",
"bid": 999,
"match": "exact",
"keywords": [
"seo marketing"
],
"date_interval": "next_month",
"sort_by": "relevance",
"tag": "seo-forecast-demo"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/keywords_data/google_ads/ad_traffic_by_keywords/live"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
# POST 请求体是 JSON 数组
payload = [
{
"location_name": "United States",
"language_name": "English",
"bid": 999,
"match": "exact",
"keywords": ["seo marketing"],
"date_interval": "next_month",
}
]
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
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 payload = [
{
location_name: "United States",
language_name: "English",
bid: 999,
match: "exact",
keywords: ["seo marketing"],
date_interval: "next_month",
},
];
axios
.post(
"https://api.seermartech.cn/v3/keywords_data/google_ads/ad_traffic_by_keywords/live",
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 数组中。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。20000 表示成功。完整状态码请参考错误码文档。 |
status_message | string | 请求级状态说明。 |
time | string | 请求执行耗时,例如 3.5834 sec.。 |
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 数组中的结果数量。 |
path | array | 请求 URL 路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | 预测结果数组。 |
result 结果字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 请求中的。 |
location_code | integer / null | 请求中的地域代码。没有数据时为 null。 |
language_code | string / null | 请求中的语言代码。没有数据时为 null。 |
date_interval | string | 请求中的预测时间范围。 |
search_partners | boolean | 是否 Google 搜索合作伙伴。该参数已废弃,返回值始终为 false。 |
bid | integer | 创建任务时设置的最大自定义出价。出价越高,预测指标和费用可能越高。 |
match | string | 匹类型,可为 exact、broad 或 phrase。 |
impressions | float / null | 预测广告展示次数。该字段已废弃,返回值始终为 null。 |
ctr | float / null | 预测广告点击率,即预测点击次数除以广告展示次数。该字段已废弃,返回值始终为 null。 |
average_cpc | float / null | 预测平均每次点击费用,根据指定时间范围和历史数据计算。没有数据时为 null。 |
cost | float / null | 在指定时间范围投放广告的预测费用。没有数据时为 null。 |
clicks | float / null | 在指定时间范围的预测广告点击次数。没有数据时为 null。 |
响应示例
json
{
"version": "0.1.20221214",
"status_code": 20000,
"status_message": "Ok.",
"time": "3.5834 sec.",
"cost": 0.075,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "3.1000 sec.",
"cost": 0.075,
"result_count": 1,
"path": [
"v3",
"keywords_data",
"google_ads",
"ad_traffic_by_keywords",
"live"
],
"data": {
"api": "keywords_data",
"function": "ad_traffic_by_keywords",
"se": "google_ads",
"language_code": "en",
"location_code": 2840,
"bid": 999,
"match": "exact",
"keywords": [
"seo marketing"
],
"date_interval": "next_month"
},
"result": [
{
"keyword": "seo marketing",
"location_code": 2840,
"language_code": "en",
"date_interval": "next_month",
"search_partners": false,
"bid": 999,
"match": "exact",
"impressions": null,
"ctr": null,
"average_cpc": 4.25,
"cost": 425.0,
"clicks": 100.0
}
]
}
]
}状态码与错误处理
建议根据顶层 status_code 和任务级 status_code 分别处理请求状态与任务状态:
20000:请求或任务成功。- 非
20000:请求或任务处理失败,应结合status_message定位原因。 - 当
tasks_error大于0时,表示至少有一个任务返回错误。
完整错误码请参考:/v3/appendix/errors
实用场景
- 评估广告需求:根据指定出价和预测周期获取点击量、平均 CPC 与广告费用,判断是否值得投放。
- 制定 SEO 与 SEM优级:对同一主题下的进行广告流量预测,优建设搜索需求和商业价值的页面。
- 比较匹策略:分别使用
exact、phrase和broad获取预测结果,评估不同匹类型对点击量与成本的影响。 - 规划区域化投放预算:按国家、城市或坐标查询广告预测数据,为本地 SEO 和区域广告活动分预算。
- 预测季度营销流量:使用
next_week、next_month或next_quarter获取未来周期数据,支持营销排期和预算规划。