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

Regarding User Data Sync Process

Hello,
 
a) We are going to purchase 200 fitbit devices and that will register into our system by admin.
b) Once a device is registered we will assign those devices to our website clients.
c) I want to confirm suppose we assigned a device to a client and we want to get client data into our system so for this case do we also need to onboard that user into our system by passing fitbituser id and password at the very first time or that can be done with step 1 only?
 
will it work or I have another case:
 
a) Admin will connect fitbit device as per the standard process to fitbit portal using auth process as given in auth document.
 
b) We will store device details in our system and then it can be assigned to users.
 
c) Once a device is assigned user can use it and we can get users data into our database.
 
Please advice.
Best Answer
0 Votes
6 REPLIES 6

Hi @anusha.saxena 

 

My apologies for the delay in the response.  Your application will not collect the Fitbit user's login credentials.  Instead of collecting the user's login credentials, your application will receive an access token for that individual user which provides your application the necessary access to fetch the user's data.   You will still need to onboard that user into your system using the OAuth2 endpoints so Fitbit can provide your application with the access token for that user. 

 

 

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

Hello,

 

I am integrating Fitbit health API in my application and I have below queries on Fitbit Health API. Can you please help me to sort it out?

 

1. I want to check the Fitbit health data for different time interval on Data Generator. From where I can check the data availability. Just like we do on Garmin Data Generator. Basically, I want some tool to check the Fitbit health data available for a particular date and time.

 

2. Is Fitbit provides live data ? can I get it for different time intervals, for example, I want to store the Fitbit health data for every 15 mins interval for a day. Is there any way I can get it?
Basically, I am looking for frequent health data. Can you please share if I can achieve this and what is the process of Fitbit data.

 

3. I want to fetch below data parameters through Fitbit health API, can you please suggest which specific API will provide me this data? I can see these API in Fitbit listing: http://prntscr.com/nvw86q

> MinAverageHeartRate
> MaxAverageHeartRate
> Steps
> Sleep Duration
> StartTimeInSeconds

 

4. As per the details, user access tokens get expired in 8 hrs, am I right? so, in this case, I will use the RefreshToken process.

 

5. Can you please provide some reference links from where I can see the details like how we call the API with parameters and what details need to call an API endpoint? Also, it would be helpful if you can provide reference from where I can get to know which API provides frequent health data and what is the difference in them in terms of data uploading and data fetching.

 

I need to resolve it on priority as I have client deliverable, please cooperate!

 

Thanks.

Best Answer
0 Votes

1. Using the Get Activity Intraday Time Series endpoints, you can pull data from a specific date and time range. For example, if you query https://api.fitbit.com/1/user/-/activities/steps/date/2019-05-29/1d/1min/time/12:00/12:05.json, you would see a response like: 

{
    "activities-steps": [
        {
            "dateTime": "2019-05-29",
            "value": "572"
        }
    ],
    "activities-steps-intraday": {
        "dataset": [
            {
                "time": "12:00:00",
                "value": 103
            },
            {
                "time": "12:01:00",
                "value": 110
            },
            {
                "time": "12:02:00",
                "value": 110
            },
            {
                "time": "12:03:00",
                "value": 114
            },
            {
                "time": "12:04:00",
                "value": 109
            },
            {
                "time": "12:05:00",
                "value": 26
            }
        ],
        "datasetInterval": 1,
        "datasetType": "minute"
    }
}

 

2. The Device SDK can provide you with real-time/live data. However, you will need to visit the SDK forums for support on this subject.

 

Otherwise, it seems like the GET endpoint example mentioned in question 1 may also fit your needs. Rather than displaying in 1min intervals, you can set it to 15 min intervals, and you should see a response like this: 

{
    "activities-steps": [
        {
            "dateTime": "2019-05-29",
            "value": "1317"
        }
    ],
    "activities-steps-intraday": {
        "dataset": [
            {
                "time": "12:00:00",
                "value": 572
            },
            {
                "time": "12:15:00",
                "value": 0
            },
            {
                "time": "12:30:00",
                "value": 457
            },
            {
                "time": "12:45:00",
                "value": 288
            },
            {
                "time": "13:00:00",
                "value": 0
            }
        ],
        "datasetInterval": 15,
        "datasetType": "minute"
    }
}

 

