Admin API lines_of_code metric significantly undercounts compared to /cost
Resolved 💬 1 comment Opened Apr 10, 2026 by john-glass-vectorsolutions Closed May 25, 2026
Summary
The Claude Code Admin API endpoint (/v1/organizations/usage_report/claude_code) returns lines_of_code values that are dramatically lower than what the /cost command reports for the same user on the same day.
Example data
For the same user (Ajit) on the same days:
| | Apr 9 /cost | Apr 9 Admin API | Apr 10 /cost | Apr 10 Admin API |
|---|---|---|---|---|
| Lines added | 273 | 3 | 429 | 14 |
| Lines removed | 8 | 3 | 0 | 1 |
The cost and token data from the API are in the right ballpark compared to /cost, so this appears specific to the lines_of_code metric.
Context
- API endpoint:
GET /v1/organizations/usage_report/claude_code - The documentation describes
lines_of_code.addedas "Total number of lines of code added across all files by Claude Code" /costdescribes its metric as "Total code changes: N lines added, M lines removed"- Both claim to measure lines changed by Claude Code, but the API reports 1-2 orders of magnitude less
Additional observations
- Token counts and estimated costs from the API are reasonably close to
/costoutput, so the data pipeline is generally working - The
tool_actionscounts (e.g.,edit_tool.accepted: 3) are suspiciously close to thelines_of_code.addedvalue (3) on April 9, raising the question of whether operations are being counted instead of lines - All actors in our org show as
api_actortype withterminal_type: "unknown"or specific terminal types
Questions
- What exactly does the Admin API's
lines_of_codemetric measure? Is it intentionally different from/cost's "Total code changes"? - If they should match, is this a known bug in the aggregation pipeline?
- Is there a way to get the full line count (matching
/cost) through the Admin API?
Environment
- Claude Code CLI (latest)
- Admin API with
anthropic-version: 2023-06-01
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