主题
Google 分类支持语言列表
GET /v3/dataforseo_labs/google/categories_for_keywords/languages
本接口用于获取 Google「分类」接口支持的语言列表,可用于调用 /v3/dataforseo_labs/google/categories_for_keywords/live 时校验或选择语言。
请求方法与路径:
http
GET https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages计费说明
本接口调用,接口返回的 cost 通常为 0。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
响应说明
接口返回 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 | GET 请求路径中使用的接口参数 |
result | array | 语言列表结果 |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
language_name | string | 语言名称 |
language_code | string | 根据 ISO 639-1 标准定义的语言代码 |
请求示例
cURL
bash
curl --location --request GET \
"https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
url = "https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers)
data = response.json()
if response.status_code == 200 and data.get("status_code") == 20000:
print(data)
# 在此处理语言列表
else:
print(
"请求失败,状态码:%s,信息:%s"
% (data.get("status_code"), data.get("status_message"))
)TypeScript
typescript
import axios from "axios";
axios
.get(
"https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages",
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
const result = response.data;
// 在此处理语言列表
console.log(result);
})
.catch((error) => {
console.error("请求失败:", error.response?.data || error.message);
});PHP
php
<?php
$url = 'https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages';
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPGET => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($response, true);
if ($httpCode === 200 && ($result['status_code'] ?? null) === 20000) {
print_r($result);
// 在此处理语言列表
} else {
echo '请求失败:' . ($result['status_message'] ?? '未知错误');
}C#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public static class ApiExample
{
public static async Task GetLanguagesAsync()
{
using var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "smt_live_YOUR_KEY");
var response = await httpClient.GetAsync(
"https://api.seermartech.cn/v3/dataforseo_labs/google/categories_for_keywords/languages"
);
var result = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
Console.WriteLine(result);
// 在此解析并处理语言列表
}
else
{
Console.WriteLine($"请求失败,HTTP 状态码:{response.StatusCode}");
}
}
}响应示例
json
{
"version": "0.1.20240626",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0702 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0100 sec.",
"cost": 0,
"result_count": 2,
"path": [
"v3",
"dataforseo_labs",
"google",
"categories_for_keywords",
"languages"
],
"data": {
"api": "dataforseo_labs",
"function": "languages",
"se": "google",
"se_type": "categories_for_keywords"
},
"result": [
{
"language_name": "英语",
"language_code": "en"
},
{
"language_name": "中文",
"language_code": "zh"
}
]
}
]
}实用场景
- 获取支持语言列表,在创建分类任务前校验语言参数,减少因语言代码不受支持导致的请求失败。
- 构建语言选择器,将接口返回的语言名称和 ISO 639-1 代码展示在 SEO 工后台,支持用户按目标市场选择语言。
- 初始化多语言分析,根据实时返回的可用语言生成项目,硬编码语言范围。
- 校验跨市场 SEO 任务参数,在批量分析不同国家或地区的前确认对应语言是否可用于 Google 分类分析。
- 维护接口能力单,定期同步语言列表,为多语言研究和市场覆盖率统计提供基础数据。