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

How to efficiently get weight data from Web API

It should be clear from the documentation but in reality, it is not. This is the observed and tested behavior of the Web API.

Problem statement: Get ALL Weight and Fat percentage data for a user given the smallest amount of API request possible. (Both for rate-limiting reasons and also I do not want to hammer FitBit API if I don't have to).

 

The first intuition would be to use the "Get Body Time Series" API. It allows getting data for an arbitrary duration. However, data from this API is inconsistent with data you get from "Get Body Fat Logs" or "Get Weight Logs" APIs. The latter 2 APIs will return nothing for dates when there is no measurement taken that day. The "Get Body Time Series" will on the other hand in such case return the last recorded measurement and will repeat this value every day until a new measurement is taken.


This behavior seems VERY odd to me for several reasons.

  1. What value will be given when multiple measurements are taken on the same day? Is it possible to correlate the value for fat and weight and therefore calculate the "fat mass" for example? With the other API, it is possible via "logID".
  2. This behavior is from how "Time Series" works for activities from my experience. There all values are 0 unless a measurement is logged. Therefore, it is possible to distinguish whether a measurement was taken in 99.9% of the cases that day. (It might be possible that the actual recorded value for that day is 0 as well and in that case, you are out of luck)
  3. As stated above, values from this API are in direct opposition to the values from other APIs.

As a result, I am forced to use "Get * Logs" APIs, that have a maximal time range of 31 days and therefore might multiply the number of required API calls by about 30 on average for my users.

At the same time, I see several possible solutions to this issue that could be implemented on the FitBit side:

  1. Allow larger range for "Get * Logs" APIs
  2. Make the values from "Get Body Time Series" deterministic with respect to the measurement taken (for all use the same measurement (first, last, with most information)) or provide all measurements for the day either ordered or with a correlation ID
  3. Make "Get Body Time Series" return 0 as do all other APIs when no data is available or even better yet some other representation of the "NULL" concept

 

Right now I am at the point that I have to use 30+ API calls for an issue I think FitBit would like me to solve with 1 call. Maybe I have missed something, does anybody see any other option to achieve the result I am seeking other than the solution I have proposed?

Best Answer
0 Votes
2 REPLIES 2

Hi @patrickkus,

 

This is a very good observation, and just recently have I worked a case where I needed to explain that the Get Weight/Fat Logs endpoints will return actual weigh-ins versus the time series endpoints.

 

I have not yet tested to see what the expected behavior is if for example I perform multiple weigh-ins a day and what response I am expected to see from the time series endpoints. I'll need a few days to test this out and get back to you.

 

If I can confirm that this is in fact a challenging experience for developers, I'll go ahead and file a ticket to improve the experience.

 

Again, thanks for bringing this up and I'll post back here after some tests.

Best Answer

Any update on this?

Best Answer
0 Votes