If you are trying to collect live data in 15 min intervals, the Web API will not fit your use case as you can only pull data that has first synced to a user's account beforehand.

 

Note: You will need to fill out the Intraday Access Request application before you can enable these endpoints on your application.

 

3. I don't believe there is any API for pulling minAverageHearRate and maxAverageHeartRate. However, the Get Activity Logs List endpoint does return the averageHeartRate attribute. If this is not the value you are searching for, can you clarify what heart rate data you are looking for in particular?

 

Steps can be accessed through any activity endpoint, such as the Get Daily Activity Summary endpoint and the Get Activity Time Series endpoints.

 

Sleep Duration or the Duration attribute can be found within the Get Sleep Logs endpoint.

 

There isn't a StartTimeInSeconds attribute that I know of, however, you can find the startTime attribute in the Get Sleep Logs endpoint and in the Get Daily Activity Summary endpoint. Can you clarify which data types you are interested in finding this attribute in?

 

4. Authorization code grant flow tokens have a default expiration of 8 hours. Your application stores the access token and refresh token. It will use the access token to make requests to the Fitbit API. It will use the refresh token to obtain a new access token when the access token expires without having to re-prompt the user.

 

If you would like your users to have the option of their tokens expiring in 1 day, 1 week, 30 days, or 1 year, I suggest setting your application to using the Implicit Grant Flow. Under this authorization flow, your application receives the access token and refresh token. It will use the access token to make requests to the Fitbit API. It will use the refresh token to obtain a new access token when the access token expires without having to re-prompt the user.

 

5. I suggest beginning at our Web API Quick Start Guide. This will take you through the basics of how the Web API works, registering your application, and to making HTTP requests to access data.

 

If you are looking for frequent API updates to when users update their account with new activity data, I suggest looking up our Subscriptions API. This allows third=party applications to be notified when Fitbit user data changes. To put it simply, the API will notify you when the user syncs new data to their account. This will allow you to fetch new data whenever it has been synced to the user's account.

 

I hope this helps. Let me know if you have any additional questions!

 

Best Answer
0 Votes

Hi John,

 

Thanks for your reply. Please find my comments on your reply :

 

1. I don't believe there is any API for pulling minAverageHearRate and maxAverageHeartRate. However, the Get Activity Logs List endpoint does return the averageHeartRate attribute. If this is not the value you are searching for, can you clarify what heart rate data you are looking for in particular?

My Comments:  Here I am looking for the Minimum Heart Rate and Maximum Heart Rate data. for Example in Garmin API, I get this type of response: http://prntscr.com/nwxaxi

I want Average Heart Rate, Minimum Heart Rate, and Maximum Heart Rate through Fitbit API.

 

2. Using the Get Activity Intraday Time Series endpoints, you can pull data from a specific date and time range. For example, if you query https://api.fitbit.com/1/user/-/activities/steps/date/2019-05-29/1d/1min/time/12:00/12:05.json, you would see a response like.

My Comments: I have checked the API response and also tried the Intraday time endpoints, but I am not able to get the expected health data like average heart rate and steps, etc, it's giving me some other kind of data you can see here: http://prntscr.com/nwxdek. How I can get the health data can you please give me some example endpoints or some kind of reference where I can get these parameters which are shared below :

> Min Average Heart Rate
> Max Average Heart Rate
> Steps
> Sleep Duration
> StartTime

I would be helpful if you can share the URL endpoints in order to fetch the above-shared parameters.

 

3. I want some console window to check the different time interval's health data just like we have Garmin portal: http://prntscr.com/nwxhhk.

Also, I need to map the live data which is showing on Dashboard with Fitbit Health API: http://prntscr.com/nwxk33

 

4. As per your comment, using IntraDay time process I can get the Fitbit health data of different time intervals, but the data I am getting by passing Time intervals but I am getting some other kind of data which is not the expected output which I am looking for (shared above).

 

Can you please share some example of API URL endpoints for more details?

 

5. Also, the API response you shared is also giving some limited amount of data and again I am not able to see the other data like steps and heart rates on it. http://prntscr.com/nwxsw2

I want API sample endpoints with all available response data.

 

Quick response will be much appreciated, looking forward to your response.

 

Thanks

 

 

Best Answer
0 Votes

Hi @anusha.saxena,

 

