GlucoseIQ
API Reference@glucoseiq/core

AGP & Metrics Aggregate

AGP-style percentile-band series and selected aggregate metrics.

buildAGPProfile

Import: @glucoseiq/core/metrics

buildAGPProfile(readings: GlucoseReading[], options?: AGPProfileOptions): AGPProfileResult

Builds an AGP-style time-of-day percentile-band series from glucose readings.

Returns: Full-day bin grid with per-bin percentiles

Throws: If binMinutes is not an integer in [1, 1440]

Throws: If timeZone is not a valid IANA time zone

import { type GlucoseReading } from '@glucoseiq/core'
import { buildAGPProfile } from '@glucoseiq/core/metrics'

const readings: GlucoseReading[] = [
  { value: 110, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
  { value: 145, unit: 'mg/dL', timestamp: '2024-01-02T08:00:00Z' },
]
const profile = buildAGPProfile(readings, { timeZone: 'America/New_York' })
const populatedBin = profile.bins.find((bin) => bin.n > 0)
const median = populatedBin?.percentiles[50] ?? null
void median
ParameterDescription
readingsGlucose readings with ISO 8601 timestamps
optionsBin width, percentiles, time zone, output unit, and method

calculateAGPMetrics

Import: @glucoseiq/core/metrics

calculateAGPMetrics(readings: GlucoseReading[], options?: AGPMetricsOptions): AGPMetricsResult

Calculates a selected aggregate set of AGP metrics from glucose readings.

This convenience function computes the fields in AGPMetricsResult in one call. Other public metrics remain available through their focused functions.

Returns: Selected aggregate AGP metrics result

Throws: If readings array is empty

Throws: If a nested metric rejects a reading or option

ParameterDescription
readingsArray of GlucoseReading objects with timestamps
optionsOptional configuration for individual metrics

On this page