Skip to content
AF

HealthKit Query Generator

120 quantity types, 3of them with no aggregation style stated · read from Apple’s documentation on 2026-08-28

Pick one HealthKit quantity type and a time window and this returns the HKStatisticsQuery for it, with the aggregation option taken from what Apple's own documentation says about that type: .cumulativeSum where Apple describes the values as cumulative, .discreteAverage where it describes them as discrete. For the three quantity types Apple never states it for, the tool refuses to generate anything, because the wrong option does not throw — it returns a plausible, wrong number. Category types get a refusal too: a category sample carries an enum case, not a value to aggregate.

One at a time, from the 150 quantity and category identifiers Apple documents.

Nothing picked yet. Choose a type and this returns either a statistics query with the correct aggregation option, or the reason it will not write one for you.

Why the refusal is the feature

Apple states whether a quantity type accumulates or is measured point-in-time inside the type’s discussion prose, not as a property you can read at compile time. The distinction decides which HKStatisticsQuery option is correct: cumulative types are summed with .cumulativeSum, discrete types are reduced with .discreteAverage, .discreteMin or .discreteMax.

Pick the wrong one and nothing throws. You get a number, it renders in your UI, and it is wrong — a summed week of heart rate reads in the tens of thousands and looks like a bug in someone else’s code. That is why, for the 3quantity types Apple’s wording does not cover — appleSleepingBreathingDisturbances, estimatedWorkoutEffortScore, workoutEffortScore — this tool emits nothing at all. A generator that guesses is worse than no generator.

Where this output comes from, and where it runs

Everything on this page runs client-side. Your selection never leaves the browser: there is no request to a server, nothing is stored, and no health data is involved — you are picking a type name, not data.

The identifiers, their aggregation style and their unit family are parsed from Apple’s developer documentation on 2026-08-28 and published in full at every HealthKit type identifier. Aggregation and unit family are the only derived fields in that dataset, and the Apple sentence each was derived from is stored beside it — which is the sentence this tool quotes back at you under the verdict.

The query shape is the one published in the HealthKit integration guide. HKQuantityType(.case) is the iOS 16+ initializer; on older targets build the same type with HKObjectType.quantityType(forIdentifier:). HKUnit.count() is the only unit constructor this site has verified, so it is emitted only for count-family types and every other family gets a comment naming the family instead of a guessed constructor. Date arithmetic beyond Calendar.current.startOfDay(for:) is left to you for the same reason — and because where a day starts is a decision, not a default. Verify every signature against Apple’s current documentation before you ship.

A free tool from AIFitnessAPI. Data read from Apple’s published documentation on 2026-08-28; the machine-readable export is on datasets.