> ## Documentation Index
> Fetch the complete documentation index at: https://www.bazhuayu.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 查询任务采集与执行分析

> **所需套餐：** 旗舰版、旗舰+、企业版

## 端点

```
POST https://openapi.bazhuayu.com/taskanalytics/queries
```

## 描述

按日/周/月粒度查询任务采集量、执行次数、成功率及资源消耗等指标。时间范围为 UTC 自然日，仅支持查询最近 3 个月内数据。

未传 `memberNames` 或传空数组时，仅查询当前登录用户；传入成员名称时须为当前用户团队成员。

选填字段未填写时应为空值（如 `""`、`[]`、`null`），不要使用 `<string>`、`123` 等自动生成的占位值。

## 请求头

| 参数              | 类型     | 必填 | 说明               |
| --------------- | ------ | -- | ---------------- |
| `Authorization` | String | 是  | 身份令牌             |
| `Content-Type`  | String | 是  | application/json |

**请求头示例**

```json theme={null}
{
  "Authorization": "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImdXS3hWc0F4SHhaMDlDcWh6NkNJb3ciLCJ0eXAiOiJhdCtqd3QifQ.eyJuYmYiOjE2MzY0NjIyNzAsImV4cCI6MTYzNjU0ODY2OSwiaXNzIjoiaHR0cDovL3Rlc3QuaWRlbnRpdHkuYmF6aHVheXUuY29tIiwiY2xpZW50X2lkIjoiT2N0b3B1cyIsInN1YiI6IjllOGJiM2VhLWUwMWQtNGFlZC05ODM3LTVhMWUyODg0NWI5ZSIsImF1dGhfdGltZSI6MTYzNjQ2MjI3MCwiaWRwIjoibG9jYWwiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjllOGJiM2VhLWUwMWQtNGFlZC05ODM3LTVhMWUyODg0NWI5ZSIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJ0ZXN0d2VuIiwicHJlZmVycmVkX3VzZXJuYW1lIjoidGVzdHdlbiIsInVuaXF1ZV9uYW1lIjoidGVzdHdlbiIsInJlZ2lzdGVyX2RhdGUiOiIxMS8wNC8yMDE2IDA4OjM4OjE2ICswODowMCIsImxhc3RfbG9naW5fZGF0ZSI6IjA0LzIyLzIwMTkgMDk6MDE6MDIgKzA4OjAwIiwibGFzdF9wYXNzd29yZF9jaGFuZ2VkX2RhdGUiOiIwMS8yMy8yMDE5IDA4OjMwOjMxICswODowMCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6IndlbmRpQHNraWVlci5jb20iLCJlbWFpbCI6IndlbmRpQHNraWVlci5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwic2NvcGUiOlsiZW1haWwiLCJvcGVuaWQiLCJyb2xlcyIsIm9mZmxpbmVfYWNjZXNzIl0sImFtciI6WyJwd2QiXX0.ARhbBfzI1xS6yo-Ue1CFHzMaUIfzw4gJlubNBOkUT4SSTlhuS4bVQ4t4UHuYGbE9VX6XgNVgkcDnx6XapqcPohSy7vPv9TIAsjtbrQSA3mj13SnVVAPWwfAVJ-I7g9HDnyPEEOVSvmZUJhiz-irH5L0ojbnt3ck2rQ9tIFuSd7j2eh5BS4ItjNoHY00rh_QPZltk66a9q-fNE33GrxOaXUdHH47WMlsENnh1gybB7QtGtd6bZ982Qa9JljpFnZWSdEf4VfkN4JmhkUTTC908DqS3stT-LD-9tpztFwB54sd0D4CyOBnESkKrUwjxchYYZo4l1O7auiZVGV48YhZYMw",
  "Content-Type": "application/json"
}
```

## 请求体

