主题
Google 可用历史日期
本接口使用 GET 方法,请求路径为:
/v3/dataforseo_labs/google/available_history
用于获取可设置到 /v3/dataforseo_labs/google/domain_metrics_by_categories/live 接口 first_date 和 second_date 参数中的历史日期列表。
计费说明
调用本接口不收取费用,参考价为 ¥0 / 次。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求示例
curl
bash
curl --location --request GET \
"https://api.seermartech.cn/v3/dataforseo_labs/google/available_history" \
--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/dataforseo_labs/google/available_history',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
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);
print_r($result);
}
curl_close($ch);TypeScript
typescript
import axios from "axios";
axios({
method: "get",
url: "https://api.seermartech.cn/v3/dataforseo_labs/google/available_history",
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);
});Python
python
import requests
url = "https://api.seermartech.cn/v3/dataforseo_labs/google/available_history"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers)
if response.ok:
print(response.json())
else:
print(f"请求失败,HTTP 状态码:{response.status_code}")
print(response.text)C#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public static class ApiDemo
{
public static async Task GetAvailableHistory()
{
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/available_history"
);
var result = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
Console.WriteLine(result);
}
else
{
Console.WriteLine(
$"请求失败。HTTP 状态码:{(int)response.StatusCode},响应:{result}"
);
}
}
}响应说明
接口返回 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 | 任务结果数组 |
任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 请求路径信息 |
data | object | 本次请求使用的参数信息 |
result | array | 可用历史日期结果数组 |
data 字段
| 字段 | 类型 | 说明 |
|---|---|---|
api | string | API 模块名称,固定为 dataforseo_labs |
function | string | 接口名称,固定为 available_history |
se | string | 搜索引擎,固定为 google |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
date | string | 可用历史日期,格式为 YYYY-MM-DD |
date 表示可用于 /v3/dataforseo_labs/google/domain_metrics_by_categories/live 接口 first_date 或 second_date 参数的日期。
示例:
text
2022-05-16响应示例
json
{
"version": "0.1.20220720",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0577 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0500 sec.",
"cost": 0,
"result_count": 3,
"path": [
"v3",
"dataforseo_labs",
"google",
"available_history"
],
"data": {
"api": "dataforseo_labs",
"function": "available_history",
"se": "google"
},
"result": [
{
"date": "2022-05-16"
},
{
"date": "2022-06-20"
},
{
"date": "2022-07-18"
}
]
}
]
}状态码与错误处理
建议在业务系统中同时检查以下字段:
- 顶层
status_code - 任务级
tasks[].status_code - 顶层
tasks_error - 任务级
tasks[].status_message
当状态码不为成功状态时,应记录对应的 status_message,并根据业务需要执行重试、告警或降级处理。完整错误码请参考本平台错误码文档。
实用场景
- 获取可用历史日期:在调用分类域名指标接口前校验日期范围,因使用不支持的日期导致请求失败。
- 构建日期选择器:将接口返回的日期列表生成前端可选项,帮助运营人员选择有效的历史对比周期。
- 执行历史趋势分析:使用可用日期查询不同时间点的域名指标,评估网站在各分类中的长期表现变化。
- 校验批量任务参数:在批量生成域名分析任务前统一检查
first_date和second_date,减少无效任务和重复调用。 - 制定 SEO 数据回溯计划:根据平台提供的历史日期范围安排竞品、行业及域名增长趋势分析。