寫入血壓資料
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
應用程式可寫入 com.google.blood_pressure
來記錄血壓資料
以及資料類型在這個資料類型中,每個資料點都代表一個瞬間
血壓讀數。資料點包含收縮壓、
舒張壓、讀音期間的身體位置和身體位置
執行測量的位置
systolic
和 diastolic
為必填欄位,其他欄位則為選填。
systolic
(最大值) 和 diastolic
(低於數字) 的壓力為
測量單位
- 如有指定,主體位置必須為下列其中一個值:
1
- 站立
2
- 坐下
3
- 躺下
4
- 半斜體
如有指定,測量位置的值必須是下列其中一個值:
1
- 左手腕
2
- 右手腕
3
- 左上臂
4
- 右上臂
Android
如要寫入血壓資料點,請建立新的 DataSource
/TYPE_BLOOD_PRESSURE
,
如以下範例所示
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
建立資料來源
如要寫入血壓資料點,請建立新的資料來源
HTTP 方法
POST
要求網址
https://www.googleapis.com/fitness/v1/users/me/dataSources
要求主體
{
"dataStreamName": "BloodPressure",
"type": "raw",
"application": {
"detailsUrl": "http://example.com",
"name": "My Example App",
"version": "1"
},
"dataType": {
"name": "com.google.blood_pressure"
}
}
回應
如果資料來源建立成功,您會收到 200 OK
HTTP
回應狀態碼。回應主體包含的 JSON 表示法
資料來源,包括 datasource.dataStreamId
資源。使用此 ID
做為新增資料的 dataSourceId
。
新增血壓資料
建立 com.google.blood_pressure
類型的資料點,即可新增資料。
HTTP 方法
PATCH
要求網址
https://www.googleapis.com/fitness/v1/users/me/dataSources/datasource.dataStreamId/datasets/1574159699023000000-1574159699023000000
要求主體
為求明確,以下顯示的 JSON 內文會附帶註解,以便顯示
健康狀態欄位常數
{
"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
}
]
}
]
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eGoogle Fit allows recording blood pressure data using the \u003ccode\u003ecom.google.blood_pressure\u003c/code\u003e data type, including systolic and diastolic values, body position, and measurement location.\u003c/p\u003e\n"],["\u003cp\u003eRequired fields for blood pressure data are \u003ccode\u003esystolic\u003c/code\u003e and \u003ccode\u003ediastolic\u003c/code\u003e pressure, measured in mmHg.\u003c/p\u003e\n"],["\u003cp\u003eBody position and measurement location can optionally be specified using predefined enum values.\u003c/p\u003e\n"],["\u003cp\u003eYou can write blood pressure data points on Android using the Google Fit API and on the REST API by creating a data source and adding data points.\u003c/p\u003e\n"]]],[],null,["# Write Blood Pressure Data\n\n| **Note:** Because health data is potentially sensitive, Google Fit [restricts read / write access to health data types](/fit/datatypes/restricted).\n\nYour app can record blood pressure data by writing to the `com.google.blood_pressure`\ndata type. In this data type, each data point represents a single instantaneous\nblood pressure reading. The data point contains fields for the systolic and\ndiastolic pressure, body position during the reading, and location on the body\nwhere the measurement was performed.\n\n- The `systolic` and `diastolic` fields are required, all others are optional.\n- Pressures for `systolic` (upper number) and `diastolic` (lower number) are measured in mmHg.\n- If specified, body position must have one of the following values:\n - `1` - standing up\n - `2` - sitting down\n - `3` - lying down\n - `4` - semi-reclined\n- If specified, measurement location must have one of the following values:\n\n - `1` - left wrist\n - `2` - right wrist\n - `3` - left upper arm\n - `4` - right upper arm\n\n### Android\n\nTo write a blood pressure data point, create a new [`DataSource`](/android/reference/com/google/android/gms/fitness/data/DataSource)\nof [`TYPE_BLOOD_PRESSURE`](/android/reference/com/google/android/gms/fitness/data/HealthDataTypes#TYPE_BLOOD_PRESSURE),\nas shown in the following example. \n\n val bloodPressureSource = DataSource.Builder()\n .setDataType(TYPE_BLOOD_PRESSURE)\n // ...\n .build()\n\n val bloodPressure = DataPoint.builder(bloodPressureSource)\n .setTimestamp(timestamp, TimeUnit.MILLISECONDS)\n .setField(FIELD_BLOOD_PRESSURE_SYSTOLIC, 120.0f)\n .setField(FIELD_BLOOD_PRESSURE_DIASTOLIC, 80.0f)\n .setField(FIELD_BODY_POSITION, BODY_POSITION_SITTING)\n .setField(\n FIELD_BLOOD_PRESSURE_MEASUREMENT_LOCATION,\n BLOOD_PRESSURE_MEASUREMENT_LOCATION_LEFT_UPPER_ARM)\n .build()\n\n### REST\n\nCreate a data source\n--------------------\n\nTo write a blood pressure data point, create a new data data source\n\n**HTTP method** \n\n POST\n\n**Request URL** \n\n```html\nhttps://www.googleapis.com/fitness/v1/users/me/dataSources\n```\n\n**Request body** \n\n {\n \"dataStreamName\": \"BloodPressure\",\n \"type\": \"raw\",\n \"application\": {\n \"detailsUrl\": \"http://example.com\",\n \"name\": \"My Example App\",\n \"version\": \"1\"\n },\n \"dataType\": {\n \"name\": \"com.google.blood_pressure\"\n }\n }\n\n**Response**\n\nIf your data source was created successfully, you'll get a [`200 OK`](https://httpstatuses.com/200) HTTP\nresponse status code. The response body contains a JSON representation of\nthe data source, including a `datasource.dataStreamId` property. Use this ID\nas the `dataSourceId` to add data.\n\nAdd blood pressure data\n-----------------------\n\nAdd data by creating a data point of type `com.google.blood_pressure`.\n\n**HTTP method** \n\n PATCH\n\n**Request URL** \n\n```html\nhttps://www.googleapis.com/fitness/v1/users/me/dataSources/datasource.dataStreamId/datasets/1574159699023000000-1574159699023000000\n```\n\n**Request body**\n\nFor clarity the JSON body shown below is annotated with comments, to show\nthe use of health field constants. \n\n {\n \"dataSourceId\": \"datasource.dataStreamId\",\n \"maxEndTimeNs\": 1574159699023000000,\n \"minStartTimeNs\": 1574159699023000000,\n \"point\": [\n {\n \"dataTypeName\": \"com.google.blood_pressure\",\n \"endTimeNanos\": 1574159699023000000,\n \"startTimeNanos\": 1574159699023000000,\n \"value\": [\n {\n \"fpVal\": 120.0 // systolic\n },\n {\n \"fpVal\": 80.0 // diastolic\n },\n {\n \"intVal\": 2 // Body position enum value for sitting\n },\n {\n \"intVal\": 3 // Location enum value for left upper arm\n }\n ]\n }\n ]\n }"]]