API / download-ai-commit-metrics-csv-via-api

API

Download AI commit metrics CSV with the AI Code Tracking API

Stream commit metrics as CSV for large extractions with GET https://api.cursor.com/analytics/ai-code/commits.csv. Official reference: AI Code Tracking API → Download AI Commit Metrics.

Authenticate with a team API key (Basic auth, key as username, empty password — same method as the Admin API). Create keys at cursor.com/dashboard → API Keys with scope admin:*. Availability: Enterprise only (contact sales for access). Status: Alpha — response shapes and fields may change. Rate limit: 20 requests per minute per endpoint. Metrics cover the git repository at the top level of the workspace root; multi-root workspaces are unsupported.

CSV endpoints stream in pages of 10,000 records server-side. Prefer them over paginated JSON when you need a full dump.

Query parameters

Parameter Rules
startDate ISO date, now, or relative days such as 7d. Default: now − 7 days
endDate ISO date, now, or relative days such as 0d. Default: now
user Optional single-user filter: email, encoded id (user_…), or numeric id

No page / pageSize — the response streams the full window.

Request

curl -L "https://api.cursor.com/analytics/ai-code/commits.csv?startDate=2025-07-01T00:00:00Z&endDate=now&user=user_3k9x8q..." \
  -u YOUR_API_KEY: \
  -o commits.csv

Response header: Content-Type: text/csv; charset=utf-8.

Sample output:

commit_hash,commit_source,user_id,user_email,repo_name,branch_name,is_primary_branch,total_lines_added,total_lines_deleted,tab_lines_added,tab_lines_deleted,composer_lines_added,composer_lines_deleted,non_ai_lines_added,non_ai_lines_deleted,message,commit_ts,created_at
a1b2c3d4,ide,user_3k9x8q...,developer@company.com,company/repo,main,true,120,30,50,10,40,5,30,15,"Refactor: extract analytics client",2025-07-30T14:12:03.000Z,2025-07-30T14:12:30.000Z
e5f6g7h8,cloud,user_3k9x8q...,developer@company.com,company/repo,feature-branch,false,85,15,30,5,25,3,30,7,"Add error handling",2025-07-30T13:45:21.000Z,2025-07-30T13:45:45.000Z

CSV columns

Column Type Meaning
commit_hash string Git commit hash
user_id string Encoded user id
user_email string User email
repo_name string Repository name
branch_name string Branch name
is_primary_branch boolean Whether the branch is the repo default
commit_source string ide, cli, or cloud
total_lines_added / total_lines_deleted number Total lines in the commit
tab_lines_added / tab_lines_deleted number Lines from accepted TAB completions
composer_lines_added / composer_lines_deleted number Lines from accepted Composer / Agent diffs
non_ai_lines_added / non_ai_lines_deleted number Derived non-AI lines
message string Commit message
commit_ts string Commit timestamp (ISO)
created_at string Ingestion timestamp (ISO)

Column names use snake_case; the JSON route uses camelCase. Field meanings match Get AI commit metrics.

Semantics

  • TAB = accepted inline completions; COMPOSER = accepted Agent / Composer diffs.
  • non_ai_* is derived as max(0, total − AI lines).
  • commit_ts is git time; created_at is ingestion time.
  • Follow redirects with -L so the stream lands in your output file.

Pitfalls

  • Omitting -L / -o — you may print a redirect body instead of writing the CSV file.
  • Expecting JSON field names (commitHash) in the CSV — columns are snake_case.
  • Calling from a multi-root workspace — only the top-level git repo is covered.
  • Amended commits can appear more than once under the same commit_ts.
  • Hitting the 20/min limit while polling large windows — one CSV pull covers the range; avoid tight loops.

For accepted AI changes independent of commits (JSON or CSV), see Get AI code change metrics.