主题
SERP API 端点列表
接口说明
GET https://api.seermartech.cn/v3/serp/endpoints
本接口用于获取可用于创建 SERP API 任务的端点列表。该接口本身不产生费用。
接口返回 JSON 格式数据,顶层 tasks 数组本次请求的任务信息及可用端点列表。
请求方式
本接口使用 GET 请求,无需请求体。
请求头
| 请求头 | 类型 | 填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | 认证信息,格式为 Bearer smt_live_YOUR_KEY |
Content-Type | string | 否 | 建议设置为 application/json |
返回字段
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 格式 |
post_id | string | 调用方自定义的任务标识 |
status_code | integer | 任务级状态码,通常在 10000 至 60000 范围 |
status_message | string | 任务级提示信息 |
time | string | 任务执行耗时,单位为秒 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量 |
path | array | 当前请求对应的 API 路径信息 |
data | array | 本次 API 调用提交的数据 |
result | array | 请求结果数组,可用于创建 SERP API 任务的端点列表 |
计费说明
本接口不收费,响应中的 cost 为 0。
请求示例
cURL
bash
curl --location --request GET "https://api.seermartech.cn/v3/serp/endpoints" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/endpoints"
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:
# 读取可用的 SERP API 端点
print(result)
else:
print(
"请求失败。状态码:%s,提示:%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
axios({
method: "get",
url: "https://api.seermartech.cn/v3/serp/endpoints",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
})
.then((response) => {
const result = response.data;
if (result.status_code === 20000) {
// 读取可用的 SERP API 端点
console.log(result);
} else {
console.error(
`请求失败。状态码:${result.status_code},提示:${result.status_message}`
);
}
})
.catch((error) => {
console.error("网络或服务异常:", error.message);
});PHP
php
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.seermartech.cn/v3/serp/endpoints',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($response === false) {
echo '请求失败:' . curl_error($curl);
} else {
$result = json_decode($response, true);
if (($result['status_code'] ?? null) === 20000) {
// 读取可用的 SERP API 端点
print_r($result);
} else {
echo '请求失败。状态码:'
. ($result['status_code'] ?? '未知')
. ',提示:'
. ($result['status_message'] ?? '未知');
}
}
curl_close($curl);返回示例
json
{
"version": "3.20191128",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1118 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"post_id": null,
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1118 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"serp",
"endpoints"
],
"data": {
"api": "serp",
"function": "map"
},
"result": [
{
"path": "/v3/serp/..."
}
]
}
]
}> result 数组中的端点以接口返回结果为准。调用方可根据返回的路径选择对应的 SERP API 接口创建任务。
状态码
| 状态码 | 说明 |
|---|---|
20000 | 请求成功 |
| 状态码 | 请求或任务处理失败,原因以 status_message 为准 |
实用场景
- 获取可用 SERP 端点:在系统初始化或版本升级时动态读取当前支持的接口,硬编码路径导致任务调用失败。
- 构建 SERP 接口选择器:将返回的端点列表展示在运营中,帮助用户按搜索引擎、地区或任务类型选择接口。
- 校验接口容性:在正式创建 SERP 任务前检查目标端点是否可用,降低无效请求和任务失败率。
- 同步 API 能力单:定期保存端点列表及版本信息,用于维护 SEO 数据采集平台的接口目录和变更记录。