About this document
AI code metrics (aggregates) and AI code tracking (detail and CSV export). Pagination differs by section. Complete Get API Key first, then read Conventions.Requirements
- Valid API key (
Authorization: Bearer <api_key>) for the organization.
Overview
The AI Code Metrics API provides organization-level AI-assisted coding statistics, including code stats overview, daily trends, member rankings, repository lists, and file extension statistics.Key features
- Stats overview: Total AI contribution and share in committed code
- Daily trends: Daily AI code share, Agent code by language, Tab completion acceptance rate
- Member ranking: Rank members by AI code contribution
- Repository list: List repositories with AI code activity
- File extensions: AI code metrics by file type
- Commit details: Get commit-level AI code attribution details (file-level line range annotations)
Common query parameters
The following parameters apply to all AI Code endpoints (required status varies by endpoint):API list
1. Get AI code stats overview
GET /v1/organizations/{organization_id}/ai-code/stats/overview
Retrieve overall AI code statistics for the organization.
Path parameters
Query parameters
See “Common query parameters”; specifically:Bothstart_dateandend_dateare required; the time range must not exceed 90 days.
Success response (200 OK)
Response fields
2. Get AI code daily trend
GET /v1/organizations/{organization_id}/ai-code/stats/daily-trend
Retrieve daily trend data for AI code, including three datasets: AI code share trend, language distribution trend, and Tab completion acceptance rate trend.
Path parameters
Query parameters
See “Common query parameters”; specifically:Bothstart_dateandend_dateare required; the time range must not exceed 90 days.
Success response (200 OK)
Response fields
items[] — AI code share trend (Chart 1)
extItems[] — Agent code by language trend (Chart 2)
nextItems[] — Tab completion acceptance rate trend (Chart 3)
3. Get member AI code ranking
GET /v1/organizations/{organization_id}/ai-code/stats/member-ranking
Retrieve organization member ranking by AI code contribution.
Path parameters
Query parameters
See “Common query parameters”; specifically:BothAdditionally supported:start_dateandend_dateare required; the time range must not exceed 90 days.
Success response (200 OK)
Response fields
4. List repositories
GET /v1/organizations/{organization_id}/ai-code/repos
List repositories in the organization with AI code activity.
Path parameters
Query parameters
Success response (200 OK)
Response fields
5. List file extensions
GET /v1/organizations/{organization_id}/ai-code/file-extensions
List file extension statistics for AI code activity in the organization.
Path parameters
Query parameters
Success response (200 OK)
Response fields
6. Get commit AI attribution details
POST /v1/organizations/{organization_id}/ai-code-tracking/commits/detail
Batch retrieve commit-level AI code attribution details, including file-level line range annotations.
Path parameters
Request body (JSON)
Request example
Success response (200 OK)
Response fields
Usage examples
Get stats overview
Get daily trend (specific repo, primary branch)
Get member ranking (top 20)
Search repositories
Get file extension statistics
Get commit AI attribution details
Error codes
Error response shape: see Error responses in Conventions.
AI Code Tracking API
Beyond AI code metrics (aggregate stats), this section provides commit / change-level detail queries and CSV export. Authentication is the same:Authorization: Bearer <api_key>.
Before use, confirm that the organization has enabled the AI Code Data Analysis capability consistent with the console; if not enabled or unauthorized, the API may return 403 or similar errors—refer to the actual response. Fields and enums are based on the live API and OpenAPI definition; this document is for reference only.
Tracking capabilities
The AI Code Tracking API provides commit-level and change-level per-record detail queries and CSV export capabilities, supplementing the AI Code Metrics (aggregate stats) above.Two-layer data model
Changes are IDE events not yet committed to Git, so they do not haverepoName/branchNamedimensions.
Product × scenario breakdown (commit level)
Each commit record contains 12 pairs oflinesAdded / linesDeleted columns, broken down by “product × scenario”:
Key features
- Commit detail query: List commit-level AI code statistics (with product × scenario breakdown)
- Commit CSV export: Stream export all commit data
-
Change detail query: List IDE AI code edit events (filterable by
source) - Change CSV export: Stream export all change data
-
User email: Lists and exports populate
userEmailwhere available -
Filter by email: Supports
userEmailquery parameter to locate users
Pagination
The Tracking API uses offset-based pagination (page + pageSize), unlike the cursor-based pagination used by other endpoints. Responses include totalItems / totalPages for pagination display.
Common query parameters
The following parameters apply to all Tracking endpoints:When bothuserIdanduserEmailare provided,userIdtakes precedence.
API list
1. List commit details
GET /v1/organizations/{organization_id}/ai-code-tracking/commits
List commit-level AI code statistics per record, ordered by commit time descending. Each record includes the product × scenario breakdown.
Path parameters
Query parameters
See “Common query parameters”; additionally:Success response (200 OK)
Response fields
success —true indicates the request succeeded
data.items[] — Commit detail list
data.pagination — Pagination info
2. Export commit CSV
GET /v1/organizations/{organization_id}/ai-code-tracking/commits/export
Export commit data in streaming CSV format. The server automatically handles pagination aggregation—callers do not need to paginate manually.
Path parameters
Query parameters
See “Common query parameters”; additionally:Success response (200 OK)
-
Content-Type:
text/csv; charset=utf-8 -
Content-Disposition:
attachment; filename="ai-code-commits.csv"
userName; JSON responses have removed it):
3. List change details
GET /v1/organizations/{organization_id}/ai-code-tracking/changes
List IDE AI code edit events (only action=suggested records), ordered by event time descending.
Changes are IDE events not yet committed to Git, so repoName filtering is not supported.
Path parameters
Query parameters
See “Common query parameters”; additionally:Success response (200 OK)
Response fields
success —true indicates the request succeeded
data.items[] — Change detail list
data.pagination — Pagination info
4. Export change CSV
GET /v1/organizations/{organization_id}/ai-code-tracking/changes/export
Export change data in streaming CSV format. The server automatically handles pagination aggregation—callers do not need to paginate manually.
CSV export uses a flat format and does not include metadata (file-level details).
Path parameters
Query parameters
See “Common query parameters”; additionally:Success response (200 OK)
-
Content-Type:
text/csv; charset=utf-8 -
Content-Disposition:
attachment; filename="ai-code-changes.csv"
Usage examples
Query commit details (filter by repo)
Query user commits by email
Export commit CSV
Query change details (filter by source)
Export change CSV
Error codes
Error response shape: see Error responses in Conventions.