メインコンテンツへスキップ

このドキュメントについて

AI コード指標AI コード追跡 を扱います。API キーを取得共通仕様 を参照してください。

前提

  • 組織に紐づく有効な API キー。
詳細な表と本文は 中国語 です。パス・メソッド・JSON キーはそのまま利用できます。完全にローカライズするには 中文 を選択してください。

概述

AI 代码指标 API 提供组织级别的 AI 辅助编码统计数据,包括代码统计概览、每日趋势、成员排名、仓库列表和文件扩展名统计。

主要功能

  • 统计概览: 提交代码中 AI 贡献的总量和占比
  • 每日趋势: 按天查看 AI 代码占比、Agent 代码分语言统计、Tab 补全接受率
  • 成员排名: 按 AI 代码贡献量排名成员
  • 仓库列表: 列出有 AI 代码活动的仓库
  • 文件扩展名: 按文件类型统计 AI 代码指标
  • 提交详情: 获取提交级别的 AI 代码归因详情(文件级行范围注解)

通用查询参数

以下参数适用于所有 AI Code 接口(各接口的必填性见具体说明):
参数类型说明
start_datestring开始时间,支持 RFC 3339 格式或 Unix 毫秒时间戳
end_datestring结束时间,支持 RFC 3339 格式或 Unix 毫秒时间戳
repo_namestring按仓库名称过滤
primary_branch_onlystring设为 true 仅统计主分支
user_idstring按用户 ID 过滤
file_extensionsstring按文件扩展名过滤,逗号分隔(如 .go,.ts

API 列表

1. 获取 AI 代码统计概览

GET /v1/organizations/{organization_id}/ai-code/stats/overview 获取组织 AI 代码的整体统计数据。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,其中:
参数必填说明
start_date开始时间
end_date结束时间
start_dateend_date 均为必填,且时间范围不超过 90 天。

成功响应 (200 OK)

{
  "committedTotalLinesEdit": 50000,
  "committedAiLinesEdit": 15000,
  "acceptedLinesEdit": 18000,
  "aiShareRate": 30.0,
  "agentEditCount": 1200,
  "tabCompletionCount": 5600,
  "messageCount": 3400
}

响应字段说明

字段类型说明
committedTotalLinesEditint64已提交代码总编辑行数(新增 + 删除)
committedAiLinesEditint64已提交代码中 AI 编辑行数(新增 + 删除)
acceptedLinesEditint64已接受的 AI 编辑行数(新增 + 删除)
aiShareRatefloat64AI 代码占比(百分比)
agentEditCountint64Agent 编辑次数
tabCompletionCountint64Tab 补全次数
messageCountint64对话消息数

2. 获取 AI 代码每日趋势

GET /v1/organizations/{organization_id}/ai-code/stats/daily-trend 获取 AI 代码的每日趋势数据,包含三组数据:AI 代码占比趋势、按语言分布趋势、Tab 补全接受率趋势。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,其中:
参数必填说明
start_date开始时间
end_date结束时间
start_dateend_date 均为必填,且时间范围不超过 90 天。

成功响应 (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 代码占比趋势(Chart 1)
字段类型说明
datestring日期(ISO 8601)
aiLinesAddedint64AI 新增行数
otherLinesAddedint64非 AI 新增行数
aiShareRatefloat64AI 代码占比(百分比)
commitCountint64提交次数
extItems[ ] - Agent 代码按语言分布趋势(Chart 2)
字段类型说明
datestring日期(ISO 8601)
fileExtensionstring文件扩展名
totalLinesAddedint64总新增行数
aiLinesAddedint64AI 新增行数
nextItems[ ] - Tab 补全接受率趋势(Chart 3)
字段类型说明
datestring日期(ISO 8601)
nextSuggestedCountint64建议次数
nextAcceptedCountint64接受次数
nextAcceptRatefloat64接受率(百分比)

3. 获取成员 AI 代码排名

GET /v1/organizations/{organization_id}/ai-code/stats/member-ranking 获取组织成员按 AI 代码贡献量的排名。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,其中:
参数必填说明
start_date开始时间
end_date结束时间
start_dateend_date 均为必填,且时间范围不超过 90 天。
额外支持:
参数类型必填默认值说明
limitinteger10返回的最大成员数

成功响应 (200 OK)

{
  "items": [
    {
      "userId": "user_abc123",
      "email": "zhangsan@example.com",
      "displayName": "张三",
      "totalLinesAdded": 5000,
      "aiLinesAdded": 2000,
      "aiShareRate": 40.0,
      "commitCount": 50
    }
  ]
}

响应字段说明

字段类型说明
itemsarray成员排名列表
items[].userIdstring用户 ID
items[].emailstring成员邮箱(可能为空)
items[].displayNamestring成员显示名(可能为空)
items[].totalLinesAddedint64总新增行数
items[].aiLinesAddedint64AI 新增行数
items[].aiShareRatefloat64AI 代码占比(百分比)
items[].commitCountint64提交次数

4. 列出仓库

GET /v1/organizations/{organization_id}/ai-code/repos 列出组织中有 AI 代码活动的仓库。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

参数类型必填默认值说明
start_datestring开始时间
end_datestring结束时间
querystring按仓库名称搜索
pageinteger1页码(从 1 开始)
per_pageinteger30每页条数,最大 100

成功响应 (200 OK)

{
  "repos": [
    {
      "repoName": "my-project",
      "commitCount": 120,
      "totalLinesAdded": 8000
    }
  ],
  "totalCount": 42,
  "page": 1,
  "perPage": 30
}

响应字段说明

字段类型说明
reposarray仓库列表
repos[].repoNamestring仓库名称
repos[].commitCountint64提交次数
repos[].totalLinesAddedint64总新增行数
totalCountint32总仓库数
pageint32当前页码perPageint32每页条数

5. 列出文件扩展名

GET /v1/organizations/{organization_id}/ai-code/file-extensions 列出组织中有 AI 代码活动的文件扩展名统计。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

参数类型必填说明
start_datestring开始时间
end_datestring结束时间

成功响应 (200 OK)

{
  "fileExtensions": [
    {
      "extension": ".go",
      "changeCount": 500,
      "totalLinesAdded": 12000,
      "aiShareRate": 35.5
    }
  ]
}

响应字段说明

字段类型说明
fileExtensionsarray文件扩展名列表
fileExtensions[].extensionstring文件扩展名
fileExtensions[].changeCountint64变更次数
fileExtensions[].totalLinesAddedint64总新增行数
fileExtensions[].aiShareRatefloat64AI 代码占比(百分比)

6. 获取提交 AI 归因详情

POST /v1/organizations/{organization_id}/ai-code-tracking/commits/detail 批量获取提交级别的 AI 代码归因详情,包含文件级的行范围注解。

路径参数

参数类型必填说明
organization_idstring组织 ID

请求体 (JSON)

字段类型必填说明
commitHashes
  • [] | 是 | 提交哈希列表(最多 50 个) |
| branch | string | 否 | 分支名称(用于限定查询范围) |

请求示例

{
  "commitHashes": ["abc123def456", "789ghi012jkl"],
  "branch": "main"
}

成功响应 (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 }
                ]
              }
            ]
          }
        ]
      },
      {
        "commitHash": "789ghi012jkl",

        "rangeAnnotations": []

      }
    ]
  }
}

