Your app can record blood pressure data by writing to the com.google.blood_pressure
data type. In this data type, each data point represents a single instantaneous
blood pressure reading. The data point contains fields for the systolic and
diastolic pressure, body position during the reading, and location on the body
where the measurement was performed.
- The
systolic
anddiastolic
fields are required, all others are optional. - Pressures for
systolic
(upper number) anddiastolic
(lower number) are measured in mmHg. - If specified, body position must have one of the following values:
1
- standing up2
- sitting down3
- lying down4
- semi-reclined
If specified, measurement location must have one of the following values:
1
- left wrist2
- right wrist3
- left upper arm4
- right upper arm
Android
To write a blood pressure data point, create a new DataSource
of TYPE_BLOOD_PRESSURE
,
as shown in the following example.
val bloodPressureSource = DataSource.Builder()
.setDataType(TYPE_BLOOD_PRESSURE)
// ...
.build()
val bloodPressure = DataPoint.builder(bloodPressureSource)
.setTimestamp(timestamp, TimeUnit.MILLISECONDS)
.setField(FIELD_BLOOD_PRESSURE_SYSTOLIC, 120.0f)
.setField(FIELD_BLOOD_PRESSURE_DIASTOLIC, 80.0f)
.setField(FIELD_BODY_POSITION, BODY_POSITION_SITTING)
.setField(
FIELD_BLOOD_PRESSURE_MEASUREMENT_LOCATION,
BLOOD_PRESSURE_MEASUREMENT_LOCATION_LEFT_UPPER_ARM)
.build()
REST
Create a data source
To write a blood pressure data point, create a new data data source
HTTP method
POST
Request URL
https://www.googleapis.com/fitness/v1/users/me/dataSources
Request body
{
"dataStreamName": "BloodPressure",
"type": "raw",
"application": {
"detailsUrl": "http://example.com",
"name": "My Example App",
"version": "1"
},
"dataType": {
"name": "com.google.blood_pressure"
}
}
Response
If your data source was created successfully, you'll get a 200 OK
HTTP
response status code. The response body contains a JSON representation of
the data source, including a datasource.dataStreamId
property. Use this ID
as the dataSourceId
to add data.
Add blood pressure data
Add data by creating a data point of type com.google.blood_pressure
.
HTTP method
PATCH
Request URL
https://www.googleapis.com/fitness/v1/users/me/dataSources/datasource.dataStreamId/datasets/1574159699023000000-1574159699023000000
Request body
For clarity the JSON body shown below is annotated with comments, to show the use of health field constants.
{
"dataSourceId": "datasource.dataStreamId",
"maxEndTimeNs": 1574159699023000000,
"minStartTimeNs": 1574159699023000000,
"point": [
{
"dataTypeName": "com.google.blood_pressure",
"endTimeNanos": 1574159699023000000,
"startTimeNanos": 1574159699023000000,
"value": [
{
"fpVal": 120.0 // systolic
},
{
"fpVal": 80.0 // diastolic
},
{
"intVal": 2 // Body position enum value for sitting
},
{
"intVal": 3 // Location enum value for left upper arm
}
]
}
]
}