Skip to content

Add usage limit tracking (5-hour and weekly) via Anthropic OAuth API#9

Open
Dobidop wants to merge 2 commits intojack21:mainfrom
Dobidop:feature/usage-limit-tracking
Open

Add usage limit tracking (5-hour and weekly) via Anthropic OAuth API#9
Dobidop wants to merge 2 commits intojack21:mainfrom
Dobidop:feature/usage-limit-tracking

Conversation

@Dobidop
Copy link

@Dobidop Dobidop commented Mar 6, 2026

Summary

  • Adds real-time usage limit tracking by fetching from api.anthropic.com/api/oauth/usage using Claude Code's existing OAuth credentials (~/.claude/.credentials.json)
  • Displays 5-hour and weekly usage percentages in the status bar: $X.XX | 5h:X% | 7d:X%
  • Warning background on the status bar when either limit exceeds 80%
  • Detailed webview cards with color-coded progress bars and reset countdowns
  • Zero configuration needed — reuses Claude Code's auth automatically
  • Graceful fallback when credentials unavailable (no errors for unauthenticated users)

How it works

  1. Reads OAuth credentials from ~/.claude/.credentials.json (created by claude auth login)
  2. Calls https://api.anthropic.com/api/oauth/usage with Bearer token + anthropic-beta: oauth-2025-04-20
  3. Auto-refreshes expired tokens via https://console.anthropic.com/v1/oauth/token
  4. Caches results for 2 minutes to avoid excessive API calls

Screenshots

image

image

Dobidop and others added 2 commits March 6, 2026 11:19
Fetches real-time usage limits from api.anthropic.com/api/oauth/usage
using Claude Code's existing OAuth credentials (~/.claude/.credentials.json).
Displays 5-hour and weekly usage percentages in the status bar alongside
the cost display, with warning highlights at 80%+ utilization. Detailed
breakdown with progress bars and reset times shown in the webview panel.

- New ClaudeApiClient for OAuth-based API calls with auto token refresh
- Status bar shows: $X.XX | 5h:X% | 7d:X%
- Warning background when either limit exceeds 80%
- Tooltip shows reset times for both limits
- Webview cards with color-coded progress bars (normal/warning/critical)
- Supports per-model limits (Sonnet/Opus weekly) for Max tier users
- Graceful fallback when credentials are unavailable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant