06-02-2015 08:59
06-02-2015 08:59
I have got a Partner API and have been trying to get the second-level heart rate data from Charge, but I have not been very successful.
I have no problem of getting minute-level data on calories, steps, and other parameters using the intraday_time_series. But when I do that for getting the heart rate data at second-level, it sent me an error message saying the level has to be 1min or 15min. 1sec doesn't seem to be an option. Even if I choose minute-level, it doesn't output data other than the heart rate summary of the day. But sometimes for some reason, I can get minute-level heart rate data during the time period when the device was not used (the device was not worn, but the heart rate monitor was turned on the whole time). Does anyone know how to get the second-level heart rate data? Anyone succeeds? For your information, I am using python on a linux system.
06-02-2015 09:05
06-02-2015 09:05
What Fitbit API endpoint do you call to get second level heart rate?
06-02-2015 09:18
06-02-2015 09:18
I used Get Intraday Time Series. These were the pages I referred to when I try to get the heart rate data: https://python-fitbit.readthedocs.org/en/latest/ and https://wiki.fitbit.com/display/API/API-Get-Intraday-Time-Series
06-02-2015 09:24
06-02-2015 09:24
Please provide exact api endpoint you're using to get heart rate data.
06-02-2015 13:40
06-02-2015 13:40
I am not entirely sure what you want me to show you (I am not familiar with the software world), but here is what I tried to get the data (input & output). If you can tell me what I did wrong or why it works sometimes, that will be fantastic.
Situation 1. Second-level data isn't an option...?
tsang=fitbit.Fitbit(client_key,client_secret,resource_owner_key=user_key,resource_owner_secret=user_secret)
>>>stats=tsang.intraday_time_series('activities/heart',base_date='2015-06-01',detail_level='1sec',start_time='08:00',end_time='11:00')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fitbit/api.py", line 370, in intraday_time_series
raise ValueError("Period must be either '1min' or '15min'")
ValueError: Period must be either '1min' or '15min'
Situation 2. I change to minute-level heart rate data, but it only gives the summary for some dates..
stats=tsang.intraday_time_series('activities/heart',base_date='2015-06-01',detail_level='1min',start_time='08:00',end_time='08:30')
>>> print stats
{u'activities-heart': [{u'value': u'0', u'heartRateZones': [{u'max': 82, u'name': u'Out of Range', u'min': 30}, {u'max': 115, u'name': u'Fat Burn', u'min': 82}, {u'max': 140, u'name': u'Cardio', u'min': 115}, {u'max': 220, u'name': u'Peak', u'min': 140}], u'customHeartRateZones': [], u'dateTime': u'2015-06-01'}], u'activities-heart-intraday': {u'datasetType': u'minute', u'datasetInterval': 1, u'dataset': []}}
Situation 3. But for some dates, it gives the minute-level data...
stats=tsang.intraday_time_series('activities/heart',base_date='2015-05-29',detail_level='1min',start_time='08:00',end_time='08:30')
>>> print stats
{u'activities-heart': [{u'value': u'108.61', u'heartRateZones': [{u'max': 82, u'caloriesOut': 1.49844, u'minutes': 1, u'name': u'Out of Range', u'min': 30}, {u'max': 115, u'caloriesOut': 62.68474, u'minutes': 18, u'name': u'Fat Burn', u'min': 82}, {u'max': 140, u'caloriesOut': 82.16446, u'minutes': 10, u'name': u'Cardio', u'min': 115}, {u'max': 220, u'caloriesOut': 21.2279, u'minutes': 2, u'name': u'Peak', u'min': 140}], u'customHeartRateZones': [], u'dateTime': u'2015-05-29'}], u'activities-heart-intraday': {u'datasetType': u'minute', u'datasetInterval': 1, u'dataset': [{u'value': 117, u'time': u'08:00:00'}, {u'value': 88, u'time': u'08:01:00'}, {u'value': 80, u'time': u'08:02:00'}, {u'value': 95, u'time': u'08:03:00'}, {u'value': 121, u'time': u'08:04:00'}, {u'value': 120, u'time': u'08:05:00'}, {u'value': 127, u'time': u'08:06:00'}, {u'value': 128, u'time': u'08:07:00'}, {u'value': 139, u'time': u'08:08:00'}, {u'value': 132, u'time': u'08:09:00'}, {u'value': 123, u'time': u'08:10:00'}, {u'value': 88, u'time': u'08:11:00'}, {u'value': 91, u'time': u'08:12:00'}, {u'value': 97, u'time': u'08:13:00'}, {u'value': 106, u'time': u'08:14:00'}, {u'value': 107, u'time': u'08:15:00'}, {u'value': 113, u'time': u'08:16:00'}, {u'value': 107, u'time': u'08:17:00'}, {u'value': 104, u'time': u'08:18:00'}, {u'value': 127, u'time': u'08:19:00'}, {u'value': 149, u'time': u'08:20:00'}, {u'value': 143, u'time': u'08:21:00'}, {u'value': 127, u'time': u'08:22:00'}, {u'value': 95, u'time': u'08:23:00'}, {u'value': 100, u'time': u'08:24:00'}, {u'value': 82, u'time': u'08:25:00'}, {u'value': 87, u'time': u'08:26:00'}, {u'value': 92, u'time': u'08:27:00'}, {u'value': 91, u'time': u'08:28:00'}, {u'value': 90, u'time': u'08:29:00'}, {u'value': 101, u'time': u'08:30:00'}]}}
06-02-2015 13:53
06-02-2015 13:53
@Kalai wrote:I have got a Partner API and have been trying to get the second-level heart rate data from Charge, but I have not been very successful.
I have no problem of getting minute-level data on calories, steps, and other parameters using the intraday_time_series. But when I do that for getting the heart rate data at second-level, it sent me an error message saying the level has to be 1min or 15min. 1sec doesn't seem to be an option. Even if I choose minute-level, it doesn't output data other than the heart rate summary of the day. But sometimes for some reason, I can get minute-level heart rate data during the time period when the device was not used (the device was not worn, but the heart rate monitor was turned on the whole time). Does anyone know how to get the second-level heart rate data? Anyone succeeds? For your information, I am using python on a linux system.
@Kalai I think the problem is that the Python library you are using doesn't support the 1sec option for the API call. (The error is coming from your library not the Fitbit servers.)
Here is the code in the library that causes the error:
if not detail_level in ['1min', '15min']: | |
raise ValueError("Period must be either '1min' or '15min'") |
I don't know if you could just add 1sec to that test and if the rest of the library would work or not.
06-02-2015 14:04
06-02-2015 14:04
I cloned the python-fitbit library they provide in GitHub (https://github.com/orcasgit/python-fitbit). Is there any other python-fitbit library that I don't know about? Even if I can only get minute-level data, it's fine. Another problem I have is sometimes it outputs the minute-level data, but sometimes it just gives the summary of the day. I have no idea what makes it work or not and why.
06-02-2015 16:37
06-02-2015 16:37
Fitbit has a standard OAuth 2.0 implementation. You should be able to use any generic OAuth 2.0 library and specify Fitbit's endpoints and your app's credentials.
You'll need to use OAuth 2.0, not OAuth 1.0a in order to get access to heart rate data.
The intraday URL to request would look like: https://api.fitbit.com/1/user/-/activities/heart/date/2015-06-02/1d/1sec.json
06-04-2015 12:52
06-04-2015 12:52
So I follow the example I found in here (https://pypi.python.org/pypi/requests-oauthlib) to try to get the heart rate data using OAuth 2.0. The following is the code I used. But it gives an error message of "Missing access token". Is the error message means I missed the token secret? In the example, it only takes client_id and token as inputs. Where am I supposed to provide the token secret? Or what do "client_id" and "token" actually refer to? "Client_id" is client key or client secret or user id?
>>> from requests_oauthlib import OAuth2Session >>> fit = OAuth2Session(r'client_id', token=r'token') >>> url = 'https://www.api.fitbit.com/1/user/-/activities/heart/date/2015-06-02/1d/1sec/time/09:00/13:00.json' >>> r = fit.get(url)
11-18-2015 07:39
11-18-2015 07:39
Hello! did you find a solution? Thank you