claude-code - 💡(How to fix) Fix API access to usage limits and total monthly usage [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45392Fetched 2026-04-09 08:06:29
View on GitHub
Comments
2
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×2labeled ×1
RAW_BUFFERClick to expand / collapse

Feature Request

Request for an API endpoint (or enhancement to the existing OAuth usage endpoint) that exposes:

  • Current monthly usage totals
  • Account/plan usage limits
  • Remaining quota

Use Case

Programmatic access to usage data enables automated throttling and capacity planning. Currently, the OAuth usage endpoint provides rolling-window consumption percentages, but there is no way to retrieve absolute usage numbers or plan limits via API.

Desired Behavior

An API endpoint that returns structured data including:

  • Total tokens/requests used in the current billing period
  • Plan-level limits (tokens, requests, spend caps)
  • Remaining quota before limits are reached

extent analysis

TL;DR

Implementing a new API endpoint to expose current monthly usage totals, account/plan usage limits, and remaining quota is likely the most straightforward fix.

Guidance

  • Review the existing OAuth usage endpoint to determine if it can be extended to include the requested usage data, rather than creating a new endpoint.
  • Consider the security implications of exposing absolute usage numbers and plan limits via API, and ensure proper authentication and authorization mechanisms are in place.
  • Define a clear data structure for the API response, including the specific fields and units for usage totals, limits, and remaining quota.
  • Develop a plan for handling cases where usage data is not available or is incomplete, such as during billing period transitions.

Example

{
  "usage": {
    "total_tokens": 1000,
    "total_requests": 500,
    "billing_period": "2023-03-01T00:00:00Z/2023-04-01T00:00:00Z"
  },
  "limits": {
    "tokens": 2000,
    "requests": 1000,
    "spend_cap": 100.00
  },
  "quota": {
    "remaining_tokens": 1000,
    "remaining_requests": 500,
    "remaining_spend": 50.00
  }
}

Notes

The implementation details will depend on the specific requirements and constraints of the system, including the existing OAuth usage endpoint and the underlying data storage and retrieval mechanisms.

Recommendation

Apply a workaround by extending the existing OAuth usage endpoint to include the requested usage data, as this is likely to be the most efficient and effective solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix API access to usage limits and total monthly usage [2 comments, 2 participants]