| Crates.io | claude-usage |
| lib.rs | claude-usage |
| version | 0.1.0 |
| created_at | 2026-01-25 14:30:01.335679+00 |
| updated_at | 2026-01-25 14:30:01.335679+00 |
| description | Fetch Claude API usage data from Anthropic |
| homepage | https://github.com/PabloLION/agent-console-dashboard |
| repository | https://github.com/PabloLION/agent-console-dashboard |
| max_upload_size | |
| id | 2068838 |
| size | 90,657 |
Fetch Claude API usage data from Anthropic.
This crate provides a simple API to retrieve usage statistics for Claude API, including 5-hour and 7-day utilization percentages.
| Platform | Credential Source |
|---|---|
| macOS | Keychain ("Claude Code-credentials") |
| Linux | ~/.claude/.credentials.json |
[dependencies]
claude-usage = "0.1"
use claude_usage::get_usage;
fn main() -> Result<(), claude_usage::Error> {
let usage = get_usage()?;
println!("5-hour utilization: {}%", usage.five_hour.utilization);
println!("7-day utilization: {}%", usage.seven_day.utilization);
// Check if usage is sustainable
if usage.five_hour_on_pace() {
println!("5-hour usage is on pace");
}
// Get time until reset
let time_left = usage.five_hour.time_until_reset();
println!("Resets in {} minutes", time_left.num_minutes());
Ok(())
}
The CLAUDE_CODE_OAUTH_TOKEN environment variable can be set to override
file-based credential retrieval on any platform.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.