Skip to main content

get_usage

Function get_usage 

Source
pub fn get_usage() -> Result<UsageData, Error>
Expand description

Fetch current Claude API usage data.

This is the main entry point for the crate. It:

  1. Retrieves credentials from platform-specific storage
  2. Calls the Anthropic usage API
  3. Returns typed usage data

§Example

use claude_usage::get_usage;

let usage = get_usage()?;
println!("5h utilization: {}%", usage.five_hour.utilization);
println!("7d utilization: {}%", usage.seven_day.utilization);

§Errors

Returns Error if:

  • Credentials are not found or expired
  • API call fails
  • Response parsing fails