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

Not getting Nutritional Information for all foods with api call

I have logged the following lunch foods:

FoodLogged.png

I'm using this api call to get the data.
https://api.fitbit.com/1/user/-/foods/log/date/<date>.json

 

I get all of the food items, but not all of the nutritionalValues in the JSON.  There's Calories, Fat, Fiber, Carbs, Sodium & Protein for the Chicken Burrito, but not for the other two.  Why?  Should I use a different api call?  Is it just not available?  Is there a bug?

Best Answer
0 Votes
23 REPLIES 23

@Gordon-C Hi there!  Hope you had a great summer!  Checking in to see if there's any update on this issue?  Thanks much!

Best Answer
0 Votes

@Gordon-C 

Not sure if it provides any additional context but there does appear to be a difference in response data over curl depending on the authorization header used.

For example when using the authorization token for the Swagger API I get this data

"loggedFood": {"accessLevel": "PUBLIC", "amount": 1, "brand": "Del Monte", "calories": 30,
"foodId": 14725566, "locale": "en_US", "mealTypeId": 1, "name": "Pears, Diced",
"unit": {"id": 91, "name": "cup", "plural": "cups"},
"units": [305, 91, 256, 279, 226, 180, 147, 389]},
"nutritionalValues": {
"calories": 30,
"carbs": 8,
"fat": 0,
"fiber": 1,
"protein": 0,
"sodium": 0}},

But when using the token from my app I do not get the Nutritional Information

"loggedFood": {"accessLevel": "PUBLIC", "amount": 1, "brand": "Del Monte", "calories": 30,
"foodId": 14725566, "locale": "en_US", "mealTypeId": 1, "name": "Pears, Diced",
"unit": {"id": 91, "name": "cup", "plural": "cups"},
"units": [305, 91, 256, 279, 226, 180, 147, 389]}},

May also be worth noting that custom foods which have "accessLevel": "PRIVATE" do return their nutritionalValues.

 

Best Answer
0 Votes

That's very interesting.  I'll have to look into it.  Thanks very much!

Best Answer
0 Votes

@Gordon-C This is an old thread, but I'm seeing this same behavior today.

When I request a food log for a given user and date, 3 of 5 loggedFood items are missing nutritionalValues.  It happens in our app, and when making the request with postman using a token from our app.

When I make the same request in web-api explorer, all food items have nutritionalValues.  When I use the token from that site in postman, as above (changing nothing else), the postman response also includes all nutritionalValues.

The only difference between the requests is the access-token.  

Interestingly, the "summary" object at the end has the same values either way.

Here's a sample response using the app's access token, with missing nutritionalValues:

{
"foods": [
{
"isFavorite": false,
"logDate": "xxxx-xx-02",
"logId": 36353447205,
"loggedFood": {
"accessLevel": "PUBLIC",
"amount": 1,
"brand": "Cheerios",
"calories": 100,
"foodId": 748257095,
"locale": "en_US",
"mealTypeId": 1,
"name": "Cheerios Cereal",
"unit": {
"id": 91,
"name": "cup",
"plural": "cups"
},
"units": [
91,
256,
279,
226,
180,
147,
389
]
}
},
{
"isFavorite": false,
"logDate": "xxxx-xx-02",
"logId": 36353496080,
"loggedFood": {
"accessLevel": "PUBLIC",
"amount": 0.5,
"brand": "",
"calories": 150,
"foodId": 81967,
"locale": "en_US",
"mealTypeId": 1,
"name": "Oats, Rolled, Quick (oatmeal)",
"unit": {
"id": 91,
"name": "cup",
"plural": "cups"
},
"units": [
91,
256,
279
]
},
"nutritionalValues": {
"calories": 150,
"carbs": 27,
"fat": 3,
"fiber": 4,
"protein": 5,
"sodium": 0
}
},
{
"isFavorite": false,
"logDate": "xxxx-xx-02",
"logId": 36350861073,
"loggedFood": {
"accessLevel": "PUBLIC",
"amount": 10,
"brand": "",
"calories": 6,
"foodId": 17222,
"locale": "en_US",
"mealTypeId": 2,
"name": "Coffee",
"unit": {
"id": 226,
"name": "oz",
"plural": "oz"
},
"units": [
226,
180,
147,
389
]
},
"nutritionalValues": {
"calories": 6,
"carbs": 0.85,
"fat": 0,
"fiber": 0,
"protein": 0.57,
"sodium": 0
}
},
{
"isFavorite": false,
"logDate": "xxxx-xx-02",
"logId": 36345905544,
"loggedFood": {
"accessLevel": "PUBLIC",
"amount": 1,
"brand": "Unknown",
"calories": 370,
"foodId": 721555292,
"locale": "en_US",
"mealTypeId": 3,
"name": "Pizza",
"unit": {
"id": 311,
"name": "slice",
"plural": "slices"
},
"units": [
311,
226,
180,
147,
389
]
}
},
{
"isFavorite": false,
"logDate": "xxxx-xx-02",
"logId": 36350172565,
"loggedFood": {
"accessLevel": "PUBLIC",
"amount": 1,
"brand": "Don Miguel",
"calories": 390,
"foodId": 14544930,
"locale": "en_US",
"mealTypeId": 3,
"name": "Burrito, Chicken",
"unit": {
"id": 40,
"name": "burrito",
"plural": "burritos"
},
"units": [
40,
226,
180,
147,
389
]
}
}
],
"goals": {
"calories": 1617
},
"summary": {
"calories": 1016,
"carbs": 145.85,
"fat": 32,
"fiber": 13,
"protein": 40.57,
"sodium": 2030,
"water": 27986.939453125
}
}

 

Best Answer
0 Votes