Skip to content

ccusage / data-loader / loadSessionUsageById

Function: loadSessionUsageById()

ts
function loadSessionUsageById(sessionId, options?): Promise<
  | null
  | {
  totalCost: number;
  entries: object[];
}>;

Load usage data for a specific session by sessionId Searches for a JSONL file named {sessionId}.jsonl in all Claude project directories

Parameters

ParameterTypeDescription
sessionIdstringThe session ID to load data for (matches the JSONL filename)
options?{ mode?: "auto" | "calculate" | "display"; offline?: boolean; }Options for loading data
options.mode?"auto" | "calculate" | "display"Cost calculation mode (auto, calculate, display)
options.offline?booleanWhether to use offline pricing data

Returns

Promise< | null | { totalCost: number; entries: object[]; }>

Usage data for the specific session or null if not found

Released under the MIT License.