响应字段说明

字段类型说明
successboolean请求是否成功
data.commitsarray提交详情列表(保持请求顺序)
data.commits[].commitHashstring提交哈希
data.commits[].rangeAnnotationsarray文件级 AI 归因注解
data.commits[].rangeAnnotations[].filePathstring文件路径
data.commits[].rangeAnnotations[].groupsarrayAI 会话贡献分组
data.commits[].rangeAnnotations[].groups[].conversationIdstringAI 会话 ID
data.commits[].rangeAnnotations[].groups[].sourcestring来源:AGENTNEXTQUESTINLINECHAT
data.commits[].rangeAnnotations[].groups[].productTypestring产品类型(小写,如 ide
data.commits[].rangeAnnotations[].groups[].typestring类型:added(新增)、deleted(删除)
data.commits[].rangeAnnotations[].groups[].rangesarray行范围列表
data.commits[].rangeAnnotations[].groups[].ranges[].startint32起始行号
data.commits[].rangeAnnotations[].groups[].ranges[].endint32结束行号

使用示例

获取统计概览

curl -X GET "https://api.qoder.com/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/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>"

获取成员排名(前 20)

curl -X GET "https://api.qoder.com/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/v1/organizations/org_xxx/ai-code/repos?query=my-project" \
  -H "Authorization: Bearer <api_key>"

获取文件扩展名统计

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code/file-extensions?start_date=2025-06-01T00:00:00Z" \
  -H "Authorization: Bearer <api_key>"

获取提交 AI 归因详情

curl -X POST "https://api.qoder.com/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"}'

