Usage Analytics¶
Usage analytics read usage and cost data for reporting, debugging, and customer-facing dashboards.
Example¶
curl "$SPENDWARE_BASE_URL/api/v1/usage/query-usage?include_statistics=true&token_unit_size=million&request_unit_size=thousand" \
-H "Authorization: Bearer $SPENDWARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"project_ids":["PROJECT_ID"],"customer_ids":["CUSTOMER_ID"]}'
usage = client.usage.query(
{"project_ids": ["PROJECT_ID"], "customer_ids": ["CUSTOMER_ID"]},
include_statistics=True,
token_unit_size="million",
request_unit_size="thousand",
)
const usage = await client.usage.query(
{ project_ids: ["PROJECT_ID"], customer_ids: ["CUSTOMER_ID"] },
{ includeStatistics: true, tokenUnitSize: "million", requestUnitSize: "thousand" },
);
Data Paths¶
Spendware returns finalized usage by default. This keeps analytics aligned with resources that are ready for billing, guardrails, and customer reporting.
Use partials_mode: include_eligible_partials when a report should include eligible unresolved partial usage. The default is finalized_only, which keeps normal analytics tied to finalized ledger resources.
Date Windows¶
Use explicit date or timestamp filters when you need stable reporting windows. Some unscoped routes apply safety windows to avoid broad scans.