HealthKit.SampleQuery
---------------------

Queries sample data from the database.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [HealthKit](component_HealthKit.md) | [8.2](newinversion82.md) | ❌ No | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "HealthKit.SampleQuery"; QuantityType; Unit; StartDate; EndDate { ; SortKey; ascending; Limit } ) 

**MBS**( **"HealthKit.SampleQuery";** /\* Queries sample data from the database. \*/  
**$QuantityType**; /\* The quantity type to lookup.e.g. "StepCount" \*/   
**$Unit**; /\* The unit to use.  
Can be SI unit or for example count for counters.  
See Apple documentation for details.e.g. "count" \*/   
**$StartDate**; /\* The start date for the search.e.g. Date ( 1 ; 1 ; 2018 ) \*/   
**$EndDate**; /\* The end date for the search.e.g. Date ( 2 ; 1 ; 2018 ) \*/   
**$SortKey**; /\* Optional; How to sort.  
Can be StartDate or EndDate.e.g. "StartDate" \*/   
**$ascending**; /\* Optional; Whether to prefer ascending instead of descending.  
Pass 1 for ascending or 0 for descending.e.g. 1 \*/   
**$Limit**) /\* Optional; The limit for search.  
Default 0 for no limit.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| QuantityType | The quantity type to lookup. | "StepCount" |  |
| Unit | The unit to use.   Can be SI unit or for example count for counters.   See Apple documentation for details. | "count" |  |
| StartDate | The start date for the search. | Date ( 1 ; 1 ; 2018 ) |  |
| EndDate | The end date for the search. | Date ( 2 ; 1 ; 2018 ) |  |
| SortKey | How to sort.   Can be StartDate or EndDate. | "StartDate" | Optional |
| ascending | Whether to prefer ascending instead of descending.   Pass 1 for ascending or 0 for descending. | 1 | Optional |
| Limit | The limit for search.   Default 0 for no limit. | 0 | Optional |

### Result

Returns values as JSON or error.

### Description

Queries sample data from the database.  
Before calling this method, the application should request authorization to access objects with the desired quantity type.  
  
Supported quantity types:  
  
Body Measurements:  
BodyFatPercentage, BodyMass, BodyMassIndex, Height, LeanBodyMass, WaistCircumference.  
  
Fitness:  
StepCount, DistanceWalkingRunning, DistanceCycling, DistanceWheelchair, BasalEnergyBurned, ActiveEnergyBurned, FlightsClimbed, NikeFuel, AppleExerciseTime, PushCount, DistanceSwimming, SwimmingStrokeCount, VO2Max.  
  
Vitals:  
HeartRate, BodyTemperature, BasalBodyTemperature, BloodPressureSystolic, BloodPressureDiastolic, RespiratoryRate.  
  
Results:  
OxygenSaturation, PeripheralPerfusionIndex, BloodGlucose, NumberOfTimesFallen, ElectrodermalActivity, InhalerUsage, InsulinDelivery, BloodAlcoholContent, ForcedVitalCapacity, ForcedExpiratoryVolume1, PeakExpiratoryFlowRate.  
  
Nutrition:  
DietaryFatTotal, DietaryFatPolyunsaturated, DietaryFatMonounsaturated, DietaryFatSaturated, DietaryCholesterol, DietarySodium, DietaryCarbohydrates, DietaryFiber, DietarySugar, DietaryEnergyConsumed, DietaryProtein,   
DietaryVitaminA, DietaryVitaminB6, DietaryVitaminB12, DietaryVitaminC, DietaryVitaminD, DietaryVitaminE, DietaryVitaminK, DietaryCalcium, DietaryIron, DietaryThiamin, DietaryRiboflavin, DietaryNiacin, DietaryFolate, DietaryBiotin, DietaryPantothenicAcid, DietaryPhosphorus, DietaryIodine, DietaryMagnesium, DietaryZinc, DietarySelenium, DietaryCopper, DietaryManganese, DietaryChromium, DietaryMolybdenum, DietaryChloride, DietaryPotassium, DietaryCaffeine, DietaryWater.  
  
UVExposure  
### Examples

Query step count:

 Set Field \[ PlaceHolder::Result ; MBS ( "HealthKit.SampleQuery"; "StepCount"; "count"; Date ( 1 ; 1 ; 2018 ); Date ( 1 ; 1 ; 2019 ) ) \]  
### Blog Entries

- [HealthKit for FileMaker on iOS](https://www.mbsplugins.de/archive/2018-04-26/HealthKit_for_FileMaker_on_iOS/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 25th April 2018 , last changed 26th April 2018

  
[HealthKit.RequestAuthorizationToShareTypes](HealthKitRequestAuthorizationToShareTypes.md) - [HealthKit.WheelchairUse](HealthKitWheelchairUse.md)

[HTML Version](HealthKitSampleQuery.shtml)