arpanghosh8453/public-fitbit-projects

KeyError: 'activities-heart-intraday'

Closed this issue · 3 comments

fitbit-fetch-data  | Traceback (most recent call last):                                                                                                                                                             
fitbit-fetch-data  |   File "/app/Fitbit_Fetch.py", line 580, in <module>                                                                                                                                           
fitbit-fetch-data  |     get_intraday_data_limit_1d(date_str, [('heart','HeartRate_Intraday','1sec'),('steps','Steps_Intraday','1min')]) # 2 queries x number of dates ( default 2)                                 
fitbit-fetch-data  |   File "/app/Fitbit_Fetch.py", line 254, in get_intraday_data_limit_1d                                                                                                                         
fitbit-fetch-data  |     data = request_data_from_fitbit('https://api.fitbit.com/1/user/-/activities/' + measurement[0] + '/date/' + date_str + '/1d/' + measurement[2] + '.json')["activities-" + measurement[0] + "-intraday"]['dataset']
fitbit-fetch-data  | KeyError: 'activities-heart-intraday'

I got KeyError everytime, and instance dies immediately.
Resposne from that api is

{'activities-heart': [{'dateTime': '2024-01-30', 'value': {'customHeartRateZones': [], 'heartRateZones': [{'caloriesOut': 2619.85725, 'max': 122, 'min': 30, 'minutes': 1409, 'name': 'Out of Range'}, {'caloriesOut': 180.6165, 'max': 147, 'min': 122, 'minutes': 26, 'name': 'Fat Burn'}, {'caloriesOut': 46.01475, 'max': 178, 'min': 147, 'minutes': 5, 'name': 'Cardio'}, {'caloriesOut': 0, 'max': 220, 'min
': 178, 'minutes': 0, 'name': 'Peak'}], 'restingHeartRate': 72}}]}

It seems api works fine, maybe api just changed or wrong api called?

Sorry for bothering you, it was intraday issue that I didn't enabled it. Solved by changing application type sever to personal.

No worries, it's good to see people are using it, and it's working as expected. I made the docker image because I thought it was easier to manage deployment and AutoStart. I am happy to see people are using it :)

Thank you.

@20chan I have updated the readme file with this valuable information for newcomers. Thank you.