1. The Fitbit Web API only provides the averageHeartRate value at this time, which can be found from responses using the GET https://api.fitbit.com/1/user/-/activities/list.json endpoint.

 

2. The Fitbit Web API does not have any endpoints available that provide min and max average heart rate data, only averageHeartRate as stated in question #1.

 

steps can be acquired from the following endpoints:

Get Daily Activity Summary

GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json.

Get Activity Time Series

 

GET https://api.fitbit.com/1/user/[user-id]/[resource-path]/date/[date]/[period].json
GET https://api.fitbit.com/1/user/[user-id]/[resource-path]/date/[base-date]/[end-date].json

 

*Replace [resource-path] with steps

 

 

Get Activity Intraday Time Series

GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/[date]/[detail-level].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/1d/[detail-level].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/[date]/[detail-level]/time/[start-time]/[end-time].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/1d/[detail-level]/time/[start-time]/[end-time].json

*Replace [resource-path] with steps

**Need Intraday Access, you'll need to fill out this form for access.

Get Activity Logs List

 

GET https://api.fitbit.com/1/user/-/activities/list.json

 

Get Activity Goals

 

GET https://api.fitbit.com/1/user/[user-id]/activities/goals/[period].json

 

Get Lifetime Stats

 

GET https://api.fitbit.com/1/user/[user-id]/activities.json

 

 

sleepDuration can be found in the following endpoints:

 

Get Sleep Logs

 

GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[date].json

 

Get Sleep Logs by Date Range

 

GET https://api.fitbit.com/1.2/user/[user-id]/sleep/date/[startDate]/[endDate].json

 

Get Sleep Logs List

GET https://api.fitbit.com/1.2/user/-/sleep/list.json

As for startTime, can you please share which collection type you are interested in seeing this information in (ie activity or sleep).

 

Lastly, please note that the heart rate data that you see on the dashboard is not live data. This is a user's recorded resting heart rate on a day by day basis. This information dependant on a user regularly syncing their sleep data to their account. To see how resting heart rate is calculated, please see How do I track my heart rate with my Fitbit device?

 

As mentioned in a previous post, live data is only available through the Device SDK. For support on this subject, please visit the SDK Forums.

 

4 & 5. In order to access the intraday time-series endpoints, you'll need to fill out an application in order to grant you with access to these endpoints. You can find the application to the intraday access request here.

 

If your application has been approved to receive Intraday access, your application will then be able to query the following endpoints:

 

https://dev.fitbit.com/build/reference/web-api/heart-rate/#get-heart-rate-intraday-time-series

GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/[end-date]/[detail-level].json
GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/[end-date]/[detail-level]/time/[start-time]/[end-time].json
GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/1d/[detail-level].json`
GET https://api.fitbit.com/1/user/-/activities/heart/date/[date]/1d/[detail-level]/time/[start-time]/[end-time].json

https://dev.fitbit.com/build/reference/web-api/activity/#get-activity-intraday-time-series

GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/[date]/[detail-level].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/1d/[detail-level].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/[date]/[detail-level]/time/[start-time]/[end-time].json
GET https://api.fitbit.com/1/user/-/[resource-path]/date/[date]/1d/[detail-level]/time/[start-time]/[end-time].json

I hope this clarifies things. Please let me know if you have any additional questions.

 

Best Answer
0 Votes

Hi John,

 

Your last response was very helpful and appreciated!

 

I have few more queries I would like you to please resolve.

 

1. As of now of now I am fetching fitbit health data of 1 month period and below is my api endpoints :

/activities/steps/date/today/1m.json

/activities/heart/date/today/1m.json

 

So here I am getting different JSON formats for both parameters i.e Hear Rates and Steps.

 

Steps :http://prntscr.com/o1agac

Heart Rate : http://prntscr.com/o1ahhn 

 

> Can you please confirm this API response JSON formats will be same and will not be changed?

 

> Also can you please clear what exactly is the highlighted thing : http://prntscr.com/o1acft. I assume its the activity name.

 

> I am fetching data of 1 day by passing date parameter in end point URL, so here I am getting multiple data array of heart rates like : http://prntscr.com/o1ataa

Can you please confirm why I am getting multiple data array in Heart Rate API? also how can I get the average heart rate of a day.

 

Here is my API endpoint : /activities/heart/date/today/1m.json

 

Please reply as soon as possible.

 

Thanks.

 

Best Answer
0 Votes