AI 代码统计、成员排名、仓库与扩展名、提交归因及 Commit/Change 明细与导出。
文档说明
本文包含两类接口:AI 代码指标(聚合统计、排名、仓库与扩展名等)与 AI 代码追踪(Commit / Change 明细与 CSV 导出)。二者分页方式不同,请注意各节说明。调用前请完成 获取 API Key,并阅读 约定与规范。
权限要求
使用有效的 API Key(
Authorization: Bearer)。API Key 必须关联到目标组织。
概述
AI 代码指标 API 提供组织级别的 AI 辅助编码统计数据,包括代码统计概览、每日趋势、成员排名、仓库列表和文件扩展名统计。
主要功能
统计概览: 提交代码中 AI 贡献的总量和占比
每日趋势: 按天查看 AI 代码占比、Agent 代码分语言统计、Tab 补全接受率
成员排名: 按 AI 代码贡献量排名成员
仓库列表: 列出有 AI 代码活动的仓库
文件扩展名: 按文件类型统计 AI 代码指标
提交详情: 获取提交级别的 AI 代码归因详情(文件级行范围注解)
通用查询参数
以下参数适用于所有 AI Code 接口(各接口的必填性见具体说明):
参数 | 类型 | 说明 |
| string | 开始时间,支持 RFC 3339 格式或 Unix 毫秒时间戳 |
| string | 结束时间,支持 RFC 3339 格式或 Unix 毫秒时间戳 |
| string | 按仓库名称过滤 |
| string | 设为 |
| string | 按用户 ID 过滤 |
| string | 按文件扩展名过滤,逗号分隔(如 |
API 列表
1. 获取 AI 代码统计概览
GET /v1/organizations/{organization_id}/ai-code/stats/overview
获取组织 AI 代码的整体统计数据。start_date 和 end_date 均为必填,且时间范围不超过 90 天。
成功响应 (200 OK)
{
"committedTotalLinesEdit": 50000,
"committedAiLinesEdit": 15000,
"acceptedLinesEdit": 18000,
"aiShareRate": 30.0,
"agentEditCount": 1200,
"tabCompletionCount": 5600,
"messageCount": 3400
}响应字段说明
字段 | 类型 | 说明 |
| int64 | 已提交代码总编辑行数(新增 + 删除) |
| int64 | 已提交代码中 AI 编辑行数 |
| int64 | 已接受的 AI 编辑行数 |
| float64 | AI 代码占比(百分比) |
| int64 | Agent 编辑次数 |
| int64 | Tab 补全次数 |
| int64 | 对话消息数 |
2. 获取 AI 代码每日趋势
GET /v1/organizations/{organization_id}/ai-code/stats/daily-trend
获取 AI 代码的每日趋势数据,包含三组数据:AI 代码占比趋势、按语言分布趋势、Tab 补全接受率趋势。
成功响应 (200 OK)
{
"items": [
{
"date": "2025-06-01T00:00:00Z",
"aiLinesAdded": 500,
"otherLinesAdded": 1500,
"aiShareRate": 25.0,
"commitCount": 30
}
],
"extItems": [
{
"date": "2025-06-01T00:00:00Z",
"fileExtension": ".go",
"totalLinesAdded": 800,
"aiLinesAdded": 300
}
],
"nextItems": [
{
"date": "2025-06-01T00:00:00Z",
"nextSuggestedCount": 200,
"nextAcceptedCount": 120,
"nextAcceptRate": 60.0
}
]
}响应字段说明
items[] - AI 代码占比趋势
字段 | 类型 | 说明 |
| string | 日期(ISO 8601) |
| int64 | AI 新增行数 |
| int64 | 非 AI 新增行数 |
| float64 | AI 代码占比(百分比) |
| int64 | 提交次数 |
extItems[] - Agent 代码按语言分布趋势
字段 | 类型 | 说明 |
| string | 文件扩展名 |
| int64 | 总新增行数 |
| int64 | AI 新增行数 |
nextItems[] - Tab 补全接受率趋势
字段 | 类型 | 说明 |
| int64 | 建议次数 |
| int64 | 接受次数 |
| float64 | 接受率(百分比) |
3. 获取成员 AI 代码排名
GET /v1/organizations/{organization_id}/ai-code/stats/member-ranking
获取组织成员按 AI 代码贡献量的排名。额外支持 limit 参数(默认 10)。
成功响应 (200 OK)
{
"items": [
{
"userId": "user_abc123",
"email": "zhangsan@example.com",
"displayName": "张三",
"totalLinesAdded": 5000,
"aiLinesAdded": 2000,
"aiShareRate": 40.0,
"commitCount": 50
}
]
}响应字段说明
字段 | 类型 | 说明 |
| string | 用户 ID |
| string | 成员邮箱(可能为空) |
| string | 成员显示名(可能为空) |
| int64 | 总新增行数 |
| int64 | AI 新增行数 |
| float64 | AI 代码占比(百分比) |
| int64 | 提交次数 |
4. 列出仓库
GET /v1/organizations/{organization_id}/ai-code/repos
列出组织中有 AI 代码活动的仓库。支持 query(按名称搜索)、page(页码,从 1 开始)、per_page(每页条数,最大 100)。
成功响应 (200 OK)
{
"repos": [
{
"repoName": "my-project",
"commitCount": 120,
"totalLinesAdded": 8000
}
],
"totalCount": 42,
"page": 1,
"perPage": 30
}响应字段说明
字段 | 类型 | 说明 |
| string | 仓库名称 |
| int64 | 提交次数 |
| int64 | 总新增行数 |
| int32 | 总仓库数 |
5. 列出文件扩展名
GET /v1/organizations/{organization_id}/ai-code/file-extensions
列出组织中有 AI 代码活动的文件扩展名统计。
成功响应 (200 OK)
{
"fileExtensions": [
{
"extension": ".go",
"changeCount": 500,
"totalLinesAdded": 12000,
"aiShareRate": 35.5
}
]
}响应字段说明
字段 | 类型 | 说明 |
| string | 文件扩展名 |
| int64 | 变更次数 |
| int64 | 总新增行数 |
| float64 | AI 代码占比(百分比) |
6. 获取提交 AI 归因详情
POST /v1/organizations/{organization_id}/ai-code-tracking/commits/detail
批量获取提交级别的 AI 代码归因详情,包含文件级的行范围注解。
请求体 (JSON)
字段 | 类型 | 必填 | 说明 |
| string[] | 是 | 提交哈希列表,最多 50 个 |
| string | 否 | 分支名称(用于限定查询范围) |
成功响应 (200 OK)
{
"success": true,
"data": {
"commits": [
{
"commitHash": "abc123def456",
"rangeAnnotations": [
{
"filePath": "src/main.go",
"groups": [
{
"conversationId": "session-001",
"source": "AGENT",
"productType": "ide",
"type": "added",
"ranges": [
{ "start": 47, "end": 48 },
{ "start": 55, "end": 60 }
]
}
]
}
]
}
]
}
}响应字段说明
字段 | 类型 | 说明 |
| boolean | 请求是否成功 |
| string | 提交哈希 |
| string | 文件路径 |
| string | AI 会话 ID |
| string | 来源: |
| string | 产品类型(如 |
| string | 类型: |
| int32 | 行范围起止行号 |
AI 代码追踪 API
在 AI 代码指标(聚合统计)之外,本节提供 Commit / Change 级别的明细查询与 CSV 导出。鉴权方式与上文相同。
两层数据模型
层级 | 含义 | 来源 | 可用过滤维度 |
Commit | Git 提交 | 代码仓库(已推送到远程) | 时间、用户、仓库 |
Change | IDE 内的 AI 代码编辑事件 | 来自 IDE 客户端的上报 | 时间、用户、source |
Change 是尚未 git commit 的 IDE 内事件,因此不具有 repoName / branchName 维度。
分页方式
Tracking API 使用偏移量分页(page + pageSize),不同于其他接口常用的游标分页。响应包含 totalItems / totalPages。
追踪 API 列表
1. 列出 Commit 明细
GET /v1/organizations/{organization_id}/ai-code-tracking/commits
逐条列出提交级 AI 代码统计数据,按提交时间倒序排列。额外支持 repoName 过滤。
成功响应 (200 OK)
{
"success": true,
"data": {
"items": [
{
"commitHash": "a1b2c3d4e5f6",
"userId": "550e8400-e29b-41d4-a716-446655440000",
"userEmail": "zhangsan@example.com",
"repoName": "my-project",
"branchName": "main",
"isPrimaryBranch": true,
"totalLinesAdded": 120,
"totalLinesDeleted": 30,
"ideNextLinesAdded": 40,
"ideNextLinesDeleted": 10,
"ideAgentLinesAdded": 50,
"ideAgentLinesDeleted": 15,
"nonAiLinesAdded": 15,
"nonAiLinesDeleted": 3,
"message": "feat: add user login",
"commitTs": "2025-06-15T10:30:00Z",
"createdAt": "2025-06-15T10:35:00Z"
}
],
"pagination": {
"currentPage": 1,
"pageSize": 100,
"totalItems": 256,
"totalPages": 3
}
}
}每条 commit 记录包含 12 对 linesAdded / linesDeleted 列,按「产品 x 场景」交叉拆解 AI 代码行,包括:ideNext、pluginNext、ideAgent、pluginAgent、cliAgent、ideQuest、ideInlineChat、jbInlineChat、nonAi。
2. 导出 Commit CSV
GET /v1/organizations/{organization_id}/ai-code-tracking/commits/export
以流式 CSV 格式导出 commit 数据。调用方无需自行翻页。
Content-Type:
text/csv; charset=utf-8Content-Disposition:
attachment; filename="ai-code-commits.csv"
3. 列出 Change 明细
GET /v1/organizations/{organization_id}/ai-code-tracking/changes
逐条列出 IDE 内 AI 代码编辑事件(仅 action=suggested 的记录),按事件时间倒序排列。额外支持 source 过滤(可选值:AGENT、NEXT、QUEST、INLINECHAT)。
成功响应 (200 OK)
{
"success": true,
"data": {
"items": [
{
"changeId": "chg_abc123",
"userId": "550e8400-e29b-41d4-a716-446655440000",
"userEmail": "zhangsan@example.com",
"source": "AGENT",
"model": "efficient",
"totalLinesAdded": 45,
"totalLinesDeleted": 12,
"metadata": [
{
"fileName": "main.go",
"fileExtension": ".go",
"linesAdded": 30,
"linesDeleted": 8
}
],
"createdAt": "2025-06-15T10:28:00Z"
}
],
"pagination": {
"currentPage": 1,
"pageSize": 100,
"totalItems": 1024,
"totalPages": 11
}
}
}响应字段说明
字段 | 类型 | 说明 |
| string | 变更事件唯一标识 |
| string | 用户 UUID |
| string | 用户邮箱(可能为空) |
| string | 使用场景: |
| string | 模型级别(可能为空) |
| integer | 总新增行数 |
| integer | 总删除行数 |
| array | 文件级别变更明细(可能为空) |
| string | 事件时间(ISO 8601) |
4. 导出 Change CSV
GET /v1/organizations/{organization_id}/ai-code-tracking/changes/export
以流式 CSV 格式导出 change 数据。CSV 导出为扁平格式,不包含 metadata。
Content-Type:
text/csv; charset=utf-8Content-Disposition:
attachment; filename="ai-code-changes.csv"
CSV 列头:
changeId,userId,userEmail,source,model,totalLinesAdded,totalLinesDeleted,createdAt使用示例
获取统计概览
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code/stats/overview?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z" \
-H "Authorization: Bearer <api_key>"获取每日趋势
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code/stats/daily-trend?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z&repo_name=my-project&primary_branch_only=true" \
-H "Authorization: Bearer <api_key>"获取成员排名
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code/stats/member-ranking?start_date=2025-06-01T00:00:00Z&end_date=2025-06-30T23:59:59Z&limit=20" \
-H "Authorization: Bearer <api_key>"搜索仓库
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code/repos?query=my-project" \
-H "Authorization: Bearer <api_key>"获取提交 AI 归因详情
curl -X POST "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code-tracking/commits/detail" \
-H "Authorization: Bearer <api_key>" \
-H "Content-Type: application/json" \
-d '{"commitHashes": ["abc123def456", "789ghi012jkl"], "branch": "main"}'查询 commit 明细
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code-tracking/commits?startDate=2025-06-01T00:00:00Z&endDate=2025-06-30T23:59:59Z&repoName=my-project&pageSize=50" \
-H "Authorization: Bearer <api_key>"导出 commit CSV
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code-tracking/commits/export?startDate=2025-06-01T00:00:00Z" \
-H "Authorization: Bearer <api_key>" \
-o ai-code-commits.csv查询 change 明细
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code-tracking/changes?startDate=2025-06-01T00:00:00Z&source=QUEST&pageSize=50" \
-H "Authorization: Bearer <api_key>"导出 change CSV
curl -X GET "https://api.qoder.com.cn/v1/organizations/org_xxx/ai-code-tracking/changes/export?startDate=2025-06-01T00:00:00Z" \
-H "Authorization: Bearer <api_key>" \
-o ai-code-changes.csv错误码
错误码 | HTTP 状态码 | 说明 |
| 400 | 请求参数无效(如 start_date / end_date 缺失、时间范围超过 90 天、commitHashes 为空或超过 50) |
| 401 | API Key 缺失或无效 |
| 403 | 无权限访问该组织 |
| 500 | 服务器内部错误 |
错误响应结构见 约定与规范 中的「错误响应」一节。