错误码

错误码HTTP 状态码说明
BadRequest400请求参数无效(如 start_date / end_date 缺失、时间范围超过 90 天、commitHashes 为空或超过 50)
Unauthorized401API Key 缺失或无效
Forbidden403无权限访问该组织
InternalError500服务器内部错误
Error response shape: see Error responses in Conventions.

AI 代码追踪 API

AI 代码指标(聚合统计)之外,本节提供 Commit / Change 级别的明细查询与 CSV 导出。鉴权方式与上文相同:Authorization: Bearer <api_key> 使用前请确认组织已开通与控制台一致的 AI 代码数据分析 能力;若未开通或无权访问,接口可能返回 403 等错误,以实际响应为准。字段与枚举以线上接口与 OpenAPI 定义为准,本文仅作说明。

追踪能力说明

AI 代码追踪 API 提供 commit 级别和 change 级别的逐条明细查询与 CSV 导出能力,是对上文 AI 代码指标(聚合统计)的补充。

两层数据模型

层级含义来源可用过滤维度
CommitGit 提交代码仓库(已推送到远程)时间、用户、仓库
ChangeIDE 内的 AI 代码编辑事件来自 IDE 客户端的上报(尚未形成 Git 提交)时间、用户、source
Change 是尚未 git commit 的 IDE 内事件,因此不具有 repoName / branchName 维度。

产品 x 场景交叉分解(Commit 级别)

每条 commit 记录包含 12 对 linesAdded / linesDeleted 列,按「产品 x 场景」交叉拆解 AI 代码行:
字段前缀产品场景
ideNextIDE (VS Code)Tab 补全 (next)
pluginNextJetBrains 插件Tab 补全 (next)
ideAgentIDE (VS Code)Agent
pluginAgentJetBrains 插件Agent
cliAgentCLIAgent
ideQuestIDE (VS Code)Quest
ideInlineChatIDE (VS Code)Inline Chat
jbInlineChatJetBrains 插件Inline Chat
nonAi无法归类的非 AI 行

主要功能

  • Commit 明细查询: 逐条列出提交级 AI 代码统计(含产品 x 场景拆解)
  • Commit CSV 导出: 流式导出全部 commit 数据
  • Change 明细查询: 逐条列出 IDE 内 AI 代码编辑事件(支持按 source 过滤)
  • Change CSV 导出: 流式导出全部 change 数据
  • 用户邮箱: 列表与导出中会尽量填充 userEmail(若数据中存在)
  • 按邮箱筛选: 支持通过 userEmail 查询参数定位用户

分页方式

Tracking API 使用偏移量分页page + pageSize),不同于其他接口常用的游标分页。响应包含 totalItems / totalPages,便于分页展示。

通用查询参数

以下参数适用于所有 Tracking 接口:
参数类型必填默认值说明
startDatestring开始时间,支持 RFC 3339 格式或 Unix 毫秒时间戳。未传时由服务端按产品策略约束可查范围(例如最长约 90 天),以实际行为为准
endDatestring当前时间结束时间,支持 RFC 3339 格式或 Unix 毫秒时间戳
userIdstring按用户 UUID 过滤
userEmailstring按用户邮箱过滤(服务端会解析为对应的用户标识)
pageinteger1页码(从 1 开始)
pageSizeinteger100每页条数,最大 200
userIduserEmail 同时提供时,userId 优先。

