07-27-2020 17:38
07-27-2020 17:38
Hi,
If I have multi devices need to collect data, how I identify which data belong to each device.
For example, if I have 4 different devices, when call https://api.fitbit.com/1/user/-/activities.json , how do I know which activities belong to each device?
Thank you
07-30-2020 14:27
07-30-2020 14:27
Hi @tinng,
Welcome to the forums!
If you execute the Get Activity Logs List endpoint, search for the "source" element and you'll be advised where the data came from. For example:
{
"activeDuration": 2766000,
"activityLevel": [{
"minutes": 5,
"name": "sedentary"
}, {
"minutes": 6,
"name": "lightly"
}, {
"minutes": 2,
"name": "fairly"
}, {
"minutes": 33,
"name": "very"
}],
"activityName": "Workout",
"activityTypeId": 3000,
"averageHeartRate": 147,
"calories": 416,
"caloriesLink": "https://api.fitbit.com/1/user/-/activities/calories/date/2016-03-05/2016-03-05/1min/time/15:31/16:17.json",
"duration": 2766000,
"heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2016-03-05/2016-03-05/1sec/time/15:31:17/16:17:23.json",
"heartRateZones": [{
"max": 94,
"min": 30,
"minutes": 3,
"name": "Out of Range"
}, {
"max": 131,
"min": 94,
"minutes": 8,
"name": "Fat Burn"
}, {
"max": 159,
"min": 131,
"minutes": 4,
"name": "Cardio"
}, {
"max": 220,
"min": 159,
"minutes": 30,
"name": "Peak"
}],
"lastModified": "2016-03-06T00:20:21.000Z",
"logId": 1846159807,
"logType": "tracker",
"manualValuesSpecified": {
"calories": false,
"distance": false,
"steps": false
},
"source": {
"id": "47086726",
"name": "Charge HR",
"type": "tracker",
"url": "https://www.fitbit.com/"
},
"startTime": "2016-03-05T15:31:17.000-08:00",
"steps": 683,
"tcxLink": "https://api.fitbit.com/1/user/-/activities/1846159807.json"
}
In the above example, the source of the activity was:
},
"source": {
"id": "47086726",
"name": "Charge HR",
"type": "tracker",
"url": "https://www.fitbit.com/"
}
I hope this helps. Let me know if you have any additional questions.
04-27-2021 03:07
04-27-2021 03:07
Hi John,
I am working with a research team that is supported by the US Health and Human Services grant. We will be assessing return to activity after surgery of 10 patients. Each patient will be sent home with a medical device on their leg and a FitBit Alta HR attached to the device. After 7 days, patients will return to the hospital where the Alta HRs will be recharged and synchronized with the Fitbit account(s). This will be repeated three times. The main data we wish to capture is the steps per 15 minutes or per hour.
Following the above exchange, I understand that we can use *one* Fitbit account, register the *ten* devices to this account and use the Web API to download the data. The *source id* will be used to tie the data to the right patient.
Is this correct? Do you see any problems with this approach?
Thank you!
Yossi
04-28-2021 10:08 - edited 04-28-2021 10:09
04-28-2021 10:08 - edited 04-28-2021 10:09
Hi @yossi-laor,
Welcome to the forums!
You can only have 1 of each device paired to an account. So, it's not possible to have 10 Alta HRs paired to a single account. We recommend having an account paired to each Alta HR (1:1).
The reason being, when the an account is created, you have to enter the user's personal information (age, height, weight, gender), and this data is used in algorithms to calculate that account owner's BMR, calorie burn, stride distance, etc. With that in mind, the data generated for the account owner will be the most accurate, whereas anyone else sharing that account will not have meaningful data.
Lastly, data is tied to user id (account ids). All of our API endpoints call the user id, not the source, to obtain data from the user. For compliance, you must obtain consent from all account owners to access their Fitbit data. That would not be possible if you had 1 account shared between 10 users as consenting with that 1 account would mean all 10 participants provided consent to share data. Each participant would need to go through the Authorization flow, and allow your application to access their Fitbit accounts.
Does this help? Let me know if you have additional questions.
04-30-2021 01:26
04-30-2021 01:26
Hi John,
Thanks for the quick and detailed answer. I understand the reasoning.
However, our context is non-standard in the sense that we have ten *elderly* patients. They will use the trackers at home, but will require *minimal* administration and technological tasks around these trackers. We will be the ones to recharge and synchronize the trackers once a week when the patients come to the hospital. Also, the only data we need is the intra-day steps number. No weight, age or other personal data or calculation is required.
We were hoping to have a single account in order to streamline the registration and synchronization. With multiple accounts we will need to log-on to account 1, synchronize tracker 1, log-off account 1, log-on account 2, and so on. A single account will make this process slightly less cumbersome.
Do you see any better way to streamline this?
(I see that the device is identified at https://api.fitbit.com/1/user/-/devices.json, but the device is not identified at https://api.fitbit.com/1/user/-/activities/steps/date/yyyy-mm-dd/1d/15min.json which we plan to use)
Thank you, Yossi
05-03-2021 15:53
05-03-2021 15:53
@yossi-laor Gotcha, it's not possible to have 10 patients share 1 account. You could instead use one device/platform to log into each account 1 at a time and sync the devices. This is the only way unless you allow each participant to sync to their own mobile devices. Each account would have an associated User ID, which you'll use to execute API calls, such as:
GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json
As you can see in the endpoint, we use [user-id] to identify user data, not device id, and this is standard across all web api endpoints..
08-19-2021 17:58
08-19-2021 17:58
Hi John, do you know why the source is not always returned for each activity in the return from Get Activity Logs List end point?