| 参数                 | 类型        | 必填 | 说明                                                    |
| ------------------ | --------- | -- | ----------------------------------------------------- |
| `start`            | String    | 是  | 查询开始日期（含），格式 `yyyy-MM-dd`，如 `2026-02-01`              |
| `end`              | String    | 是  | 查询结束日期（含），格式 `yyyy-MM-dd`；不得晚于当前 UTC 日期，且不能早于 `start` |
| `page`             | Number    | 选填 | 页码，≥1，默认 `1`                                          |
| `pageSize`         | Number    | 选填 | 每页条数，1～500，默认 `20`                                    |
| `taskIds`          | String\[] | 选填 | 任务 Id 列表，最多 100 个；不传表示不过滤任务                           |
| `memberNames`      | String\[] | 选填 | 团队成员名称，最多 100 个；不传或空数组表示仅查当前用户                        |
| `collectionMethod` | String    | 选填 | 采集方式：`Cloud` / `Local` / `All`；不传或 `All` 表示不过滤        |
| `timeGranularity`  | String    | 选填 | 时间粒度：`Day` / `Week` / `Month`，默认 `Day`                |

**请求体示例（仅必填参数）**

```json theme={null}
{
  "start": "2026-02-01",
  "end": "2026-04-01"
}
```

**请求体示例（含选填参数）**

```json theme={null}
{
  "start": "2026-02-01",
  "end": "2026-04-01",
  "page": 1,
  "pageSize": 20,
  "timeGranularity": "Week",
  "collectionMethod": "All",
  "taskIds": [
    "task-id-1"
  ],
  "memberNames": []
}
```

## 响应

| 参数                      | 类型        | 必填 | 说明                                            |
| ----------------------- | --------- | -- | --------------------------------------------- |
| `data`                  | Object    | 是  | 响应数据                                          |
| `total`                 | Number    | 是  | 符合条件的总记录数（用于分页）                               |
| `data`                  | Object\[] | 是  | 当前页数据列表                                       |
| `taskId`                | String    | 是  | 任务 Id                                         |
| `userId`                | String    | 是  | 用户 Id                                         |
| `taskName`              | String    | 否  | 任务名称（可能为 null）                                |
| `dayKey`                | String    | 是  | 时间分桶键（日：`yyyy-MM-dd`；周：`YYYY-WW`；月：`yyyy-MM`） |
| `weekStartDate`         | String    | 否  | 周开始日期 `yyyy-MM-dd`，仅 Week 粒度有值                |
| `weekEndDate`           | String    | 否  | 周结束日期 `yyyy-MM-dd`，仅 Week 粒度有值                |
| `collectionMethod`      | String    | 是  | 采集方式：`Cloud` / `Local`                        |
| `dataVolumeMetrics`     | Object    | 是  | 数据量指标                                         |
| `totalCollected`        | Number    | 否  | 采集总量；无数据为 null                                |
| `deduplicatedVolume`    | Number    | 否  | 去重后保存量；无数据为 null                              |
| `executionMetrics`      | Object    | 是  | 执行指标                                          |
| `runCount`              | Number    | 否  | 运行次数                                          |
| `successCount`          | Number    | 否  | 成功次数                                          |
| `failureCount`          | Number    | 否  | 失败次数                                          |
| `durationPerRunSeconds` | Number    | 否  | 单次平均耗时（秒）                                     |
| `totalExecutionSeconds` | Number    | 否  | 总耗时（秒）                                        |
| `successRate`           | Number    | 否  | 成功率，0～1                                       |
| `failureRate`           | Number    | 否  | 失败率，0～1                                       |
| `resourceUsageMetrics`  | Object    | 是  | 资源消耗指标                                        |
| `captchaCount`          | Number    | 否  | 验证码次数                                         |
| `simpleTemplateCount`   | Number    | 否  | 简易模板条数                                        |
| `proxyIpCount`          | Number    | 否  | 代理 IP 用量                                      |
| `balance`               | Number    | 否  | 资源消耗金额                                        |
| `requestId`             | String    | 是  | 请求 Id                                         |

**成功示例**