API 列表

1. 列出 Commit 明细

GET /v1/organizations/{organization_id}/ai-code-tracking/commits 逐条列出提交级 AI 代码统计数据,按提交时间倒序排列。每条记录包含产品 x 场景的交叉拆解。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,额外支持:
参数类型必填说明
repoNamestring按仓库名称过滤

成功响应 (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,
        "pluginNextLinesAdded": 0,
        "pluginNextLinesDeleted": 0,
        "ideAgentLinesAdded": 50,
        "ideAgentLinesDeleted": 15,
        "pluginAgentLinesAdded": 0,
        "pluginAgentLinesDeleted": 0,
        "cliAgentLinesAdded": 0,
        "cliAgentLinesDeleted": 0,
        "ideQuestLinesAdded": 10,
        "ideQuestLinesDeleted": 0,
        "ideInlineChatLinesAdded": 5,
        "ideInlineChatLinesDeleted": 2,
        "jbInlineChatLinesAdded": 0,
        "jbInlineChatLinesDeleted": 0,
        "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
    }
  }
}

响应字段说明

success - true 表示请求成功 data.items[ ] - Commit 明细列表
字段类型说明
commitHashstringGit commit SHA
userIdstring用户 UUID
userEmailstring用户邮箱(可能为空)
repoNamestring仓库名称
branchNamestring分支名称
isPrimaryBranchboolean是否为主分支
totalLinesAddedinteger总新增行数
totalLinesDeletedinteger总删除行数
ideNextLinesAddedintegerIDE Tab 补全新增行数
ideNextLinesDeletedintegerIDE Tab 补全删除行数
pluginNextLinesAddedintegerJetBrains 插件 Tab 补全新增行数
pluginNextLinesDeletedintegerJetBrains 插件 Tab 补全删除行数
ideAgentLinesAddedintegerIDE Agent 新增行数
ideAgentLinesDeletedintegerIDE Agent 删除行数
pluginAgentLinesAddedintegerJetBrains 插件 Agent 新增行数
pluginAgentLinesDeletedintegerJetBrains 插件 Agent 删除行数
cliAgentLinesAddedintegerCLI Agent 新增行数
cliAgentLinesDeletedintegerCLI Agent 删除行数
ideQuestLinesAddedintegerIDE Quest 新增行数
ideQuestLinesDeletedintegerIDE Quest 删除行数
ideInlineChatLinesAddedintegerIDE Inline Chat 新增行数
ideInlineChatLinesDeletedintegerIDE Inline Chat 删除行数
jbInlineChatLinesAddedintegerJetBrains Inline Chat 新增行数
jbInlineChatLinesDeletedintegerJetBrains Inline Chat 删除行数
nonAiLinesAddedinteger非 AI 新增行数
nonAiLinesDeletedinteger非 AI 删除行数
messagestring提交信息(可能为空)
commitTsstring提交时间(ISO 8601)
createdAtstring记录创建时间(ISO 8601)
data.pagination - 分页信息
字段类型说明
currentPageinteger当前页码
pageSizeinteger每页条数
totalItemsinteger总记录数
totalPagesinteger总页数

2. 导出 Commit CSV

GET /v1/organizations/{organization_id}/ai-code-tracking/commits/export 以流式 CSV 格式导出 commit 数据。导出过程由服务端自动完成分页聚合,调用方无需自行翻页

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,额外支持:
参数类型必填说明
repoNamestring按仓库名称过滤

成功响应 (200 OK)

  • Content-Type: text/csv; charset=utf-8
  • Content-Disposition: attachment; filename="ai-code-commits.csv"
