06-10-2019 02:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-10-2019 02:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
import fitbitPackage.fitbit import fitbitPackage.gather_keys_oauth2 as Oauth2 import datetime class FitbiAapi: __client_id__ = None __client_secret__ = None __server__ = None __access_token__ = None __refresh_token__ = None __auth_client__ = None def __init__(self, client_id, client_secret): self.__client_id__ = client_id self.__client_secret__ = client_secret self.__server__ = Oauth2.OAuth2Server(self.__client_id__, self.__client_secret__) def get_authorize_url(self): return self.__server__.get_authorize_url() def start_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__) def get_auth_client(self) -> fitbitPackage.fitbit.Fitbit: return self.__auth_client__ def get_right_dateFormat(offset: int = 0) -> str: return str((datetime.datetime.now() - datetime.timedelta(days=offset)).strftime("%Y-%m-%d"))
main.py
from fitbitPackage import fitbit_api, get_right_dateFormat print(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.
A way to access some HR data? The app can't be a personal type app because needs to be used from other users. Actually is a server type app. Thank you
06-10-2019 14:58 - edited 06-12-2019 11:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



06-10-2019 14:58 - edited 06-12-2019 11:00
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @gabriele97 ,
I'll be happy to assist you with your application. So that I can see if your application is set up to query heart rate during activities, can you please PM me with your application's Client ID? This information can be found in your application details at https://dev.fitbit.com/apps.
Looking forward to hearing from you. Let me know if you have any additional questions in the meantime.

