Skip to content

获取百度 SERP 支持的语言列表

GET /v3/serp/baidu/languages

本接口使用 GET 方法,路径为:

GET https://api.seermartech.cn/v3/serp/baidu/languages

用于获取百度 SERP 数据支持的语言列表。接口无需提交请求参数,也不会创建任务。

计费说明

本接口调用,不产生接口费用。

请求示例

cURL

bash
curl --location --request GET "https://api.seermartech.cn/v3/serp/baidu/languages" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json"

PHP

php
<?php

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.seermartech.cn/v3/serp/baidu/languages',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer smt_live_YOUR_KEY',
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);

if ($response === false) {
    echo '请求失败:' . curl_error($ch);
} else {
    $result = json_decode($response, true);

    if (($result['status_code'] ?? 0) === 20000) {
        print_r($result);
    } else {
        echo '错误码:' . ($result['status_code'] ?? '未知');
        echo ',错误信息:' . ($result['status_message'] ?? '未知');
    }
}

curl_close($ch);

TypeScript

typescript
import axios from 'axios';

axios.get('https://api.seermartech.cn/v3/serp/baidu/languages', {
  headers: {
    Authorization: 'Bearer smt_live_YOUR_KEY',
    'Content-Type': 'application/json',
  },
})
  .then((response) => {
    const result = response.data;

    if (result.status_code === 20000) {
      console.log(result);
    } else {
      console.error(
        `错误码:${result.status_code},错误信息:${result.status_message}`,
      );
    }
  })
  .catch((error) => {
    console.error('请求失败:', error.message);
  });

Python

python
import requests

url = "https://api.seermartech.cn/v3/serp/baidu/languages"
headers = {
    "Authorization": "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json",
}

response = requests.get(url, headers=headers)
result = response.json()

if result.get("status_code") == 20000:
    print(result)
else:
    print(
        f"错误码:{result.get('status_code')},"
        f"错误信息:{result.get('status_message')}"
    )

响应结构

接口返回 JSON 对象 tasks 数组以及语言列表结果。

顶层字段

字段名类型说明
versionstring当前 API 版本
status_codeinteger请求整体状态码
status_messagestring请求整体状态说明
timestring请求执行耗时,单位为秒
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务数量
tasks_errorinteger返回错误的任务数量
tasksarray任务结果数组

tasks 数组字段

字段名类型说明
idstring任务唯一标识,采用 UUID 格式
status_codeinteger当前任务的状态码,通常为 20000 表示成功
status_messagestring当前任务的状态说明
timestring当前任务执行耗时,单位为秒
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的数量
patharray请求路径信息
dataobject请求参数及接口上下文信息
resultarray语言列表结果

result 数组字段

字段名类型说明
language_namestring语言名称
language_codestring语言代码,遵循 ISO 639-1 标准

响应示例

json
{
  "version": "3.20191128",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.1773 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "01234567-89ab-cdef-0123-456789abcdef",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.1773 sec.",
      "cost": 0,
      "result_count": 2,
      "path": [
        "v3",
        "serp",
        "baidu",
        "languages"
      ],
      "data": {
        "api": "serp",
        "function": "languages",
        "se": "baidu"
      },
      "result": [
        {
          "language_name": "中文",
          "language_code": "zh"
        },
        {
          "language_name": "英语",
          "language_code": "en"
        }
      ]
    }
  ]
}

状态码

  • 20000:请求成功。
  • 状态码:请求或任务执行失败,错误信息以 status_message 为准。

注意事项

  • 本接口为 GET 请求,不需要请求体。
  • 请求头携带 Authorization: Bearer smt_live_YOUR_KEY
  • 返回的 language_code 可用于百度 SERP 查询接口中的语言参数。
  • 完整支持列表以接口实时返回结果为准。

实用场景

  • 读取百度支持的语言代码,在创建 SERP 查询任务前校验参数,因语言错误导致任务失败。
  • 构建语言选择器,在 SEO 平台中动态展示可用语言,支持多语言排名监控。
  • 同步语言数据,将语言名称与 ISO 639-1 代码写本地,统一不同报表和查询模块的语言标识。
  • 校验跨市场任务,在批量生成百度搜索任务时筛选合法语言,提升任务提交成功率。

统一入口:官网 · LLM API · 控制台