CSV 列头(注意 CSV 保留 userName,JSON 响应中已移除):
commitHash,userId,userEmail,userName,repoName,branchName,isPrimaryBranch,
totalLinesAdded,totalLinesDeleted,
ideNextLinesAdded,ideNextLinesDeleted,pluginNextLinesAdded,pluginNextLinesDeleted,
ideAgentLinesAdded,ideAgentLinesDeleted,pluginAgentLinesAdded,pluginAgentLinesDeleted,
cliAgentLinesAdded,cliAgentLinesDeleted,ideQuestLinesAdded,ideQuestLinesDeleted,
ideInlineChatLinesAdded,ideInlineChatLinesDeleted,jbInlineChatLinesAdded,jbInlineChatLinesDeleted,
nonAiLinesAdded,nonAiLinesDeleted,message,commitTs,createdAt

3. 列出 Change 明细

GET /v1/organizations/{organization_id}/ai-code-tracking/changes 逐条列出 IDE 内 AI 代码编辑事件(仅 action=suggested 的记录),按事件时间倒序排列。
Change 是尚未 git commit 的 IDE 内事件,因此不支持 repoName 过滤。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,额外支持:
参数类型必填说明
sourcestring按使用场景过滤,可选值:AGENTNEXTQUESTINLINECHAT

成功响应 (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
          },
          {
            "fileName": "utils.go",
            "fileExtension": ".go",
            "linesAdded": 15,
            "linesDeleted": 4
          }
        ],
        "createdAt": "2025-06-15T10:28:00Z"
      }
    ],
    "pagination": {
      "currentPage": 1,
      "pageSize": 100,
      "totalItems": 1024,
      "totalPages": 11
    }
  }
}

响应字段说明

success - true 表示请求成功 data.items[ ] - Change 明细列表
字段类型说明
changeIdstring变更事件唯一标识
userIdstring用户 UUID
userEmailstring用户邮箱(可能为空)
sourcestring使用场景(大写):NEXTAGENTQUESTINLINECHAT
modelstring模型级别:liteefficientauto(可能为空)
totalLinesAddedinteger总新增行数
totalLinesDeletedinteger总删除行数
metadataarray文件级别变更明细(可能为空)
metadata[].fileNamestring文件名
metadata[].fileExtensionstring文件扩展名
metadata[].linesAddedinteger文件新增行数
metadata[].linesDeletedinteger文件删除行数
createdAtstring事件时间(ISO 8601)
data.pagination - 分页信息
字段类型说明
currentPageinteger当前页码
pageSizeinteger每页条数
totalItemsinteger总记录数
totalPagesinteger总页数

4. 导出 Change CSV

GET /v1/organizations/{organization_id}/ai-code-tracking/changes/export 以流式 CSV 格式导出 change 数据。导出过程由服务端自动完成分页聚合,调用方无需自行翻页
CSV 导出为扁平格式,不包含 metadata(文件级明细)。

路径参数

参数类型必填说明
organization_idstring组织 ID

查询参数

见「通用查询参数」,额外支持:
参数类型必填说明
sourcestring按使用场景过滤,可选值:AGENTNEXTQUESTINLINECHAT

成功响应 (200 OK)

  • Content-Type: text/csv; charset=utf-8
  • Content-Disposition: attachment; filename="ai-code-changes.csv"
CSV 列头:
changeId,userId,userEmail,source,model,totalLinesAdded,totalLinesDeleted,createdAt

使用示例

查询 commit 明细(按仓库过滤)

curl -X GET "https://api.qoder.com/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

curl -X GET "https://api.qoder.com/v1/organizations/org_xxx/ai-code-tracking/commits?startDate=2025-06-01T00:00:00Z&userEmail=zhangsan@example.com" \
  -H "Authorization: Bearer <api_key>"

导出 commit CSV

curl -X GET "https://api.qoder.com/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 明细(按 source 过滤)

curl -X GET "https://api.qoder.com/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/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 状态码说明
Unauthorized401API Key 缺失或无效
Forbidden403无权限访问该组织
BadRequest400请求参数无效(如 organization_id / userId 不是合法 UUID)
InternalError500服务器内部错误
Error response shape: see Error responses in Conventions.