npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@devmaxime/capacitor-health-connect

v1.1.0

Published

Capacitor plugin to interact with Health Connect

Downloads

88

Readme

Capacitor plugin to interact with Android Health Connect.

Install

npm install @devmaxime/capacitor-health-connect
npx cap sync

Add the following to your app's AndroidManifest.xml:

<queries>
   <package android:name="com.google.android.apps.healthdata" />
</queries>

Also add this to your AndroidManifest.xml:

<application>
...
    <activity>
    ...

        <!-- Permission handling for Android 13 and before -->
        <intent-filter>
            <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
        </intent-filter>

        <!-- Permission handling for Android 14 and later -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/>
            <category android:name="android.intent.category.HEALTH_PERMISSIONS"/>
        </intent-filter>

    ...
    </activity>
</application>

Permissions

You also need to add permissions for the records you want to read and/or write to the AndroidManifest.xml. A complete list of available records and the corresponding permissions can be found here.

<!-- Example permissions -->
<uses-permission android:name="android.permission.health.READ_STEPS"/>
<uses-permission android:name="android.permission.health.WRITE_STEPS"/>
<uses-permission android:name="android.permission.health.READ_EXERCISE"/>
<uses-permission android:name="android.permission.health.WRITE_EXERCISE"/>

API

checkAvailability()

checkAvailability() => Promise<{ availability: HealthConnectAvailability; }>

Returns: Promise<{ availability: HealthConnectAvailability; }>


requestPermissions(...)

requestPermissions(options: { read: RecordType[]; write: RecordType[]; }) => Promise<PermissionsResponse>

| Param | Type | | ------------- | --------------------------------------------------------- | | options | { read: RecordType[]; write: RecordType[]; } |

Returns: Promise<PermissionsResponse>


getGrantedPermissions()

getGrantedPermissions() => Promise<PermissionsResponse>

Returns: Promise<PermissionsResponse>


revokePermissions()

revokePermissions() => Promise<void>

readRecords(...)

readRecords(options: { start: string; end: string; type: RecordType; pageSize?: number; pageToken?: string; }) => Promise<ReadRecordsResponse>

Reads records of the specified type within a time range.

When pageToken is not provided, automatic pagination is used to retrieve ALL records within the specified time range. This may take longer for large datasets but ensures complete data retrieval.

When pageToken is provided, manual pagination is used and only a single page of results is returned along with a nextPageToken for retrieving subsequent pages.

| Param | Type | | ------------- | ------------------------------------------------------------------------------------------------------------------------------- | | options | { start: string; end: string; type: RecordType; pageSize?: number; pageToken?: string; } |

Returns: Promise<ReadRecordsResponse>


aggregateRecords(...)

aggregateRecords(options: { start: string; end: string; type: AggregateRecordType; groupBy?: AggregateGroupBy; }) => Promise<AggregateResponse>

Aggregates records of the specified type within a time range. Returns aggregated data grouped by the specified time period (e.g., daily totals).

| Param | Type | | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | options | { start: string; end: string; type: AggregateRecordType; groupBy?: AggregateGroupBy; } |

Returns: Promise<AggregateResponse>


Interfaces

PermissionsResponse

| Prop | Type | | ----------- | ------------------------- | | read | RecordType[] | | write | RecordType[] |

ReadRecordsResponse

Response from reading health records.

When using automatic pagination (no pageToken provided), all records are returned and nextPageToken will be undefined.

When using manual pagination (pageToken provided), nextPageToken will contain the token for the next page, or undefined if this is the last page.

| Prop | Type | | ------------------- | ------------------- | | records | any[] | | nextPageToken | string |

AggregateResponse

Response from aggregating health records. Contains aggregated data grouped by time periods.

| Prop | Type | | ---------------- | ---------------------------- | | aggregates | AggregateData[] |

AggregateData

Aggregated data for a specific time period.

| Prop | Type | | --------------- | ------------------- | | startTime | string | | endTime | string | | value | number | | unit | string |

