Skip to main content

Statistics

Pro Feature

The Programmatic API requires Prisma Calendar Pro.

getStatistics(input?)

Returns interval-based statistics with time breakdowns aggregated by event name or category. Uses the same statistics engine as the weekly/monthly stats modals.

Input:

PropertyTypeRequiredDefaultDescription
datestringnotodayISO date to anchor the interval (e.g. 2026-02-24)
intervalstringno"week""day", "week", or "month" — determines the date range
modestringnosettings default"name" or "category" — how to group time entries
calendarIdstringnoTarget calendar ID

Returns: Promise<PrismaStatisticsOutput | null>

PropertyTypeDescription
periodStartstringISO start of the resolved interval
periodEndstringISO end of the resolved interval
intervalstring"day", "week", or "month"
modestring"name" or "category"
totalDurationnumberTotal duration in milliseconds
totalDurationFormattedstringFormatted total (e.g. "12h 30m" or "12.5h")
totalEventsnumberTotal events in range (non-skipped)
timedEventsnumberTimed events count
allDayEventsnumberAll-day events count
skippedEventsnumberSkipped events count
doneEventsnumberEvents marked as done
undoneEventsnumberEvents marked as not done
entriesPrismaStatEntry[]Time breakdown entries (see below)

Entry shape:

PropertyTypeDescription
namestringEvent name or category
durationnumberDuration in milliseconds
durationFormattedstringFormatted duration
percentagestringPercentage of total (e.g. "45.3%")
countnumberNumber of events
isRecurringbooleanWhether the event is recurring

Examples:

// Weekly stats for the current week (default)
const stats = await window.PrismaCalendar.getStatistics();
console.log(`This week: ${stats.totalDurationFormatted} tracked`);
stats.entries.forEach(e => console.log(`${e.name}: ${e.durationFormatted} (${e.percentage})`));

// Monthly stats by category for February
const monthly = await window.PrismaCalendar.getStatistics({
date: "2026-02-01",
interval: "month",
mode: "category"
});
console.log(`February: ${monthly.totalEvents} events, ${monthly.doneEvents} done`);

// Daily stats for a specific date
const daily = await window.PrismaCalendar.getStatistics({
date: "2026-02-24",
interval: "day"
});