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

获取指定时间范围内，企业整体的 AI 使用数据。
## 所需权限 {#8b842c37}
`statistics`
## 请求方式 {#87e36d3a}
```HTTP
GET /openapi/v1/statistics/core-metrics
```

## 请求参数  {#6e7f87d1}
<!-- @cols-width: 183,151,100,143,297 -->
| | | | | | \
|**参数** |**类型** |**是否必填** |**默认值** |**描述** |
|---|---|---|---|---|
| | | | | | \
|`start_date` |string |是 |\- |开始日期。格式：YYYY-MM-DD。 |
| | | | | | \
|`end_date` |string |是 |\- |结束日期。格式：YYYY-MM-DD。 |
| | | | | | \
|`timezone` |string |否 |`"Asia/Shanghai"` |时区。需使用 IANA 时区名称。 |

## 响应参数 {#e8918474}
<!-- @cols-width: 176,148,503 -->
| | | | \
|**参数** |**类型** |**描述** |
|---|---|---|
| | | | \
|`metrics` |object |时间范围内的整体汇总数据。 |
| | | | \
|`daily_trend` |array |按天拆分的趋势数据。 |

`metrics` 对象和 `daily_trend` 数组包含的参数如下：
<!-- @cols-width: 244,183,434 -->
| | | | \
|**参数** |**类型** |**描述** |
|---|---|---|
| | | | \
|`date` |string |日期。格式：YYYY-MM-DD。该参数为 `daily_trend` 部分独有。 |
| | | | \
|`ai_generation_rate` |float64 |AI 生成代码在总代码产出中的占比（%）。 |
| | | | \
|`ai_contribution_rate` |float64 |AI 代码贡献率（%），表示最终提交到仓库的代码中，有多少来自 AI。 |
| | | | \
|`ai_generated_code_lines` |int64 |在对话和自动补全中，AI 生成的代码总行数。 |
| | | | \
|`chat_code_gen_lines` |int64 |在对话中，AI 生成的总代码行数。 |
| | | | \
|`chat_code_accept_lines` |int64 |在对话中，AI 生成的代码被采纳的总行数。 |
| | | | \
|`cue_recommend_count` |int64 |CUE 提供代码建议的总次数。 |
| | | | \
|`cue_recommend_accepted` |int64 |CUE 提供的代码建议被采纳的总次数。 |
| | | | \
|`ai_commit_lines` |int64 |AI 生成的代码被提交到仓库的总行数。 |
| | | | \
|`non_ai_commit_lines` |int64 |非 AI 生成的代码被提交到仓库的总行数。 |
| | | | \
|`total_commit_lines` |int64 |提交到仓库的总代码行数。 |

## 请求示例 {#c16fdbbc}
```Bash
curl -X GET "https://{domain}/openapi/v1/statistics/core-metrics?start_date=2026-01-01&end_date=2026-01-31" \
  -H "Authorization: Bearer {access_token}"
```

## 响应示例 {#4638c3c5}
```JSON
{
  "code": 0,
  "message": "success",
  "request_id": "req_abc123xyz",
  "data": {
    "metrics": {
      "ai_generation_rate": 35.5,
      "ai_contribution_rate": 22.0,
      "ai_generated_code_lines": 120000,
      "chat_code_gen_lines": 500,
      "chat_code_accept_lines": 350,
      "cue_recommend_count": 50000,
      "cue_recommend_accepted": 150,
      "ai_commit_lines": 10000,
      "non_ai_commit_lines": 10000,
      "total_commit_lines": 30000
    },
    "daily_trend": [
      {
        "date": "2026-01-15",
        "ai_generation_rate": 30.5,
        "ai_contribution_rate": 21.2,
        "ai_generated_code_lines": 30000,
        "chat_code_gen_lines": 200,
        "chat_code_accept_lines": 150,
        "cue_recommend_count": 80,
        "cue_recommend_accepted": 70,
        "ai_commit_lines": 2000,
        "non_ai_commit_lines": 2000,
        "total_commit_lines": 6000
      }
    ]
  }
}
```


