Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Controling intraday HR json size

Hey there,

I need to pull HR data from the fitbit API in order to get the last HR value sync by the watch. While trying to do that I ve ran into a couple problems:

1. I tried using the API call for the whole day (1 sec precision) and grabbing the dataset array's last element, and it did work for that purpose. However my nodejs app needs to JSON.parse() the intraday response in order to access its data and the fact that parse() blocks the event loop compromises greatly my app's performance.

2. Given the input from problem number 1 I decided to use the API call with a start/end time in order to reduce json size. Unfortunately I have ran into another problem: If I try and pull data that has not been synchronized yet I get an empty array in response and my request basically went to waste.

I wonder if there is a middle men between those two, a way to pull the last HR data that has been synchronized like in the full day call but still be able to reduce the response size as something like: fetch latest synchronized HR data within the last hour or minute.

Is this achievable in any way?

Thanks in advance,

Best Answer
0 Votes
1 REPLY 1

Interesting question. I'm parsing the response using php, and it chews through a whole day's data (HR in seconds) in less than one second.

 

Perhaps you could try getting 1min resolution data first. That should parse much more quickly, and the last record therein will tell you which minute's data to subsequently request at 1sec resolution. You'll just have to watch the edge case of when the last data occurs on a minute boundary.

Peter McLennan
Gondwana Software
Best Answer
0 Votes