<!--
{
  "documentType" : "article",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/queries",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Queries"
}
-->

# Queries

Query health and fitness data.

## Discussion

Use queries to read sample data from the HealthKit store. You can also use queries to list all the sources for a particular data type, or to perform statistical calculations for a data type. For example, statistical queries can calculate the minimum and maximum heart rate for a given week, or the total step count for a given day.

You run a query by calling the HealthKit store’s [`execute(_:)`](/documentation/HealthKit/HKHealthStore/execute(_:)) method. HealthKit returns a snapshot of the current results to the query’s results handler. Long-running queries continue to monitor the HealthKit store, and return any relevant changes to the query’s update handler. To return sorted or filtered results, give the query a sort descriptor or predicate.

## Topics

### Essentials

  <doc://com.apple.healthkit/documentation/HealthKit/reading-data-from-healthkit>

### Swift concurrency support

  <doc://com.apple.healthkit/documentation/HealthKit/running-queries-with-swift-concurrency>

[`HKAsyncQuery`](/documentation/HealthKit/HKAsyncQuery)

A protocol that defines an asynchronous method for running queries.

[`HKAsyncSequenceQuery`](/documentation/HealthKit/HKAsyncSequenceQuery)

A protocol that defines a method for running queries that returns results using an asynchronous sequence.

[`HKSamplePredicate`](/documentation/HealthKit/HKSamplePredicate)

A predicate for queries that return a collection of matching sample objects.

### Basic queries

[`HKSampleQueryDescriptor`](/documentation/HealthKit/HKSampleQueryDescriptor)

A query interface that reads samples using Swift concurrency.

[`HKSampleQuery`](/documentation/HealthKit/HKSampleQuery)

A general query that returns a snapshot of all the matching samples currently saved in the HealthKit store.

[`HKCorrelationQuery`](/documentation/HealthKit/HKCorrelationQuery)

A query that performs complex searches based on the correlation’s contents, and returns a snapshot of all matching samples.

[`HKQueryDescriptor`](/documentation/HealthKit/HKQueryDescriptor)

A descriptor that specifies a set of samples based on the data type and a predicate.

[`HKQuery`](/documentation/HealthKit/HKQuery)

An abstract class for all the query classes in HealthKit.

### Series queries

[`HKQuantitySeriesSampleQueryDescriptor`](/documentation/HealthKit/HKQuantitySeriesSampleQueryDescriptor)

A query interface that reads the series data associated with quantity samples using Swift concurrency.

[`HKQuantitySeriesSampleQuery`](/documentation/HealthKit/HKQuantitySeriesSampleQuery)

A query that accesses the series data associated with a quantity sample.

[`HKWorkoutRouteQueryDescriptor`](/documentation/HealthKit/HKWorkoutRouteQueryDescriptor)

A query interface that reads the location data stored in a workout route using Swift concurrency.

[`HKWorkoutRouteQuery`](/documentation/HealthKit/HKWorkoutRouteQuery)

A query to access the location data stored in a workout route.

[`HKHeartbeatSeriesQueryDescriptor`](/documentation/HealthKit/HKHeartbeatSeriesQueryDescriptor)

A query interface that reads the heartbeat series data stored in a heartbeat sample using Swift concurrency.

[`HKHeartbeatSeriesQuery`](/documentation/HealthKit/HKHeartbeatSeriesQuery)

A query that returns the heartbeat data contained in a heartbeat series sample.

[`HKElectrocardiogramQueryDescriptor`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor)

A query interface that reads the underlying voltage measurements for an electrocardiogram sample using Swift concurrency.

[`HKElectrocardiogramQuery`](/documentation/HealthKit/HKElectrocardiogramQuery)

A query that returns the underlying voltage measurements for an electrocardiogram sample.

[`HKWorkoutEffortRelationship`](/documentation/HealthKit/HKWorkoutEffortRelationship)

[`HKWorkoutEffortRelationshipQuery`](/documentation/HealthKit/HKWorkoutEffortRelationshipQuery)

### Long-running queries

[`HKActivitySummaryQueryDescriptor`](/documentation/HealthKit/HKActivitySummaryQueryDescriptor)

A query interface that reads activity summaries using Swift concurrency.

[`HKActivitySummaryQuery`](/documentation/HealthKit/HKActivitySummaryQuery)

A query for reading activity summary objects from the HealthKit store.

[`HKAnchoredObjectQueryDescriptor`](/documentation/HealthKit/HKAnchoredObjectQueryDescriptor)

A query interface that runs anchored object queries using Swift concurrency.

[`HKAnchoredObjectQuery`](/documentation/HealthKit/HKAnchoredObjectQuery)

A query that returns changes to the HealthKit store, including a snapshot of new changes and continuous monitoring as a long-running query.

[`HKObserverQuery`](/documentation/HealthKit/HKObserverQuery)

