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

activities-heart-intraday not present in my query

I've recently started looking into the FitBit API because I wanted to play around with my charge 6. following the python implementation suggested on the developers portal and other websites always bring me to the following issue:

KeyError: 'activities-heart-intraday' 

sample code running with python 3.10

 

import gather_keys_oauth2 as Oauth2 
import fitbit
import pandas as pd 
import datetime
CLIENT_ID='xxx'
CLIENT_SECRET='xxx'

server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET)
server.browser_authorize()
ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token'])
REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token'])

server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET)
server.browser_authorize()
ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token'])
REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token'])
auth2_client = fitbit.Fitbit(CLIENT_ID,CLIENT_SECRET,oauth2=True,access_token=ACCESS_TOKEN,refresh_token=REFRESH_TOKEN)

yesterday = str((datetime.datetime.now() - datetime.timedelta(days=1)).strftime("%Y%m%d"))

fit_statsHR = auth2_client.intraday_time_series('activities/heart', base_date=yesterday, detail_level='1sec')
time_list = []
val_list = []

for i in fit_statsHR['activities-heart-intraday']['dataset']:
    val_list.append(i['value'])
    time_list.append(i['time'])
heartdf = pd.DataFrame({'Heart Rate':val_list,'Time':time_list})​

 

YES: my app is set on 'personal'

YES: I authorized the data usage

YES: I tried to remake the app from scratch.

Any further suggestion?
Thanks a lot!

Best Answer
5 REPLIES 5

Hi @S4m 

I saw your posted your question in the wrong forum and I moved it to the correct one.   Are you still getting this error messge?

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

I seem to have the same issue, I wrote my app from scratch, the app is set to Personal, yet I don't get activities-heart-intraday from something like https://api.fitbit.com/1/user/-/activities/heart/date/<date>/1d/1s.json  which I should according to the documentation. 

I played around with the OAuth way of authorizing, but to no ends. Any other suggestions? 

Best Answer
0 Votes

Hi @MarcusMT 

You have a typo in your endpoint.   The detail level for HR in seconds is "1sec", not "1s".   Please try changing your endpoint syntax and let me know if that doesn't work.

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

That was it, doh, now it works.

This would be a good candidate to not respond with a 200 OK

Best Answer
0 Votes

Yes, I will report that bug to engineering.   Thank you!

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes