usage

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package usage provides access to the Anthropic quota usage API.

Index

Constants

This section is empty.

Variables

View Source
var AuthFailPath = "/tmp/claude-usage-auth-failed"

AuthFailPath stores the token hash of the last authentication failure. Replaceable for testing.

View Source
var CachePath = "/tmp/claude-usage-cache.json"

CachePath is the path to the usage cache file. Replaceable for testing.

View Source
var CacheTTL = 10 * time.Minute

CacheTTL is the cache duration for usage data. Configurable at startup.

View Source
var ErrUnexpectedStatus = errors.New("unexpected status from usage API")

ErrUnexpectedStatus is returned when the usage API returns a non-200/401/429 status code.

HTTPGetFn is the function used for HTTP requests. Replaceable for testing.

View Source
var LastGoodCachePath = "/tmp/claude-usage-last-good.json"

LastGoodCachePath stores the last successful API response. Replaceable for testing.

View Source
var RetryAfterPath = "/tmp/claude-usage-retry-after"

RetryAfterPath stores the retry-after deadline. Replaceable for testing.

Functions

func Fetch

func Fetch() (*fmtutil.Data, error)

Fetch retrieves quota usage from Anthropic API (with caching).

func FetchLastGood added in v0.2.0

func FetchLastGood() *fmtutil.Data

FetchLastGood returns the last successful usage data (no TTL).

func ParseBody

func ParseBody(body []byte) (*fmtutil.Data, error)

ParseBody parses the usage API response body.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL