Fitbit "Get Daily Activity Summary" API call gets empty "activities" array

861 views Asked by At

In my application I'm making API calls to fetch Fitbit data of a user,when I make an API call to "Get Daily Activity Summary" I get empty activities array.

I'm getting everything from this API call just activities array is coming out as empty[]. Below is the sample response of API call.

{  
   "activities":[  

   ],
   "goals":{  
      "caloriesOut":2826,
      "distance":8.05,
      "floors":150,
      "steps":10000
   },
   "summary":{  
      "activityCalories":230,
      "caloriesBMR":1913,
      "caloriesOut":2143,
      "distances":[  
         {  
            "activity":"tracker",
            "distance":1.32
         },
         {  
            "activity":"loggedActivities",
            "distance":0
         },
         {  
            "activity":"total",
            "distance":1.32
         },
         {  
            "activity":"veryActive",
            "distance":0.51
         },
         {  
            "activity":"moderatelyActive",
            "distance":0.51
         },
         {  
            "activity":"lightlyActive",
            "distance":0.51
         },
         {  
            "activity":"sedentaryActive",
            "distance":0.51
         },
         {  
            "activity":"Treadmill, 0% Incline",
            "distance":3.28
         }
      ],
      "elevation":48.77,
      "fairlyActiveMinutes":0,
      "floors":16,
      "lightlyActiveMinutes":0,
      "marginalCalories":200,
      "sedentaryMinutes":1166,
      "steps":0,
      "veryActiveMinutes":0
   }
}
2

There are 2 answers

5
Manav On BEST ANSWER

We can log the activities in two ways.

  1. Log into fitbit portal (https://www.fitbit.com/) and manually log one activity.
  2. Sync your fitbit device with your application (android or Iphone).

In First Case, you will get the activities collection, when you request for that day for which you have logged the activity.

Suppose you have logged an activity for 18th Dec 2016.

Request Url : https://api.fitbit.com/1/user/-/activities/date/2016-12-18.json

Response:

{
  "activities": [
    {
      "activityId": 12030,
      "activityParentId": 90009,
      "activityParentName": "Run",
      "calories": 530,
      "description": "Running - 5 mph (12 min/mile)",
      "distance": 1,
      "duration": 3600000,
      "hasStartTime": true,
      "isFavorite": false,
      "lastModified": "2016-12-19T12:07:51.124Z",
      "logId": 5218814487,
      "name": "Run",
      "startDate": "2016-12-18",
      "startTime": "06:00",
      "steps": 843
    }
  ],
  "goals": {
    "activeMinutes": 30,
    "caloriesOut": 2689,
    "distance": 8.05,
    "steps": 10000
  },
  "summary": {
    "activeScore": -1,
    "activityCalories": 1658,
    "caloriesBMR": 1588,
    "caloriesOut": 2927,
    "distances": [
      {
        "activity": "Run",
        "distance": 1
      },
      {
        "activity": "total",
        "distance": 7.42
      },
      {
        "activity": "tracker",
        "distance": 7.1
      },
      {
        "activity": "loggedActivities",
        "distance": 1
      },
      {
        "activity": "veryActive",
        "distance": 1.99
      },
      {
        "activity": "moderatelyActive",
        "distance": 0.03
      },
      {
        "activity": "lightlyActive",
        "distance": 5.41
      },
      {
        "activity": "sedentaryActive",
        "distance": 0
      }
    ],
    "fairlyActiveMinutes": 1,
    "lightlyActiveMinutes": 297,
    "marginalCalories": 961,
    "sedentaryMinutes": 108,
    "steps": 9982,
    "veryActiveMinutes": 74
  }
}

In Second Case, where you have fitbit activity tracker, you will not get activities collection for data logged thenter code here`rough fitbit band. You can check that data in fitbit portal. That will be logged as activity record.

But you will get the summary section. where you will find useful information needed. Like Steps, calorie burned etc. So always use summary section in place of activities collection.

In your case, you have not logged any activity that's why you are not getting any activities collection. Apart from activities collection , the data that you are getting is default data that we get even when there is no activity for that day.

0
Rohit Dhiman On

Try this:

It will give the activity list as Fitbit displays in their website.

https://api.fitbit.com/1/user/{fitbit-user-id}/activities/list.json?beforeDate=2017-09-29&sort=desc&offset=0&limit=20