Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read BloodPressure and BloodGlucose dataSource from google api fitness playground

If I go to google api playground I do the following steps:

Step 1: Select & authorize APIs. I select the two scopes

  1. https://www.googleapis.com/auth/fitness.blood_glucose.read
  2. https://www.googleapis.com/auth/fitness.blood_pressure.read

cause I need to read blood glucose and pressure from user.

I select a google user and authorize the application to read the data.

Step 2: Exchange authorization code for tokens. I exchange the authorization token for the access and refresh token.

Step 3: Configure request to API. From List possible operations I choose DataSources UsersLists all data sources that are visible to the developer, using the OAuth scopes provided. The list is not exhaustive; the user may have private data sources that are only visible to other developers, or calls using other scopes. Request: GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources

I change {userId} with me and I suppose to retrieve the data source to read blood glucose and blood pressure, but what I receive is an empty array. { "dataSource": [] }

I need to test the reading of such values (pressure and glucose). What steps do I have to in google playground to achieve these 2 readings?

Thanks in advance

like image 894
Zu1779 Avatar asked Jan 31 '18 14:01

Zu1779


People also ask

Can you check blood pressure with Google Fit?

Qardio users with Android devices can now connect their Qardio accounts and automatically send all of their QardioArm blood pressure measurements to Google Fit. This will provide an even more connected experience as QardioBase and QardioBase 2 are already integrated with Google Fit.

How does Google Fit read data?

Read daily total data Google Fit also provides simple access to the daily total of a specified data type. Use the HistoryClient. readDailyTotal() method to retrieve the data type that you specify as of midnight of the current day in the device's current timezone.

What data does Google Fit collect?

Google Fit uses sensors on your device to collect data about your physical activity, like distance and steps, even when the app is closed. You can find that data in your daily and weekly activity stats or your journal.


2 Answers

To get blood pressure and glucose data, you first need to create that data. You see in the get api that your datasource is empty. Here is what you can do to create and get a blood pressure:

  1. Install "Instant Heart Rate Monitor" application from "play store",
  2. Signup using your google account,

  3. Connect "Instant Heart Rate Monitor" application to "Google Fit" (go to Instant Heart Rate Monitor profile and click on Google Fit,...)

  4. Measure your heart bpm using this application. Since this app is now connected with Google Fit, you will have a record in your datasource.

  5. To get this record, have the current epoch time in nanoseconds (https://www.epochconverter.com/) and make the following GET call:

    https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm/datasets/000000-1518561964000000000

Note that in the above code, 1518561964000000000 is epoch time in nanoseconds and you need to change it to the current time. You can do the same thing for Glucose data with an application that measures blood Glucose :)

like image 190
AidaNow Avatar answered Oct 19 '22 20:10

AidaNow


To get blood Pressure from google Fit endpoint is: https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.blood_pressure:com.google.android.gms:merged/datasets/0-1550664667715000000

dataStreamId: derived:com.google.blood_pressure:com.google.android.gms:merged

time: 0-1550664667715000000

This is startTime-endTime in UNIX epoch nanoseconds format. To get epoch time this link can be used: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html

like image 40
Akanksha Singh Avatar answered Oct 19 '22 20:10

Akanksha Singh