Type Aliases

HealthConnectAvailability

'Available' | 'NotSupported' | 'NotInstalled'

RecordType

'Steps' | 'Weight' | 'ActivitySession' | 'SleepSession' | 'RestingHeartRate'

AggregateRecordType

'Steps' | 'Distance' | 'TotalCaloriesBurned' | 'ActiveCaloriesBurned' | 'HeartRate'

AggregateGroupBy

'day' | 'hour' | 'week' | 'month'

Available records in Android Health Connect TODO: add this to the docs.

ActiveCaloriesBurned -> class androidx.health.connect.client.records.ActiveCaloriesBurnedRecord ActivitySession -> class androidx.health.connect.client.records.ExerciseSessionRecord BasalBodyTemperature -> class androidx.health.connect.client.records.BasalBodyTemperatureRecord BasalMetabolicRate -> class androidx.health.connect.client.records.BasalMetabolicRateRecord BloodGlucose -> class androidx.health.connect.client.records.BloodGlucoseRecord BloodPressure -> class androidx.health.connect.client.records.BloodPressureRecord BodyFat -> class androidx.health.connect.client.records.BodyFatRecord BodyTemperature -> class androidx.health.connect.client.records.BodyTemperatureRecord BodyWaterMass -> class androidx.health.connect.client.records.BodyWaterMassRecord BoneMass -> class androidx.health.connect.client.records.BoneMassRecord CervicalMucus -> class androidx.health.connect.client.records.CervicalMucusRecord CyclingPedalingCadenceSeries -> class androidx.health.connect.client.records.CyclingPedalingCadenceRecord Distance -> class androidx.health.connect.client.records.DistanceRecord ElevationGained -> class androidx.health.connect.client.records.ElevationGainedRecord FloorsClimbed -> class androidx.health.connect.client.records.FloorsClimbedRecord HeartRateSeries -> class androidx.health.connect.client.records.HeartRateRecord HeartRateVariabilityRmssd -> class androidx.health.connect.client.records.HeartRateVariabilityRmssdRecord Height -> class androidx.health.connect.client.records.HeightRecord Hydration -> class androidx.health.connect.client.records.HydrationRecord LeanBodyMass -> class androidx.health.connect.client.records.LeanBodyMassRecord Menstruation -> class androidx.health.connect.client.records.MenstruationFlowRecord MenstruationPeriod -> class androidx.health.connect.client.records.MenstruationPeriodRecord Nutrition -> class androidx.health.connect.client.records.NutritionRecord OvulationTest -> class androidx.health.connect.client.records.OvulationTestRecord OxygenSaturation -> class androidx.health.connect.client.records.OxygenSaturationRecord PowerSeries -> class androidx.health.connect.client.records.PowerRecord RespiratoryRate -> class androidx.health.connect.client.records.RespiratoryRateRecord RestingHeartRate -> class androidx.health.connect.client.records.RestingHeartRateRecord SexualActivity -> class androidx.health.connect.client.records.SexualActivityRecord SkinTemperature -> class androidx.health.connect.client.records.SkinTemperatureRecord SleepSession -> class androidx.health.connect.client.records.SleepSessionRecord SpeedSeries -> class androidx.health.connect.client.records.SpeedRecord IntermenstrualBleeding -> class androidx.health.connect.client.records.IntermenstrualBleedingRecord Steps -> class androidx.health.connect.client.records.StepsRecord StepsCadenceSeries -> class androidx.health.connect.client.records.StepsCadenceRecord TotalCaloriesBurned -> class androidx.health.connect.client.records.TotalCaloriesBurnedRecord Vo2Max -> class androidx.health.connect.client.records.Vo2MaxRecord WheelchairPushes -> class androidx.health.connect.client.records.WheelchairPushesRecord Weight -> class androidx.health.connect.client.records.WeightRecord

Initially forked from @sprintwerk/capacitor-android-health-connect