0

I am using the Google Fit REST API to retrieve blood pressure data from the user's Google Fit account. I am able to successfully make a request to the API endpoint https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate and receive a response. However, I am having difficulty understanding how to extract the blood pressure values from the response and differentiate between systolic and diastolic readings.

{
  "bucket": [
    {
      "startTimeMillis": "1686076220000",
      "endTimeMillis": "1686137004070",
      "dataset": [
        {
          "dataSourceId": "derived:com.google.blood_pressure.summary:com.google.android.gms:aggregated",
          "point": [
            {
              "startTimeNanos": "1686130860000000000",
              "originDataSourceId": "raw:com.google.blood_pressure:com.google.android.apps.fitness:user_input",
              "endTimeNanos": "1686132720000000000",
              "value": [
                {
                  "mapVal": [],
                  "fpVal": 120.5
                },
                {
                  "mapVal": [],
                  "fpVal": 121
                },
                {
                  "mapVal": [],
                  "fpVal": 120
                },
                {
                  "mapVal": [],
                  "fpVal": 84.5
                },
                {
                  "mapVal": [],
                  "fpVal": 89
                },
                {
                  "mapVal": [],
                  "fpVal": 80
                },
                {
                  "mapVal": []
                },
                {
                  "mapVal": []
                }
              ],
              "dataTypeName": "com.google.blood_pressure.summary"
            }
          ]
        }
      ]
    }
  ]
}

I would like to extract the systolic and diastolic blood pressure values from the response, where the systolic value is higher and the diastolic value is lower. In the provided example, my Google Fit app shows two entries with values 120/80 and 121/89.

How can I correctly parse the response data to fetch the appropriate systolic and diastolic values?

Any guidance or code examples would be greatly appreciated. Thank you!

1 Answer 1

0

https://developers.google.com/fit/scenarios/write-bp-data it is in the documentation.

I also suggest that you migrate to Google's new API, Health Connect. It also supports blood pressure record.

https://developer.android.com/guide/health-and-fitness/health-connect https://developer.android.com/guide/health-and-fitness/health-connect/data-and-data-types/data-types https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/package-summary#classes

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.