主题
批量难度(旧版)
GET /v3/dataforseo_labs/locations_and_languages
本接口使用 POST 方法,请求路径为:
/v3/dataforseo_labs/bulk_keyword_difficulty/live
> 说明:本接口为旧版结构。平台 API 已于 2022 年 3 月 19 日更新 Labs API 的请求与响应结构,但仍继续支持本页面所述的旧版接口。难度用于衡量某个自然搜索结果前 10 名的相对难度,取值范围为 0–100,采用对数尺度表示。数值越高,前 10 名的难度越大。
接口能力
单次请求最多可提交 1,000 个,并返回每个对应的难度评分。
所有 POST 请求体使用 UTF-8 编码的 JSON 格式,并且顶层结构是 JSON 数组:
json
[
{
"keywords": ["buy laptop", "cheap laptops for sale"],
"location_code": 2840,
"language_code": "en"
}
]每分钟最多可提交 2,000 次 API 请求。
计费说明
本接口按请求计费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
响应中的 cost 字段(平台原始 USD 成本兼容字段)表示任务或请求的费用信息,金额以平台扣费结果为准。
请求参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keywords | array | 是 | 目标列表。使用 UTF-8 编码。最多 1,000 个;每个至少 3 个字符。会被转换为小写格式。 |
location_name | string | 条件填 | 地区完整名称。未提供 location_code 时填写。可通过 /v3/dataforseo_labs/locations_and_languages 获取可用地区列表。示例:United Kingdom。 |
location_code | integer | 条件填 | 地区代码。未提供 location_name 时填写。可通过 /v3/dataforseo_labs/locations_and_languages 获取可用地区代码。示例:2840。 |
language_name | string | 条件填 | 语言完整名称。未提供 language_code 时填写。可通过 /v3/dataforseo_labs/locations_and_languages 获取可用语言列表。示例:English。 |
language_code | string | 条件填 | 语言代码。未提供 language_name 时填写。可通过 /v3/dataforseo_labs/locations_and_languages 获取可用语言代码。示例:en。 |
tag | string | 否 | 用户自定义任务标识,最多 255 个字符。可用于识别任务并将请求与响应结果匹。提交的值会原样返回在响应的 data 对象中。 |
location_name 与 location_code 二选一;language_name 与 language_code 二选一。
响应结构
接口返回 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 数组中的数量。 |
path | array | 请求 URL 路径。 |
data | object | 请求中提交的参数。 |
result | array | 难度结果数组。 |
result 结果字段
| 字段 | 类型 | 说明 |
|---|---|---|
location_code | integer | 请求中使用的地区代码。没有数据时为 null。 |
language_code | string | 请求中使用的语言代码。没有数据时为 null。 |
total_count | integer | 数据库中与请求的结果总数。 |
items_count | integer | items 数组中返回的结果数量。 |
items | array | 含及难度评分。 |
items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 请求中的。 |
keyword_difficulty | integer | 难度评分,范围为 0–100。该指标用于表示自然搜索结果前 10 名的难度,评分基于搜索结果前 10 个页面的链接等因素计算。 |
请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/dataforseo_labs/bulk_keyword_difficulty/live" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"keywords": [
"buy laptop",
"cheap laptops for sale",
"purchase laptop"
],
"location_code": 2840,
"language_code": "en",
"tag": "laptop-keywords-2024"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/dataforseo_labs/bulk_keyword_difficulty/live"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
# 请求体顶层是 JSON 数组
payload = [
{
"keywords": [
"buy laptop",
"cheap laptops for sale",
"purchase laptop",
],
"location_name": "United States",
"language_name": "English",
}
]
response = requests.post(url, headers=headers, json=payload, timeout=60)
response.raise_for_status()
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败:Code=%s Message=%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
const payload = [
{
keywords: [
"buy laptop",
"cheap laptops for sale",
"purchase laptop",
],
location_code: 2840,
language_code: "en",
},
];
axios
.post(
"https://api.seermartech.cn/v3/dataforseo_labs/bulk_keyword_difficulty/live",
payload,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
// 处理响应数据
console.log(response.data);
})
.catch((error) => {
// 处理 HTTP 或接口错误
console.error(error.response?.data || error.message);
});响应示例
json
{
"version": "0.1.20211130",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1214 sec.",
"cost": 0.0103,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "08092525-2802-0114-0000-6d7d8c6e1e4a",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0967 sec.",
"cost": 0.0103,
"result_count": 1,
"path": [
"v3",
"dataforseo_labs",
"bulk_keyword_difficulty",
"live"
],
"data": {
"api": "dataforseo_labs",
"function": "bulk_keyword_difficulty",
"keywords": [
"buy laptop",
"cheap laptops for sale",
"purchase laptop"
],
"location_code": 2840,
"language_code": "en"
},
"result": [
{
"location_code": 2840,
"language_code": "en",
"total_count": 3,
"items_count": 3,
"items": [
{
"keyword": "buy laptop",
"keyword_difficulty": 68
},
{
"keyword": "cheap laptops for sale",
"keyword_difficulty": 74
},
{
"keyword": "purchase laptop",
"keyword_difficulty": 61
}
]
}
]
}
]
}错误处理
建议根据以下字段实现错误处理机制:
- 顶层
status_code:判断整个请求是否成功。 tasks_error:判断是否有任务执行失败。tasks[].status_code:判断单个任务是否成功。status_message:获取请求级错误说明。tasks[].status_message:获取任务级错误说明。
当请求失败、参数不完整或指定地区与语言不受支持时,应记录状态码与说明信息,并将错误任务结果当作有效难度数据使用。
实用场景
- 批量评估竞争度:一次提交最多 1,000 个,快速筛选更容易自然搜索前 10 名的目标词。
- 制定优级:结合难度与搜索量数据,优创建竞争度适中、备排名机会的。
- 比较不同市场的 SEO 难度:针对不同地区代码和语言代码重复查询同一组,评估本地化市场的排名竞争差异。
- 构建分层体系:
keyword_difficulty区间划分核心词、成长词和长尾词,为不同阶段的页面匹目标。 - 监控策略变化:通过
tag标记项目、批次或日期,定期重复请求并对比难度变化。