> ## 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.

# App 运行统计

> 作者自检用的单 App 汇总指标：运行量、成功率、最近运行、近 30 天计费。

## 端点

```
GET https://api-datahub.bazhuayu.com/v1/data-apps/{app_id}/stats
```

认证：需要 API Key，且仅 App 作者（发布者本人）可调用；其他人得到 `404`。

单个 App 的汇总指标（运行量、成功率、最近一次运行等），仅作者可读。零 Release 的 App 也能查（调试期间已有测试流量）。数据来自终态时累加的日桶，秒级新鲜。作者调试运行默认排除，`include_test=true` 并入。窗口内没有终态运行的指标为 `null` 而不是 0。

## 请求

### 路径参数

<ParamField path="app_id" type="string" required>
  App 引用。
</ParamField>

### 查询参数

<ParamField query="include_test" type="boolean" default="False">
  是否把作者调试运行并入统计。
</ParamField>

### 示例请求

```bash theme={null}
curl \
  -H "Authorization: Bearer $BAZHUAYU_API_KEY" \
  "https://api-datahub.bazhuayu.com/v1/data-apps/carol/reviews-query/stats"
```

## 响应

### 200 成功

```json theme={null}
{
  "data": {
    "namespace": "carol",
    "app_name": "probe-b",
    "total_runs": 2,
    "last_run_at": "2026-09-15T07:45:42.326823+00:00",
    "runs_30d": 2,
    "success_rate_30d": 1.0,
    "runs_7d": 2,
    "success_rate_7d": 1.0,
    "calls_7d": [
      0,
      0,
      "…"
    ],
    "avg_duration_ms_30d": 422,
    "credits_30d": 0.04
  }
}
```

响应包在 `data` 字段中，其内容如下。

<ResponseField name="namespace" type="string">
  发布者用户名。
</ResponseField>

<ResponseField name="app_name" type="string" required>
  应用名。
</ResponseField>

<ResponseField name="total_runs" type="integer" required>
  累计运行数。
</ResponseField>

<ResponseField name="last_run_at" type="string">
  最近一次运行时间。
</ResponseField>

<ResponseField name="runs_30d" type="integer" required>
  近 30 天运行数。
</ResponseField>

<ResponseField name="success_rate_30d" type="number">
  近 30 天成功率。
</ResponseField>

<ResponseField name="runs_7d" type="integer">
  近 7 天运行数。
</ResponseField>

<ResponseField name="success_rate_7d" type="number">
  近 7 天成功率。
</ResponseField>

<ResponseField name="calls_7d" type="integer[]" required>
  近 7 天逐日运行数，旧到新，含当天。
</ResponseField>

<ResponseField name="avg_duration_ms_30d" type="integer">
  近 30 天平均执行毫秒数。
</ResponseField>

<ResponseField name="credits_30d" type="number">
  近 30 天计费合计。字段名是历史包袱，币种以 `GET /v1/meta` 为准。
</ResponseField>

### 错误

| HTTP | `code` | `category` | 说明 |
| - | - | - | - |
| 401 | `unauthorized` | `forbidden` | 缺少或无效的 API Key。 |
| 404 | `app-not-found` | `not_found` | App 不存在、已改名，或对当前凭证不可见（私有 / 分享范围之外）。 |

错误响应统一为 `{"error": {code, category, message, retryable}}`，见<a href="/docs/zh/datahub/api/reference/introduction#错误" target="_blank" rel="noopener noreferrer">错误</a>。

## 客户端库

Python 与 JavaScript SDK 暂未封装此端点，请直接调用 REST。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.