2

I am trying to fetch data using the following link:- https://dev.fitbit.com/docs/activity/ and API :- GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json and getting response array as below

Array(
[result] => Array
    (
        [activities] => Array
            (
                [0] => Array
                    (
                        [activityId] => 90013
                        [activityParentId] => 90013
                        [activityParentName] => Walk
                        [calories] => 25
                        [description] => Walking less than 2 mph, strolling very slowly
                        [distance] => 0.271426
                        [duration] => 355000
                        [hasStartTime] => 1
                        [isFavorite] => 
                        [lastModified] => 2016-11-29T19:11:42.000Z
                        [logId] => 5007419020
                        [name] => Walk
                        [startDate] => 2016-11-30
                        [startTime] => 00:34
                        [steps] => 342
                    )

            )

        [goals] => Array
            (
                [activeMinutes] => 30
                [caloriesOut] => 2157
                [distance] => 8.05
                [floors] => 10
                [steps] => 10000
            )

        [summary] => Array
            (
                [activeScore] => -1
                [activityCalories] => 55
                [caloriesBMR] => 1257
                [caloriesOut] => 1300
                [distances] => Array
                    (
                        [0] => Array
                            (
                                [activity] => Walk
                                [distance] => 0.271426
                            )

                        [1] => Array
                            (
                                [activity] => total
                                [distance] => 0.48
                            )

                        [2] => Array
                            (
                                [activity] => tracker
                                [distance] => 0.42
                            )

                        [3] => Array
                            (
                                [activity] => loggedActivities
                                [distance] => 0.271426
                            )

                        [4] => Array
                            (
                                [activity] => veryActive
                                [distance] => 0.09
                            )

                        [5] => Array
                            (
                                [activity] => moderatelyActive
                                [distance] => 0.11
                            )

                        [6] => Array
                            (
                                [activity] => lightlyActive
                                [distance] => 0.16
                            )

                        [7] => Array
                            (
                                [activity] => sedentaryActive
                                [distance] => 0.12
                            )

                    )

                [elevation] => 0
                [fairlyActiveMinutes] => 5
                [floors] => 0
                [heartRateZones] => Array
                    (
                        [0] => Array
                            (
                                [caloriesOut] => 37.9099
                                [max] => 98
                                [min] => 30
                                [minutes] => 25
                                [name] => Out of Range
                            )

                        [1] => Array
                            (
                                [caloriesOut] => 33.193
                                [max] => 137
                                [min] => 98
                                [minutes] => 9
                                [name] => Fat Burn
                            )

                        [2] => Array
                            (
                                [caloriesOut] => 0
                                [max] => 166
                                [min] => 137
                                [minutes] => 0
                                [name] => Cardio
                            )

                        [3] => Array
                            (
                                [caloriesOut] => 0
                                [max] => 220
                                [min] => 166
                                [minutes] => 0
                                [name] => Peak
                            )

                    )

                [lightlyActiveMinutes] => 6
                [marginalCalories] => 33
                [sedentaryMinutes] => 1426
                [steps] => 789
                [veryActiveMinutes] => 3
            )

    )

[code] => 200
[content_type] => application/json;charset=UTF-8

)

but the problem is this array just provides me the data of the activity that has been done using Fitbit application. But I have to fetch complete data whether its by the Fitbit application or Fitbit device i.e blaze.

Ishika
  • 2,187
  • 1
  • 17
  • 30

1 Answers1

0

Just glancing at the API, I believe you need to use activities/tracker/. The API states that this represents the daily activity values logged by the tracker device only, excluding manual activity log entries. So you just need to add tracker to your GET.

Tracker Activities:

activities/tracker/calories  
activities/tracker/steps  
activities/tracker/distance  
activities/tracker/floors  
activities/tracker/elevation  
activities/tracker/minutesSedentary  
activities/tracker/minutesLightlyActive  
activities/tracker/minutesFairlyActive  
activities/tracker/minutesVeryActive  
activities/tracker/activityCalories
Kitson88
  • 2,889
  • 5
  • 22
  • 37
  • Tracker is giving us different response, but we need as above response which is fetched at key--> [Activities]. We are still getting just app synced data..but not by device. – Ishika Dec 01 '16 at 07:51
  • I don't think you have a tracker assigned with this ID. According to the API. if you specify activities by date using `GET https://api.fitbit.com/1/user/[user-id]/activities/date/[date].json`, it will show you all activities. Whether it be tracker (Device) or the application. To filter the result by device, you need to specify the key ['tracker']. If you look at the example response at https://dev.fitbit.com/docs/activity/, you will see within the activities --> Summary, it shows app input and device (tracker). It also shows an elevation value (Tracker/Device Value) greater than 0. – Kitson88 Dec 01 '16 at 08:07
  • We need all activities, both by app or device. The problem is we are just getting app synced data not the device one's. – Ishika Dec 01 '16 at 08:10
  • As mentioned previously, I don't think you have a device assigned with the ID you are using or your search date needs to be widened. Have you tried getting the lifetime stats using `GET https://api.fitbit.com/1/user/[user-id]/activities.json` to see if device information is showing. – Kitson88 Dec 01 '16 at 08:16
  • Yes we tried this as well but still not getting complete data. – Ishika Dec 01 '16 at 09:30