How to Request Heart Rate Data at 1-Minute Intervals Using Google Fit API in a Google REST API Request

70 Views Asked by At

Hello Stack Overflow community,

I'm working on a project where I need to retrieve heart rate data at 1-minute intervals using the Google Fit API. I am using Google REST API for this purpose, but I'm unsure how to configure the request to achieve 1-minute interval data aggregation.

Here's what I've tried so far:


start_time = int((datetime.now() - timedelta(days=1)).timestamp()) * 1000
end_time = int(datetime.now().timestamp()) * 1000

aggregate_request = {
    "aggregateBy": [{
        "dataTypeName": "com.google.heart_rate.bpm",
        "dataSourceId": "derived:com.google.heart_rate.bpm:com.google.android.gms:resting_heart_rate<-merge_heart_rate_bpm"
    }],
    "bucketByTime": { "durationMillis": 60000 },
    "startTimeMillis": start_time,
    "endTimeMillis": end_time
}




This is my current approach to request heart rate data. However, I am not certain if this setup correctly requests data at 1-minute intervals. I am also concerned about whether this approach captures continuous heart rate data effectively.

Could someone with experience in using the Google Fit API provide guidance on:

How to correctly set up the request for 1-minute interval heart rate data?
Any best practices for ensuring continuous and accurate data retrieval?
Any help or insights would be greatly appreciated. Thank you in advance!

Best regards,
0

There are 0 best solutions below