The following describes how to obtain the user's gender, date of birth, height, and weight defined in Me > Profile in the Huawei Health app.

Before using any of the following APIs, make sure that you have both obtained the related scopes from Huawei and been granted the scopes by users. Otherwise, the API calling will fail.
| Data Openness Type | Query API | Scope Requested from Users | Scope Requested from Huawei |
|---|---|---|---|
| Gender | https://www.huawei.com/healthkit/extend/healthbehavior.read | Scope to read personal information data | |
| Date of birth | |||
| Height | |||
| Weight |
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getGender().then((result) => {
console.info("getGender success: " + JSON.stringify(result))
}).catch((error) => {
console.error("getGender Error: " + JSON.stringify(error));
}); | Parameter | Type | Description |
|---|---|---|
| result | String |
|
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getBirthday().then((result) => {
console.info("getBirthday success: " + JSON.stringify(result))
}).catch((error) => {
console.error("getBirthday Error: " + JSON.stringify(error));
}); | Parameter | Type | Description |
|---|---|---|
| result | String |
|
Call getHeight to obtain the height as follows:
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getHeight().then((result) => {
console.info("getHeight success: " + JSON.stringify(result))
}).catch((error) => {
console.error("getHeight Error: " + JSON.stringify(error));
}); | Parameter | Type | Description |
|---|---|---|
| result | String |
|
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getWeight().then((result) => {
console.info("getWeight success: " + JSON.stringify(result))
}).catch((error) => {
console.error("getWeight Error: " + JSON.stringify(error));
});