API / get-top-file-extensions-via-analytics-api

API

Get top file extensions with the Analytics API

Pull team-level metrics on the most frequently edited file extensions in Cursor with GET https://api.cursor.com/analytics/team/top-file-extensions. Official reference: Analytics API → Top File Extensions.

Authenticate with Basic auth (API key as username, empty password). Create keys at Cursor Dashboard → API Keys. Most Analytics endpoints need scope admin:*. Availability: Enterprise only. Team-level rate limit: 100 requests per minute per team (by-user Analytics endpoints are 50/min — covered in a later batch).

Returns the top 5 file extensions per day by suggestion volume.

Query parameters

Parameter Rules
startDate Optional. Default: 7 days ago. Prefer YYYY-MM-DD, or shortcuts now / today / yesterday / Nd (e.g. 14d). Max range 30 days. Time is ignored (day-level UTC).
endDate Optional. Default: today. Same formats as startDate.
users Optional. Comma-separated emails and/or public user ids (user_…). Mix formats in one request.

Omit both dates for the last 7 days (simplest path for HTTP caching). Prefer day shortcuts or YYYY-MM-DD over ISO timestamps so ETag cache hits stay stable.

Request

Docs example with a 30-day window:

curl -X GET "https://api.cursor.com/analytics/team/top-file-extensions?startDate=30d&endDate=today" \
  -u YOUR_API_KEY:

Default last-7-days call:

curl -X GET "https://api.cursor.com/analytics/team/top-file-extensions" \
  -u YOUR_API_KEY:

With a user filter:

curl -X GET "https://api.cursor.com/analytics/team/top-file-extensions?startDate=14d&endDate=today&users=alice@example.com,user_abc123" \
  -u YOUR_API_KEY:

Example response:

{
  "data": [
    {
      "event_date": "2025-01-15",
      "file_extension": "tsx",
      "total_files": 156,
      "total_accepts": 98,
      "total_rejects": 45,
      "total_lines_suggested": 3230,
      "total_lines_accepted": 2340,
      "total_lines_rejected": 890
    },
    {
      "event_date": "2025-01-15",
      "file_extension": "ts",
      "total_files": 142,
      "total_accepts": 89,
      "total_rejects": 38,
      "total_lines_suggested": 2850,
      "total_lines_accepted": 2100,
      "total_lines_rejected": 750
    }
  ],
  "params": {
    "metric": "top-files",
    "teamId": 12345,
    "startDate": "2025-01-01",
    "endDate": "2025-01-31"
  }
}

Response fields

Field Type Meaning
event_date string Day the metrics cover (YYYY-MM-DD)
file_extension string Extension (e.g. tsx, ts)
total_files number Files touched for that extension
total_accepts number Accepts
total_rejects number Rejects
total_lines_suggested number Lines suggested
total_lines_accepted number Lines accepted
total_lines_rejected number Lines rejected
params.metric string Echoes top-files
params.teamId number Team id for the key
params.startDate / params.endDate string Resolved range

Caching

Store the response ETag and send it back as If-None-Match on the next poll. Unchanged data returns 304 Not Modified with no body; 304s do not count against the rate limit. Analytics endpoints use Cache-Control: public, max-age=900 (15 minutes). See API Overview → Caching.

Pitfalls

  • Requesting more than 30 days — the Analytics date range caps at 30 days (startDate=30d&endDate=today is the documented max-window example).
  • Sending timestamps with clock times — time is ignored, and varying times break ETag cache hits.
  • Expecting more than five extensions per day — the endpoint returns the top 5 by suggestion volume.
  • Reading params.metric as top-file-extensions — the echo value is top-files.
  • Polling without If-None-Match — burns the 100/min team budget on identical payloads.

Sibling how-tos in this batch: Get client versions, Get MCP adoption, Get commands adoption. Related: Get agent edits, Get tab usage.