Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
A DataCollector can be used to collect the raw data from sensors or derived data (after being converted or combined).
This method is used to create a data collector. The ID of the data collector combines certain fields in the request body based on specific rules and is unique among all data collectors of this user.
A sensor can collect data of one or more dimensions. Multiple DataCollectors need to be created for multiple dimensions. Each DataCollector corresponds to a single dimension.
For data types for which DataCollector can be created, please refer to daily activity data, health sampling data, and health record data.
| Protocol | HTTPS POST |
|---|---|
| Direction | App > Health Service Kit cloud |
| URL | https://health-api.cloud.huawei.com/healthkit/v2/dataCollectors |
| Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Request Header
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| Content-type | String | Yes | Value: application/json; charset=UTF-8 |
| Authorization | String | Yes | For details, see Authentication. NOTE A space character must be added between Bearer and the value of access_token. |
| x-client-id | String | No | App ID allocated by HUAWEI Developers. The server can perform gray routing based on this parameter. It is recommended that this parameter be carried. |
| x-version | String | No | Software version number of the app calling the API, that is, the version number of the current client. The server can perform gray release based on this parameter. It is recommended that this parameter be carried. |
| x-caller-trace-id | String | No | Request tracing ID, which is used to connect the entire request chain between the service calling party and server. It is recommended that this parameter be carried. |
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| collectorType | String | Yes | Type of the data collector. The value can be:
|
| appInfo | AppInfo | Yes | App information of the data collector. For details, please refer to AppInfo data model. |
| collectorDataType | DataType | Yes | Data type. For details, please refer to DataType data model. |
| collectorId | String | No | Unique ID of the data collector. It is generated with certain fields in the request body based on specified rules. |
| collectorName | String | No | Name used to internally identify a data collector created for a certain data type by the user. |
| name | String | No | Data collector's name to display in your app. |
| deviceInfo | DeviceInfo | No | Description of the hardware device that integrates various sensors, such as a watch, a band, or any other wearable devices. For details, please refer to DeviceInfo data model. |
POST
https://health-api.cloud.huawei.com/healthkit/v2/dataCollectors
Content-Type: application/json
Authorization: Bearer ***
x-client-id: ***
x-version: ***
x-caller-trace-id: ***
{
"collectorName": "DataCollectorExample",
"collectorType": "raw",
"appInfo": {
"appPackageName": "com.huawei.demo",
"appName": "Example App",
"desc": "https://huaweiapi.com",
"appVersion": "1"
},
"collectorDataType": {
"name": "com.huawei.continuous.steps.delta"
},
"deviceInfo": {
"manufacturer": "huawei",
"modelNum": "ExampleTablet",
"devType": "Phone",
"uniqueId": "1000",
"version": "1.0"
}
} When the status code is 200:
Response Header
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| Content-Type | String | Yes | Value: application/json; charset=UTF-8 |
Response Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| collectorType | String | Yes | Type of the data collector. The value can be:
|
| appInfo | AppInfo | Yes | App information of the data collector. For details, please refer to AppInfo data model. |
| collectorDataType | DataType | Yes | Data type. For details, please refer to DataType data model. |
| collectorId | String | No | Unique ID of the data collector. It is generated with certain fields in the request body based on specified rules. |
| collectorName | String | No | Internal ID. The name is used to identify a data collector created for a certain data type by the user. |
| name | String | No | Data collector's name to display in your app. |
| deviceInfo | DeviceInfo | No | Description of the hardware device that integrates various sensors, such as a watch, a band, or any other wearable devices. For details, please refer to DeviceInfo data model. |
HTTP/1.1 200 OK
Content-type: application/json;charset=utf-8
{
"collectorId": "cmF3OmNvbnRpbnVvdXMuc3RlcHMuZGVsdGE6EwMTI3ODUwMTpqEF7rB3uBcGykpv6T2TisfTMhfZAvz1BP2Kcz70d1Sg",
"collectorName": "DataCollectorExample",
"collectorType": "raw",
"collectorDataType": {
"name": "com.huawei.continuous.steps.delta",
"field": [
{
"name": "steps_delta",
"format": "integer"
}
]
},
"deviceInfo": {
"uniqueId": "1000",
"devType": "Phone",
"version": "1.0",
"modelNum": "ExampleTablet",
"manufacturer": "huawei"
},
"appInfo": {
"appName": "Example App",
"appPackageName": "com.huawei.demo",
"appVersion": "1",
"desc": "https://huaweiapi.com",
"clientId": "101222525"
}
} For details, see Result Codes.