A long-running query that monitors the HealthKit store and updates your app when the HealthKit store saves or deletes a matching sample.

### Sources and devices

[`HKSourceQueryDescriptor`](/documentation/HealthKit/HKSourceQueryDescriptor)

A query interface that uses Swift concurrency to read the apps and devices that produced the matching samples.

[`HKSourceRevision`](/documentation/HealthKit/HKSourceRevision)

An object indicating the source of a HealthKit sample.

[`HKSource`](/documentation/HealthKit/HKSource)

An object indicating the app or device that created a HealthKit sample

[`HKDevice`](/documentation/HealthKit/HKDevice)

A device that generates data for HealthKit.

[`HKSourceQuery`](/documentation/HealthKit/HKSourceQuery)

A query that returns a list of sources, such as apps and devices, that have saved matching queries to the HealthKit store.

### Statistics

  <doc://com.apple.healthkit/documentation/HealthKit/executing-statistical-queries>

  <doc://com.apple.healthkit/documentation/HealthKit/executing-statistics-collection-queries>

[`HKStatisticsQueryDescriptor`](/documentation/HealthKit/HKStatisticsQueryDescriptor)

A query descriptor that calculates the minimum, maximum, average, or sum over a set of samples from the HealthKit store.

[`HKStatisticsQuery`](/documentation/HealthKit/HKStatisticsQuery)

A query that performs statistical calculations over a set of matching quantity samples, and returns the results.

[`HKStatisticsCollectionQueryDescriptor`](/documentation/HealthKit/HKStatisticsCollectionQueryDescriptor)

A query descriptor that gathers a collection of statistics calculated over a series of fixed-length time intervals.

[`HKStatisticsCollectionQuery`](/documentation/HealthKit/HKStatisticsCollectionQuery)

A query that performs multiple statistics queries over a series of fixed-length time intervals.

[`HKStatistics`](/documentation/HealthKit/HKStatistics)

An object that represents the result of calculating the minimum, maximum, average, or sum over a set of samples from the HealthKit store.

[`HKStatisticsCollection`](/documentation/HealthKit/HKStatisticsCollection)

An object that manages a collection of statistics, representing the results calculated over separate time intervals.

[`HKStatisticsOptions`](/documentation/HealthKit/HKStatisticsOptions)

Options for specifying the statistic to calculate.

### Clinical record queries

[`HKVerifiableClinicalRecordQueryDescriptor`](/documentation/HealthKit/HKVerifiableClinicalRecordQueryDescriptor)

A query interface that provides one-time access to a SMART Health Card or EU Digital COVID Certificate using Swift concurrency.

[`HKVerifiableClinicalRecordQuery`](/documentation/HealthKit/HKVerifiableClinicalRecordQuery)

A query for one-time access to a SMART Health Card or EU Digital COVID Certificate.

[`HKVerifiableClinicalRecordSourceType`](/documentation/HealthKit/HKVerifiableClinicalRecordSourceType)

The source type for the verifiable clinical record.

[`HKVerifiableClinicalRecordCredentialType`](/documentation/HealthKit/HKVerifiableClinicalRecordCredentialType)

The type of record returned by a verifiable clinical record query.

[`HKDocumentQuery`](/documentation/HealthKit/HKDocumentQuery)

A query that returns a snapshot of all matching documents currently saved in the HealthKit store.

### Medication queries

[`HKClinicalCoding`](/documentation/HealthKit/HKClinicalCoding)

A clinical coding that represents a medical concept using a standardized coding system.

[`HKHealthConceptIdentifier`](/documentation/HealthKit/HKHealthConceptIdentifier)

A unique identifier for a specific health concept within a domain.

[`HKMedicationConcept`](/documentation/HealthKit/HKMedicationConcept)

An object that describes a specific medication concept.

[`HKMedicationDoseEvent`](/documentation/HealthKit/HKMedicationDoseEvent)

[`HKMedicationDoseEventType`](/documentation/HealthKit/HKMedicationDoseEventType)

[`HKUserAnnotatedMedication`](/documentation/HealthKit/HKUserAnnotatedMedication)

A reference to the tracked medication and the details a person can customize.

[`HKUserAnnotatedMedicationQuery`](/documentation/HealthKit/HKUserAnnotatedMedicationQuery)

[`HKUserAnnotatedMedicationType`](/documentation/HealthKit/HKUserAnnotatedMedicationType)

[`HKHealthConceptDomain`](/documentation/HealthKit/HKHealthConceptDomain)

A domain that represents a health concept.

[`HKMedicationGeneralForm`](/documentation/HealthKit/HKMedicationGeneralForm)

The manufactured form of a medication.

[`HKUserAnnotatedMedicationQueryDescriptor`](/documentation/HealthKit/HKUserAnnotatedMedicationQueryDescriptor)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)