```json theme={null}
{
  "data": {
    "total": 42,
    "data": [
      {
        "taskId": "abc123",
        "userId": "user001",
        "taskName": null,
        "dayKey": "2026-11",
        "weekStartDate": "2026-03-10",
        "weekEndDate": "2026-03-16",
        "collectionMethod": "Cloud",
        "dataVolumeMetrics": {
          "totalCollected": 10000,
          "deduplicatedVolume": 8000
        },
        "executionMetrics": {
          "runCount": 50,
          "successCount": 48,
          "failureCount": 2,
          "durationPerRunSeconds": 12.5,
          "totalExecutionSeconds": 625,
          "successRate": 0.96,
          "failureRate": 0.04
        },
        "resourceUsageMetrics": {
          "captchaCount": 10,
          "simpleTemplateCount": null,
          "proxyIpCount": 1.5,
          "balance": 3.2
        }
      }
    ]
  },
  "requestId": "0HMD469L0I8Q1:00000001"
}
```

## 错误响应

| 参数          | 类型     | 必填 | 说明         |
| ----------- | ------ | -- | ---------- |
| `requestId` | String | 是  | 请求Id       |
| `error`     | Object | 是  | 错误信息，参考错误码 |
| `code`      | String | 是  | 错误码        |
| `message`   | String | 是  | 错误描述       |

**错误示例**

```json theme={null}
{
  "error": {
    "code": "MemberNotAllowed",
    "message": "存在无权查询的成员名称"
  },
  "requestId": "0HMD469L0I8R0:00000001"
}
```

<ParamField header="Authorization" type="string" required hidden />

<ParamField header="Content-Type" type="string" default="application/json" required hidden />


## OpenAPI

````yaml en/api-reference/task-analytics/openapi.json POST /taskanalytics/queries
openapi: 3.0.3
info:
  title: Task Analytics
  version: 1.0.0
servers:
  - url: https://openapi.bazhuayu.com
security: []
paths:
  /taskanalytics/queries:
    post:
      summary: 查询任务采集与执行分析
      operationId: taskAnalyticsQueries
      parameters:
        - name: Authorization
          in: header
          required: true
          description: 身份令牌，格式 Bearer {access_token}
          schema:
            type: string
            example: Bearer <access_token>
        - name: Content-Type
          in: header
          required: true
          description: application/json
          schema:
            type: string
            default: application/json
            example: application/json
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - start
                - end
              properties:
                start:
                  type: string
                  description: 查询开始日期（含），格式 yyyy-MM-dd
                end:
                  type: string
                  description: 查询结束日期（含），格式 yyyy-MM-dd
                page:
                  type: integer
                  description: 页码，≥1，默认 1
                pageSize:
                  type: integer
                  description: 每页条数，1～500，默认 20
                taskIds:
                  type: array
                  items:
                    type: string
                  description: 任务 Id 列表，最多 100 个
                memberNames:
                  type: array
                  items:
                    type: string
                  description: 团队成员名称，最多 100 个
                collectionMethod:
                  type: string
                  description: 采集方式：Cloud / Local / All
                timeGranularity:
                  type: string
                  description: 时间粒度：Day / Week / Month
            example:
              start: ''
              end: ''
              page: null
              pageSize: null
              taskIds: []
              memberNames: []
              collectionMethod: ''
              timeGranularity: ''
      responses:
        '200':
          description: 成功
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            import requests

            url = "https://openapi.bazhuayu.com/taskanalytics/queries"
            headers = {
                "Authorization": "Bearer <access_token>",
                "Content-Type": "application/json",
            }
            payload = {
                "start": "",
                "end": "",
                "page": None,
                "pageSize": None,
                "taskIds": [],
                "memberNames": [],
                "collectionMethod": "",
                "timeGranularity": "",
            }

            response = requests.post(url, json=payload, headers=headers)
            print(response.json())
        - lang: curl
          label: cURL
          source: |-
            curl -X POST "https://openapi.bazhuayu.com/taskanalytics/queries" \
              -H "Authorization: Bearer <access_token>" \
              -H "Content-Type: application/json" \
              -d '{"start":"","end":"","page":null,"pageSize":null,"taskIds":[],"memberNames":[],"collectionMethod":"","timeGranularity":""}'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 身份令牌

````