Hi,
I am developing a python application for my university and I need to access heart rate during an activity (avg data or something that tell me how user is performing during a run). I am using this api https://github.com/orcasgit/python-fitbit .
I have this code
fitbit_api.py
importfitbitPackage.fitbitimportfitbitPackage.gather_keys_oauth2asOauth2importdatetimeclassFitbiAapi:
__client_id__=None__client_secret__=None__server__=None__access_token__=None__refresh_token__=None__auth_client__=Nonedef__init__(self, client_id, client_secret):
self.__client_id__=client_idself.__client_secret__=client_secretself.__server__=Oauth2.OAuth2Server(self.__client_id__, self.__client_secret__)
defget_authorize_url(self):
returnself.__server__.get_authorize_url()
defstart_response_poll(self):
self.__server__.start_response_poll()
self.__access_token__=str(self.__server__.fitbit.client.session.token['access_token'])
self.__refresh_token__=str(self.__server__.fitbit.client.session.token['refresh_token'])
self.__auth_client__=fitbitPackage.fitbit.Fitbit(self.__client_id__, self.__client_secret__, oauth2=True, access_token=self.__access_token__, refresh_token=self.__refresh_token__)
defget_auth_client(self) ->fitbitPackage.fitbit.Fitbit:
returnself.__auth_client__defget_right_dateFormat(offset: int=0) ->str:
returnstr((datetime.datetime.now() -datetime.timedelta(days=offset)).strftime("%Y-%m-%d"))
main.py
fromfitbitPackageimportfitbit_api, get_right_dateFormatprint(fitbit_api.get_authorize_url())
fitbit_api.start_response_poll()
client=fitbit_api.get_auth_client()
today_date=get_right_dateFormat()
yesterday_date=get_right_dateFormat(-1)
fitbit_stats=client._COLLECTION_RESOURCE('heart', date=today_date)
print (fitbit_stats)but when I execute this code, i obtain this error:
Traceback (most recent call last):
File "main_testFitBit.py", line 11, in <module>
fitbit_stats = client._COLLECTION_RESOURCE('heart', date=today_date)
File "C:\Users\gabri\OneDrive\Desktop\AmIRunning-code\src\fitbitPackage\fitbit\api.py", line 348, in _COLLECTION_RESOURCE
return self.make_request(url, data)
File "C:\Users\gabri\OneDrive\Desktop\AmIRunning-code\src\fitbitPackage\fitbit\api.py", line 256, in make_request
response = self.client.make_request(*args, **kwargs)
File "C:\Users\gabri\OneDrive\Desktop\AmIRunning-code\src\fitbitPackage\fitbit\api.py", line 99, in make_request
exceptions.detect_and_raise_error(response)
File "C:\Users\gabri\OneDrive\Desktop\AmIRunning-code\src\fitbitPackage\fitbit\exceptions.py", line 86, in detect_and_raise_error
raise HTTPNotFound(response)
fitbitPackage.fitbit.exceptions.HTTPNotFound: The API you are requesting could not be found.
Why?
Hi,
I am developing a python application for my university and I need to access heart rate during an activity (avg data or something that tell me how user is performing during a run). I am using this api https://github.com/orcasgit/python-fitbit .
I have this code
fitbit_api.py
main.py
but when I execute this code, i obtain this error:
Why?