{"id":31433415,"url":"https://github.com/cap-go/capacitor-health","last_synced_at":"2026-03-16T08:11:07.568Z","repository":{"id":316410174,"uuid":"1063195756","full_name":"Cap-go/capacitor-health","owner":"Cap-go","description":"Capacitor plugin to interact with data from Apple healthKit and Google Fit","archived":false,"fork":false,"pushed_at":"2026-03-08T20:18:31.000Z","size":975,"stargazers_count":14,"open_issues_count":6,"forks_count":12,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-08T20:46:26.752Z","etag":null,"topics":["capacitor","ionic","plugin"],"latest_commit_sha":null,"homepage":"https://capgo.app","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-09-24T09:46:05.000Z","updated_at":"2026-03-08T20:18:04.000Z","dependencies_parsed_at":"2025-09-24T13:21:31.447Z","dependency_job_id":"1a74e7d3-11f3-4aba-8e30-64b011f4291f","html_url":"https://github.com/Cap-go/capacitor-health","commit_stats":null,"previous_names":["cap-go/capacitor-health"],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-health","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-health","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-health/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-health/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-health/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-health/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-health/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30466582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T11:00:43.441Z","status":"ssl_error","status_checked_at":"2026-03-13T11:00:23.173Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capacitor","ionic","plugin"],"created_at":"2025-09-30T11:13:58.306Z","updated_at":"2026-03-13T12:03:32.230Z","avatar_url":"https://github.com/Cap-go.png","language":"Kotlin","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":[],"sub_categories":[],"readme":"# @capgo/capacitor-health\n\n\u003ca href=\"https://capgo.app/\"\u003e\n  \u003cimg\n    src=\"https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png\"\n    alt=\"Capgo - Instant updates for capacitor\"\n  /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\n    \u003ca href=\"https://capgo.app/?ref=plugin_health\"\u003e ➡️ Get Instant updates for your App with Capgo\u003c/a\u003e\n  \u003c/h2\u003e\n  \u003ch2\u003e\n    \u003ca href=\"https://capgo.app/consulting/?ref=plugin_health\"\u003e Missing a feature? We’ll build the plugin for you 💪\u003c/a\u003e\n  \u003c/h2\u003e\n\u003c/div\u003e\n\nCapacitor plugin to read and write health metrics via Apple HealthKit (iOS) and Health Connect (Android). The TypeScript API keeps the same data types and units across platforms so you can build once and deploy everywhere.\n\n## Why Capacitor Health?\n\nThe only **free**, **unified** health data plugin for Capacitor supporting the latest native APIs:\n\n- **Health Connect (Android)** - Uses Google's newest health platform (replaces deprecated Google Fit)\n- **HealthKit (iOS)** - Full integration with Apple's health framework\n- **Unified API** - Same TypeScript interface across platforms with consistent units\n- **Multiple metrics** - Steps, distance, calories, heart rate, weight\n- **Read \u0026 Write** - Query historical data and save new health entries\n- **Modern standards** - Supports Android 8.0+ and iOS 14+\n- **Modern package management** - Supports both Swift Package Manager (SPM) and CocoaPods (SPM-ready for Capacitor 8)\n\nPerfect for fitness apps, health trackers, wellness platforms, and medical applications.\n\n## Documentation\n\nThe most complete doc is available here: https://capgo.app/docs/plugins/health/\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-health\nnpx cap sync\n```\n\n## iOS Setup\n\n1. Open your Capacitor application's Xcode workspace and enable the **HealthKit** capability.\n2. Provide usage descriptions in `Info.plist` (update the copy for your product):\n\n```xml\n\u003ckey\u003eNSHealthShareUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app reads your health data to personalise your experience.\u003c/string\u003e\n\u003ckey\u003eNSHealthUpdateUsageDescription\u003c/key\u003e\n\u003cstring\u003eThis app writes new health entries that you explicitly create.\u003c/string\u003e\n```\n\n## Android Setup\n\nThis plugin now uses [Health Connect](https://developer.android.com/health-and-fitness/guides/health-connect) instead of Google Fit. Make sure your app meets the requirements below:\n\n1. **Min SDK 26+.** Health Connect is only available on Android 8.0 (API 26) and above. The plugin's Gradle setup already targets this level.\n2. **Declare Health permissions.** The plugin manifest ships with the required `\u003cuses-permission\u003e` declarations for basic data types (`READ_/WRITE_STEPS`, `READ_/WRITE_DISTANCE`, `READ_/WRITE_ACTIVE_CALORIES_BURNED`, `READ_/WRITE_HEART_RATE`, `READ_/WRITE_WEIGHT`, `READ_/WRITE_SLEEP`, `READ_/WRITE_RESPIRATORY_RATE`, `READ_/WRITE_OXYGEN_SATURATION`, `READ_/WRITE_RESTING_HEART_RATE`, `READ_/WRITE_HEART_RATE_VARIABILITY`). Your app does not need to duplicate them, but you must surface a user-facing rationale because the permissions are considered health sensitive.\n3. **Ensure Health Connect is installed.** Devices on Android 14+ include it by default. For earlier versions the user must install _Health Connect by Android_ from the Play Store. The `Health.isAvailable()` helper exposes the current status so you can prompt accordingly.\n4. **Request runtime access.** The plugin opens the Health Connect permission UI when you call `requestAuthorization`. You should still handle denial flows (e.g., show a message if `checkAuthorization` reports missing scopes).\n5. **Provide a Privacy Policy.** Health Connect requires apps to display a privacy policy explaining how health data is used. See the [Privacy Policy Setup](#privacy-policy-setup) section below.\n\nIf you already used Google Fit in your project you can remove the associated dependencies (`play-services-fitness`, `play-services-auth`, OAuth configuration, etc.).\n\n### Privacy Policy Setup\n\nHealth Connect requires your app to provide a privacy policy that explains how you handle health data. When users tap \"Privacy policy\" in the Health Connect permissions dialog, your app must display this information.\n\n**Option 1: HTML file in assets (recommended for simple cases)**\n\nPlace an HTML file at `android/app/src/main/assets/public/privacypolicy.html`:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /\u003e\n    \u003ctitle\u003ePrivacy Policy\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003ePrivacy Policy\u003c/h1\u003e\n    \u003cp\u003eYour privacy policy content here...\u003c/p\u003e\n    \u003ch2\u003eHealth Data\u003c/h2\u003e\n    \u003cp\u003eExplain how you collect, use, and protect health data...\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n**Option 2: Custom URL (recommended for hosted privacy policies)**\n\nAdd a string resource to your app's `android/app/src/main/res/values/strings.xml`:\n\n```xml\n\u003cresources\u003e\n    \u003c!-- Your other strings... --\u003e\n    \u003cstring name=\"health_connect_privacy_policy_url\"\u003ehttps://yourapp.com/privacy-policy\u003c/string\u003e\n\u003c/resources\u003e\n```\n\nThis URL will be loaded in a WebView when the user requests to see your privacy policy.\n\n**Programmatic access:**\n\nYou can also show the privacy policy or open Health Connect settings from your app:\n\n```ts\n// Show the privacy policy screen\nawait Health.showPrivacyPolicy();\n\n// Open Health Connect settings (useful for managing permissions)\nawait Health.openHealthConnectSettings();\n```\n\n## Usage\n\n```ts\nimport { Health } from '@capgo/capacitor-health';\n\n// Verify that the native health SDK is present on this device\nconst availability = await Health.isAvailable();\nif (!availability.available) {\n  console.warn('Health access unavailable:', availability.reason);\n}\n\n// Ask for separate read/write access scopes\nawait Health.requestAuthorization({\n  read: ['steps', 'heartRate', 'weight'],\n  write: ['weight'],\n});\n\n// Query the last 50 step samples from the past 24 hours\nconst { samples } = await Health.readSamples({\n  dataType: 'steps',\n  startDate: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n  limit: 50,\n});\n\n// Persist a new body-weight entry (kilograms by default)\nawait Health.saveSample({\n  dataType: 'weight',\n  value: 74.3,\n});\n```\n\n### Supported data types\n\n| Identifier              | Default unit  | Notes                                                    |\n| ----------------------- | ------------- | -------------------------------------------------------- |\n| `steps`                 | `count`       | Step count deltas                                        |\n| `distance`              | `meter`       | Walking / running distance                               |\n| `calories`              | `kilocalorie` | Active energy burned                                     |\n| `heartRate`             | `bpm`         | Beats per minute                                         |\n| `weight`                | `kilogram`    | Body mass                                                |\n| `sleep`                 | `minute`      | Sleep sessions with duration and states                  |\n| `respiratoryRate`       | `bpm`         | Breaths per minute                                       |\n| `oxygenSaturation`      | `percent`     | Blood oxygen saturation (SpO2)                           |\n| `restingHeartRate`      | `bpm`         | Resting heart rate                                       |\n| `heartRateVariability`  | `millisecond` | Heart rate variability (HRV)                             |\n| `bloodPressure`         | `mmHg`        | Blood pressure (requires systolic/diastolic values)      |\n| `bloodGlucose`          | `mg/dL`       | Blood glucose level                                      |\n| `bodyTemperature`       | `celsius`     | Body temperature                                         |\n| `height`                | `centimeter`  | Body height                                              |\n| `flightsClimbed`        | `count`       | Floors / flights of stairs climbed                       |\n| `exerciseTime`          | `minute`      | Apple Exercise Time (iOS only)                           |\n| `distanceCycling`       | `meter`       | Cycling distance                                         |\n| `bodyFat`               | `percent`     | Body fat percentage                                      |\n| `basalBodyTemperature`  | `celsius`     | Basal body temperature                                   |\n| `basalCalories`         | `kilocalorie` | Basal metabolic rate / resting energy                    |\n| `totalCalories`         | `kilocalorie` | Total energy burned (active + basal)                     |\n| `mindfulness`           | `minute`      | Mindfulness / meditation sessions                        |\n| `workouts`              | N/A           | Workout sessions (read-only, use with `queryWorkouts()`) |\n\nAll write operations expect the default unit shown above. On Android the `metadata` option is currently ignored by Health Connect.\n\n**Blood Pressure:** Blood pressure requires both systolic and diastolic values:\n\n```ts\nawait Health.saveSample({\n  dataType: 'bloodPressure',\n  value: 120, // systolic value (used as main value)\n  systolic: 120,\n  diastolic: 80,\n  startDate: new Date().toISOString(),\n});\n\n// Reading blood pressure returns samples with systolic/diastolic fields\nconst { samples } = await Health.readSamples({\n  dataType: 'bloodPressure',\n  startDate: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n});\n\nsamples.forEach((sample) =\u003e {\n  console.log(`BP: ${sample.systolic}/${sample.diastolic} mmHg`);\n});\n```\n\n**Note about workouts:** To query workout data using `queryWorkouts()`, you need to explicitly request `workouts` permission:\n\n```ts\nawait Health.requestAuthorization({\n  read: ['steps', 'workouts'], // Include 'workouts' to access workout sessions\n});\n```\n\n**Pagination example:** Use the `anchor` parameter to paginate through workout results:\n\n```ts\n// First page: get the first 10 workouts\nlet result = await Health.queryWorkouts({\n  startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(), // Last 30 days\n  endDate: new Date().toISOString(),\n  limit: 10,\n});\n\nconsole.log(`Found ${result.workouts.length} workouts`);\n\n// If there are more results, the anchor will be set\nwhile (result.anchor) {\n  // Next page: use the anchor to continue from where we left off\n  result = await Health.queryWorkouts({\n    startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),\n    endDate: new Date().toISOString(),\n    limit: 10,\n    anchor: result.anchor, // Continue from the last result\n  });\n\n  console.log(`Found ${result.workouts.length} more workouts`);\n}\n```\n\n### New Data Types Examples\n\n**Sleep data:**\n```ts\n// Request permission for sleep data\nawait Health.requestAuthorization({\n  read: ['sleep'],\n});\n\n// Read sleep sessions from the past week\nconst { samples } = await Health.readSamples({\n  dataType: 'sleep',\n  startDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n});\n\nsamples.forEach(sample =\u003e {\n  console.log(`Sleep: ${sample.value} minutes, state: ${sample.sleepState}`);\n});\n```\n\n**Respiratory rate, oxygen saturation, and HRV:**\n```ts\n// Request permission\nawait Health.requestAuthorization({\n  read: ['respiratoryRate', 'oxygenSaturation', 'restingHeartRate', 'heartRateVariability'],\n});\n\n// Read respiratory rate\nconst { samples: respiratoryRate } = await Health.readSamples({\n  dataType: 'respiratoryRate',\n  startDate: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n});\n\n// Read oxygen saturation (SpO2)\nconst { samples: oxygenSat } = await Health.readSamples({\n  dataType: 'oxygenSaturation',\n  startDate: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n});\n```\n\n### Aggregated Queries\n\nFor large date ranges, use `queryAggregated()` to get aggregated data efficiently instead of fetching individual samples:\n\n```ts\n// Get daily step totals for the past month\nconst { samples } = await Health.queryAggregated({\n  dataType: 'steps',\n  startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n  bucket: 'day',        // Options: 'hour', 'day', 'week', 'month'\n  aggregation: 'sum',   // Options: 'sum', 'average', 'min', 'max'\n});\n\nsamples.forEach(sample =\u003e {\n  console.log(`${sample.startDate}: ${sample.value} ${sample.unit}`);\n});\n\n// Get average heart rate by day\nconst { samples: avgHR } = await Health.queryAggregated({\n  dataType: 'heartRate',\n  startDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),\n  endDate: new Date().toISOString(),\n  bucket: 'day',\n  aggregation: 'average',\n});\n```\n\n**Note:** Aggregated queries are not supported for sleep, respiratory rate, oxygen saturation, and heart rate variability data types. These are instantaneous measurements and should use `readSamples()` instead. Aggregation is supported for: steps, distance, calories, heart rate, weight, and resting heart rate.\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`isAvailable()`](#isavailable)\n* [`requestAuthorization(...)`](#requestauthorization)\n* [`checkAuthorization(...)`](#checkauthorization)\n* [`readSamples(...)`](#readsamples)\n* [`saveSample(...)`](#savesample)\n* [`getPluginVersion()`](#getpluginversion)\n* [`openHealthConnectSettings()`](#openhealthconnectsettings)\n* [`showPrivacyPolicy()`](#showprivacypolicy)\n* [`queryWorkouts(...)`](#queryworkouts)\n* [`queryAggregated(...)`](#queryaggregated)\n* [Interfaces](#interfaces)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### isAvailable()\n\n```typescript\nisAvailable() =\u003e Promise\u003cAvailabilityResult\u003e\n```\n\nReturns whether the current platform supports the native health SDK.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#availabilityresult\"\u003eAvailabilityResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### requestAuthorization(...)\n\n```typescript\nrequestAuthorization(options: AuthorizationOptions) =\u003e Promise\u003cAuthorizationStatus\u003e\n```\n\nRequests read/write access to the provided data types.\n\n| Param         | Type                                                                  |\n| ------------- | --------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#authorizationoptions\"\u003eAuthorizationOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#authorizationstatus\"\u003eAuthorizationStatus\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### checkAuthorization(...)\n\n```typescript\ncheckAuthorization(options: AuthorizationOptions) =\u003e Promise\u003cAuthorizationStatus\u003e\n```\n\nChecks authorization status for the provided data types without prompting the user.\n\n| Param         | Type                                                                  |\n| ------------- | --------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#authorizationoptions\"\u003eAuthorizationOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#authorizationstatus\"\u003eAuthorizationStatus\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### readSamples(...)\n\n```typescript\nreadSamples(options: QueryOptions) =\u003e Promise\u003cReadSamplesResult\u003e\n```\n\nReads samples for the given data type within the specified time frame.\n\n| Param         | Type                                                  |\n| ------------- | ----------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#queryoptions\"\u003eQueryOptions\u003c/a\u003e\u003c/code\u003e |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#readsamplesresult\"\u003eReadSamplesResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### saveSample(...)\n\n```typescript\nsaveSample(options: WriteSampleOptions) =\u003e Promise\u003cvoid\u003e\n```\n\nWrites a single sample to the native health store.\n\n| Param         | Type                                                              |\n| ------------- | ----------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#writesampleoptions\"\u003eWriteSampleOptions\u003c/a\u003e\u003c/code\u003e |\n\n--------------------\n\n\n### getPluginVersion()\n\n```typescript\ngetPluginVersion() =\u003e Promise\u003c{ version: string; }\u003e\n```\n\nGet the native Capacitor plugin version\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ version: string; }\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### openHealthConnectSettings()\n\n```typescript\nopenHealthConnectSettings() =\u003e Promise\u003cvoid\u003e\n```\n\nOpens the Health Connect settings screen (Android only).\nOn iOS, this method does nothing.\n\nUse this to direct users to manage their Health Connect permissions\nor to install Health Connect if not available.\n\n--------------------\n\n\n### showPrivacyPolicy()\n\n```typescript\nshowPrivacyPolicy() =\u003e Promise\u003cvoid\u003e\n```\n\nShows the app's privacy policy for Health Connect (Android only).\nOn iOS, this method does nothing.\n\nThis displays the same privacy policy screen that Health Connect shows\nwhen the user taps \"Privacy policy\" in the permissions dialog.\n\nThe privacy policy URL can be configured by adding a string resource\nnamed \"health_connect_privacy_policy_url\" in your app's strings.xml,\nor by placing an HTML file at www/privacypolicy.html in your assets.\n\n--------------------\n\n\n### queryWorkouts(...)\n\n```typescript\nqueryWorkouts(options: QueryWorkoutsOptions) =\u003e Promise\u003cQueryWorkoutsResult\u003e\n```\n\nQueries workout sessions from the native health store.\nSupported on iOS (HealthKit) and Android (Health Connect).\n\n| Param         | Type                                                                  | Description                                                                             |\n| ------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#queryworkoutsoptions\"\u003eQueryWorkoutsOptions\u003c/a\u003e\u003c/code\u003e | Query options including optional workout type filter, date range, limit, and sort order |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#queryworkoutsresult\"\u003eQueryWorkoutsResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### queryAggregated(...)\n\n```typescript\nqueryAggregated(options: QueryAggregatedOptions) =\u003e Promise\u003cQueryAggregatedResult\u003e\n```\n\nQueries aggregated health data from the native health store.\nAggregates data into time buckets (hour, day, week, month) with operations like sum, average, min, or max.\nThis is more efficient than fetching individual samples for large date ranges.\n\nSupported on iOS (HealthKit) and Android (Health Connect).\n\n| Param         | Type                                                                      | Description                                                                      |\n| ------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#queryaggregatedoptions\"\u003eQueryAggregatedOptions\u003c/a\u003e\u003c/code\u003e | Query options including data type, date range, bucket size, and aggregation type |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#queryaggregatedresult\"\u003eQueryAggregatedResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### Interfaces\n\n\n#### AvailabilityResult\n\n| Prop            | Type                                     | Description                                            |\n| --------------- | ---------------------------------------- | ------------------------------------------------------ |\n| **`available`** | \u003ccode\u003eboolean\u003c/code\u003e                     |                                                        |\n| **`platform`**  | \u003ccode\u003e'ios' \\| 'android' \\| 'web'\u003c/code\u003e | Platform specific details (for debugging/diagnostics). |\n| **`reason`**    | \u003ccode\u003estring\u003c/code\u003e                      |                                                        |\n\n\n#### AuthorizationStatus\n\n| Prop                  | Type                          |\n| --------------------- | ----------------------------- |\n| **`readAuthorized`**  | \u003ccode\u003eHealthDataType[]\u003c/code\u003e |\n| **`readDenied`**      | \u003ccode\u003eHealthDataType[]\u003c/code\u003e |\n| **`writeAuthorized`** | \u003ccode\u003eHealthDataType[]\u003c/code\u003e |\n| **`writeDenied`**     | \u003ccode\u003eHealthDataType[]\u003c/code\u003e |\n\n\n#### AuthorizationOptions\n\n| Prop        | Type                          | Description                                             |\n| ----------- | ----------------------------- | ------------------------------------------------------- |\n| **`read`**  | \u003ccode\u003eHealthDataType[]\u003c/code\u003e | Data types that should be readable after authorization. |\n| **`write`** | \u003ccode\u003eHealthDataType[]\u003c/code\u003e | Data types that should be writable after authorization. |\n\n\n#### ReadSamplesResult\n\n| Prop          | Type                        |\n| ------------- | --------------------------- |\n| **`samples`** | \u003ccode\u003eHealthSample[]\u003c/code\u003e |\n\n\n#### HealthSample\n\n| Prop             | Type                                                      | Description                                                                                  |\n| ---------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------- |\n| **`dataType`**   | \u003ccode\u003e\u003ca href=\"#healthdatatype\"\u003eHealthDataType\u003c/a\u003e\u003c/code\u003e |                                                                                              |\n| **`value`**      | \u003ccode\u003enumber\u003c/code\u003e                                       |                                                                                              |\n| **`unit`**       | \u003ccode\u003e\u003ca href=\"#healthunit\"\u003eHealthUnit\u003c/a\u003e\u003c/code\u003e         |                                                                                              |\n| **`startDate`**  | \u003ccode\u003estring\u003c/code\u003e                                       |                                                                                              |\n| **`endDate`**    | \u003ccode\u003estring\u003c/code\u003e                                       |                                                                                              |\n| **`sourceName`** | \u003ccode\u003estring\u003c/code\u003e                                       |                                                                                              |\n| **`sourceId`**   | \u003ccode\u003estring\u003c/code\u003e                                       |                                                                                              |\n| **`sleepState`** | \u003ccode\u003e\u003ca href=\"#sleepstate\"\u003eSleepState\u003c/a\u003e\u003c/code\u003e         | For sleep data, indicates the sleep state (e.g., 'asleep', 'awake', 'rem', 'deep', 'light'). |\n| **`systolic`**   | \u003ccode\u003enumber\u003c/code\u003e                                       | For blood pressure data, the systolic value in mmHg.                                         |\n| **`diastolic`**  | \u003ccode\u003enumber\u003c/code\u003e                                       | For blood pressure data, the diastolic value in mmHg.                                        |\n\n\n#### QueryOptions\n\n| Prop            | Type                                                      | Description                                                        |\n| --------------- | --------------------------------------------------------- | ------------------------------------------------------------------ |\n| **`dataType`**  | \u003ccode\u003e\u003ca href=\"#healthdatatype\"\u003eHealthDataType\u003c/a\u003e\u003c/code\u003e | The type of data to retrieve from the health store.                |\n| **`startDate`** | \u003ccode\u003estring\u003c/code\u003e                                       | Inclusive ISO 8601 start date (defaults to now - 1 day).           |\n| **`endDate`**   | \u003ccode\u003estring\u003c/code\u003e                                       | Exclusive ISO 8601 end date (defaults to now).                     |\n| **`limit`**     | \u003ccode\u003enumber\u003c/code\u003e                                       | Maximum number of samples to return (defaults to 100).             |\n| **`ascending`** | \u003ccode\u003eboolean\u003c/code\u003e                                      | Return results sorted ascending by start date (defaults to false). |\n\n\n#### WriteSampleOptions\n\n| Prop            | Type                                                            | Description                                                                                                                                                                                       |\n| --------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **`dataType`**  | \u003ccode\u003e\u003ca href=\"#healthdatatype\"\u003eHealthDataType\u003c/a\u003e\u003c/code\u003e       |                                                                                                                                                                                                   |\n| **`value`**     | \u003ccode\u003enumber\u003c/code\u003e                                             |                                                                                                                                                                                                   |\n| **`unit`**      | \u003ccode\u003e\u003ca href=\"#healthunit\"\u003eHealthUnit\u003c/a\u003e\u003c/code\u003e               | Optional unit override. If omitted, the default unit for the data type is used (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`). |\n| **`startDate`** | \u003ccode\u003estring\u003c/code\u003e                                             | ISO 8601 start date for the sample. Defaults to now.                                                                                                                                              |\n| **`endDate`**   | \u003ccode\u003estring\u003c/code\u003e                                             | ISO 8601 end date for the sample. Defaults to startDate.                                                                                                                                          |\n| **`metadata`**  | \u003ccode\u003e\u003ca href=\"#record\"\u003eRecord\u003c/a\u003e\u0026lt;string, string\u0026gt;\u003c/code\u003e | Metadata key-value pairs forwarded to the native APIs where supported.                                                                                                                            |\n| **`systolic`**  | \u003ccode\u003enumber\u003c/code\u003e                                             | For blood pressure data, the systolic value in mmHg. Required when dataType is 'bloodPressure'.                                                                                                   |\n| **`diastolic`** | \u003ccode\u003enumber\u003c/code\u003e                                             | For blood pressure data, the diastolic value in mmHg. Required when dataType is 'bloodPressure'.                                                                                                  |\n\n\n#### QueryWorkoutsResult\n\n| Prop           | Type                   | Description                                                                                                                                                             |\n| -------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **`workouts`** | \u003ccode\u003eWorkout[]\u003c/code\u003e |                                                                                                                                                                         |\n| **`anchor`**   | \u003ccode\u003estring\u003c/code\u003e    | Anchor for the next page of results. Pass this value as the anchor parameter in the next query to continue pagination. If undefined or null, there are no more results. |\n\n\n#### Workout\n\n| Prop                    | Type                                                            | Description                                         |\n| ----------------------- | --------------------------------------------------------------- | --------------------------------------------------- |\n| **`workoutType`**       | \u003ccode\u003e\u003ca href=\"#workouttype\"\u003eWorkoutType\u003c/a\u003e\u003c/code\u003e             | The type of workout.                                |\n| **`duration`**          | \u003ccode\u003enumber\u003c/code\u003e                                             | Duration of the workout in seconds.                 |\n| **`totalEnergyBurned`** | \u003ccode\u003enumber\u003c/code\u003e                                             | Total energy burned in kilocalories (if available). |\n| **`totalDistance`**     | \u003ccode\u003enumber\u003c/code\u003e                                             | Total distance in meters (if available).            |\n| **`startDate`**         | \u003ccode\u003estring\u003c/code\u003e                                             | ISO 8601 start date of the workout.                 |\n| **`endDate`**           | \u003ccode\u003estring\u003c/code\u003e                                             | ISO 8601 end date of the workout.                   |\n| **`sourceName`**        | \u003ccode\u003estring\u003c/code\u003e                                             | Source name that recorded the workout.              |\n| **`sourceId`**          | \u003ccode\u003estring\u003c/code\u003e                                             | Source bundle identifier.                           |\n| **`metadata`**          | \u003ccode\u003e\u003ca href=\"#record\"\u003eRecord\u003c/a\u003e\u0026lt;string, string\u0026gt;\u003c/code\u003e | Additional metadata (if available).                 |\n\n\n#### QueryWorkoutsOptions\n\n| Prop              | Type                                                | Description                                                                                                                                                                                                                           |\n| ----------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **`workoutType`** | \u003ccode\u003e\u003ca href=\"#workouttype\"\u003eWorkoutType\u003c/a\u003e\u003c/code\u003e | Optional workout type filter. If omitted, all workout types are returned.                                                                                                                                                             |\n| **`startDate`**   | \u003ccode\u003estring\u003c/code\u003e                                 | Inclusive ISO 8601 start date (defaults to now - 1 day).                                                                                                                                                                              |\n| **`endDate`**     | \u003ccode\u003estring\u003c/code\u003e                                 | Exclusive ISO 8601 end date (defaults to now).                                                                                                                                                                                        |\n| **`limit`**       | \u003ccode\u003enumber\u003c/code\u003e                                 | Maximum number of workouts to return (defaults to 100).                                                                                                                                                                               |\n| **`ascending`**   | \u003ccode\u003eboolean\u003c/code\u003e                                | Return results sorted ascending by start date (defaults to false).                                                                                                                                                                    |\n| **`anchor`**      | \u003ccode\u003estring\u003c/code\u003e                                 | Anchor for pagination. Use the anchor returned from a previous query to continue from that point. On iOS, this uses HKQueryAnchor. On Android, this uses Health Connect's pageToken. Omit this parameter to start from the beginning. |\n\n\n#### QueryAggregatedResult\n\n| Prop          | Type                            |\n| ------------- | ------------------------------- |\n| **`samples`** | \u003ccode\u003eAggregatedSample[]\u003c/code\u003e |\n\n\n#### AggregatedSample\n\n| Prop            | Type                                              | Description                        |\n| --------------- | ------------------------------------------------- | ---------------------------------- |\n| **`startDate`** | \u003ccode\u003estring\u003c/code\u003e                               | ISO 8601 start date of the bucket. |\n| **`endDate`**   | \u003ccode\u003estring\u003c/code\u003e                               | ISO 8601 end date of the bucket.   |\n| **`value`**     | \u003ccode\u003enumber\u003c/code\u003e                               | Aggregated value for the bucket.   |\n| **`unit`**      | \u003ccode\u003e\u003ca href=\"#healthunit\"\u003eHealthUnit\u003c/a\u003e\u003c/code\u003e | Unit of the aggregated value.      |\n\n\n#### QueryAggregatedOptions\n\n| Prop              | Type                                                        | Description                                              |\n| ----------------- | ----------------------------------------------------------- | -------------------------------------------------------- |\n| **`dataType`**    | \u003ccode\u003e\u003ca href=\"#healthdatatype\"\u003eHealthDataType\u003c/a\u003e\u003c/code\u003e   | The type of data to aggregate from the health store.     |\n| **`startDate`**   | \u003ccode\u003estring\u003c/code\u003e                                         | Inclusive ISO 8601 start date (defaults to now - 1 day). |\n| **`endDate`**     | \u003ccode\u003estring\u003c/code\u003e                                         | Exclusive ISO 8601 end date (defaults to now).           |\n| **`bucket`**      | \u003ccode\u003e\u003ca href=\"#buckettype\"\u003eBucketType\u003c/a\u003e\u003c/code\u003e           | Time bucket for aggregation (defaults to 'day').         |\n| **`aggregation`** | \u003ccode\u003e\u003ca href=\"#aggregationtype\"\u003eAggregationType\u003c/a\u003e\u003c/code\u003e | Aggregation operation to perform (defaults to 'sum').    |\n\n\n### Type Aliases\n\n\n#### HealthDataType\n\n\u003ccode\u003e'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep' | 'respiratoryRate' | 'oxygenSaturation' | 'restingHeartRate' | 'heartRateVariability' | 'bloodPressure' | 'bloodGlucose' | 'bodyTemperature' | 'height' | 'flightsClimbed' | 'exerciseTime' | 'distanceCycling' | 'bodyFat' | 'basalBodyTemperature' | 'basalCalories' | 'totalCalories' | 'mindfulness'\u003c/code\u003e\n\n\n#### HealthUnit\n\n\u003ccode\u003e'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute' | 'percent' | 'millisecond' | 'mmHg' | 'mg/dL' | 'celsius' | 'fahrenheit' | 'centimeter'\u003c/code\u003e\n\n\n#### SleepState\n\n\u003ccode\u003e'inBed' | 'asleep' | 'awake' | 'rem' | 'deep' | 'light'\u003c/code\u003e\n\n\n#### Record\n\nConstruct a type with a set of properties K of type T\n\n\u003ccode\u003e{\r [P in K]: T;\r }\u003c/code\u003e\n\n\n#### WorkoutType\n\n\u003ccode\u003e'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'archery' | 'australianFootball' | 'badminton' | 'barre' | 'bowling' | 'boxing' | 'climbing' | 'cooldown' | 'coreTraining' | 'cricket' | 'crossCountrySkiing' | 'curling' | 'dance' | 'discSports' | 'downhillSkiing' | 'equestrianSports' | 'fencing' | 'fishing' | 'fitnessGaming' | 'flexibility' | 'functionalStrengthTraining' | 'golf' | 'gymnastics' | 'handball' | 'handCycling' | 'highIntensityIntervalTraining' | 'hockey' | 'hunting' | 'jumpRope' | 'kickboxing' | 'lacrosse' | 'martialArts' | 'mindAndBody' | 'mixedCardio' | 'paddleSports' | 'pickleball' | 'pilates' | 'play' | 'preparationAndRecovery' | 'racquetball' | 'rugby' | 'sailing' | 'skatingSports' | 'snowboarding' | 'snowSports' | 'softball' | 'squash' | 'stairs' | 'stepTraining' | 'surfingSports' | 'tableTennis' | 'taiChi' | 'trackAndField' | 'transition' | 'underwaterDiving' | 'volleyball' | 'wheelchairRunPace' | 'wheelchairWalkPace' | 'cardioDance' | 'socialDance' | 'other'\u003c/code\u003e\n\n\n#### BucketType\n\n\u003ccode\u003e'hour' | 'day' | 'week' | 'month'\u003c/code\u003e\n\n\n#### AggregationType\n\n\u003ccode\u003e'sum' | 'average' | 'min' | 'max'\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n\n### Credits:\n\nthis plugin was inspired by the work of https://github.com/perfood/capacitor-healthkit/ for ios and https://github.com/perfood/capacitor-google-fit for Android\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-health","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-go%2Fcapacitor-health","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-health/lists"}