You need to enable JavaScript to run this app.
导航
查询标签历史计算结果
最近更新时间:2024.06.30 18:36:02首次发布时间:2024.06.30 18:36:02

请求说明

Path:/openapi/v1/app/{app_id}/tag/{tag_name}/result/history
Method: POST
Content-type: application/json

请求参数

Path-parameters: 参考公共参数即可
Body:

{
    "granularity":"day",
    "type":"past_range",
    "spans":[
        {
            "type":"past",
            "past":{
                "amount":7,
                "unit":"day"
            }
        },
        {
            "type":"past",
            "past":{
                "amount":1,
                "unit":"day"
            }
        }
    ],
    "timezone":"Asia/Shanghai",
    "week_start":1
}

字段含义说明
整个 json 是一个 period 字段,详见开发者指南->数据开放->OpenAPI->查询API->5.2.2periods字段

返回参数

Response:

{
    "code": 200,
    "message": "success",
    "data": {
        "app_id": 164314,
        "tag_name": "tag_testxxxx_wyx",
        "calculate_results": [
            {
                "total": 28762,
                "details": [
                    {
                        "name": "标签值1",
                        "count": 28762,
                        "percent": 1.0,
                        "pdate": "2022-05-05"
                    }
                ],
                "trace_id": "8a23c9b6-0d05-4cee-a1b6-f2977a489581",
                "calculate_date": 1651728069000,
                "timezone": "Asia/Shanghai",
                "tag_status": "success",
                "begin_at": 1651728069000,
                "end_at": 1651728092000,
                "pdate": "2022-05-05",
                "p_date": "2022-05-05"
            }
        ],
        "has_history": true
    },
    "total_execute_time": null
}

字段含义说明
data 返回的是一个 JSON object, 针对关键字段进行说明

Field

Type

Description

app_id

int

应用id

tag_name

string

标签名称

calculate_results

array

查询时间段的计算结果集

calculate_results.total

int

当前分区时间内的数据总行数

calculate_results.details

object

当前分区时间内的数据详情

calculate_results.details.name

string

标签值

calculate_results.details.count

int

属于该标签值的数据行数

calculate_results.details.percent

double

属于该标签值的数据行数在数据总行数的占比

calculate_results.details.pdate

string

冗余字段,同calculate_results.p_date

calculate_results.calculate_date

int

当前分区标签计算开始的时间戳

calculate_results.timezone

string

当前分区的时区

calculate_results.tag_status

string

当前分区的计算状态

calculate_results.begin_at

int

已废弃,当前分区标签计算开始的时间戳

calculate_results.end_at

int

已废弃,当前分区标签计算结束的时间戳

calculate_results.p_date

string

当前分区计算日期(建议使用)

请求示例

bc 为创建的 RangersClient, 其初始化请参考使用说明, 各语言的 SDK 都提供了类似的接口
调用(Python):

method = 'POST'
service_url = '/datatag/openapi/v1/app/164314/tag/tag_testxxxx_wyx/result/history'
body = {
    "granularity":"day",
    "type":"past_range",
    "spans":[
        {
            "type":"past",
            "past":{
                "amount":7,
                "unit":"day"
            }
        },
        {
            "type":"past",
            "past":{
                "amount":1,
                "unit":"day"
            }
        }
    ],
    "timezone":"Asia/Shanghai",
    "week_start":1
}

resp = bc.request(method=method, service_url=service_url, body=body)
print(resp.content.decode('utf-8'))

返回示例

返回结果:

{
    "code": 200,
    "message": "success",
    "data": {
        "app_id": 164314,
        "tag_name": "tag_testxxxx_wyx",
        "calculate_results": [
            {
                "total": 28762,
                "details": [
                    {
                        "name": "标签值1",
                        "count": 28762,
                        "percent": 1.0,
                        "pdate": "2022-05-05"
                    }
                ],
                "trace_id": "8a23c9b6-0d05-4cee-a1b6-f2977a489581",
                "calculate_date": 1651728069000,
                "timezone": "Asia/Shanghai",
                "tag_status": "success",
                "begin_at": 1651728069000,
                "end_at": 1651728092000,
                "pdate": "2022-05-05",
                "p_date": "2022-05-05"
            }
        ],
        "has_history": true
    },
    "total_execute_time": null
}