06-19-2018 14:33
06-19-2018 14:33
We used python-fitbit by Orcas to obtain intraday step data and what we get is different from Fitbit dashboard. We have cases where we see zero steps for a particular date but the dashboard shows +3K steps. Or, dates where the total number of steps is different from what we see in dashboard.
This code illustrates the main steps of obtaining intra-day data and processing it (e.g. obtaining the counts)
# user_id, client_secret, _access_token_, _refresh_token_, start_date, and end_date are passed in as input
fitbit_auth = Fitbit(
user_id, client_secret, oauth2=True, access_token=_access_token_], refresh_token=_refresh_token_])
current_date = start_date; date_increment = datetime.timedelta(days=1) while(current_date < end_date): current_date_str = current_date.strftime("%Y-%m-%d") data = fitbit_auth.intraday_time_series(
'activities/steps', base_date = current_date_str, detail_level = '1min', start_time = '0:00', end_time = '23:59') daily_steps = 0; data = data['activities-steps-intraday']['dataset'] for item in data: daily_steps += item['value’] # other processing …
print(f’{daily_steps} steps on {current_date_str}’) current_date += date_increment
I have also tried a more direct call like this to no avail:
# client_id and score are passed
fitbit = OAuth2Session(client_id, client=client, scope=scope)
# authentication_flow ...
for date in dates: data_response = fitbit.get('https://api.fitbit.com/1/user/-/activities/steps/date/{}/1d/1min.json'.format(date)) data = data_response.json() data = data['activities-steps-intraday']['dataset'] daily_steps = 0; for item in data: daily_steps += item['value’] # other processing …
The differences between the data we get and Fitbit dashboard do not seem to follow any pattern and appear in between dates where there is a complete match. So, I don’t think there is an issue with our API calls given what we retrieve matches the dashboard some of the time. I am very confused by why there is such a difference. Any thoughts are much appreciated.
Answered! Go to the Best Answer.
06-27-2018 14:16
06-27-2018 14:16
I believe the python application is not the problem as it properly obtains the data for most days. This post explains why intra-day is missing despite dashboard showing data: https://community.fitbit.com/t5/Web-API-Development/Intra-day-data-zeroed-out/td-p/2563684
In fact, when I use the same python API to get time-series data (as opposed to intra-day data) I get the data that exactly matches Fitbit dashboard
06-25-2018 12:53
06-25-2018 12:53
Hi @einsian. Have you tried the Web API Explorer tool to see if you get the data back correctly? This will help eliminate your python application as the problem.
06-27-2018 14:16
06-27-2018 14:16
I believe the python application is not the problem as it properly obtains the data for most days. This post explains why intra-day is missing despite dashboard showing data: https://community.fitbit.com/t5/Web-API-Development/Intra-day-data-zeroed-out/td-p/2563684
In fact, when I use the same python API to get time-series data (as opposed to intra-day data) I get the data that exactly matches Fitbit dashboard