Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


Get a summary and list of a user's food log entries for a given day in the format requested.

Access Type: Read

Rate Limited: Yes

...

Privacy: Foods (Friends or Anyone) privacy permission grants access to other user's resource.

Access Levels

There are three types of foods that authorized user can see while in the API requests, each food is annotated with accessLevel field with one of the three following values:

  • PUBLIC – those foods that we have in our public food database, they are visible to any of the Fitbit users. We are only populating this database ourselves to avoid spam and duplicated entries.
  • PRIVATE – foods created by the authorized user both on the website and via the call to the new Create Food endpoint.
  • SHARED – is a PRIVATE foods of some user, when viewed on behalf of other authorized user. The user can add a log entry for such food (via the API or on the website). To discover such foods and log them one could use Get Foods endpoint to fetch food log entries of any other user, who granted permission for Foods to Friends or Anyone.

Note: Get Foods response for the user other than the authorized one, will include PRIVATE or SHARED label from that log owner's point of view.

Resource URL

GET /<api-version>/user/<user-id>/foods/log/date/<date>.<response-format>

api-version

The API version. Currently 1.

user-id

User's encoded id or "-" (dash) to indicate user currently authenticated via the token credentials provided.

date

The date in the format yyyy-MM-dd.

response-format

The response format. Currently supported response formats are json and xml for responses in JSON and XML, respectively.

Code Block
bgColor#eeeeee
titleBGColor#3ec1c1
titleExamples
borderStylesolid
titleExamples

GET /1/user/228TQ4/foods/log/date/2010-02-25.json
GET /1/user/223XR3/foods/log/date/2010-03-27.xml
GET /1/user/-/foods/log/date/2010-02-21.json
GET /1/user/-/foods/log/date/2010-03-27.xml

Authentication

Via token credentials. oauth_token authentication header parameter is optional.

Request Headers

None

Accept-LocaleoptionalThe locale to use for response values. Locale is used to determine locale of the food units in the response.

Response

API Response in format requested: JSON or XML.

Response body format

Note: Text within <> is a descriptive place holder for a value.

Code Block
bgColor#eeeeee
titleBGColor#3ec1c1
borderStylesolid
titleJSON Response
borderStylesolid
{
    "foods":[
        {
            "isFavorite":<value>,
            "logDate":<value>,
            "logId":<value>,
            "loggedFood":{
                "accessLevel":<value>,
                "amount":<value>,
                "brand":<value>,
                "calories":<value>,
                "foodId":<value>,
                "mealTypeId":<value>,
                "locale":<value>,
                "name":<value>,
                "unit":{"id":<value>,"name":<value>,"plural":<value>},
                "units":[<value>,..,<value>]
            },
            "nutritionalValues":{"calories":<value>,"carbs":<value>,"fat":<value>,"fiber":<value>,"protein":<value>,"sodium":<value>}
        },
        <..>
    ],
    "summary":{"calories":<value>,"carbs":<value>,"fat":<value>,"fiber":<value>,"protein":<value>,"sodium":<value>,"water":<value>},
    "goals":{
        "calories":<value>,
        "estimatedCaloriesOut":<value>
    }
}

 

Note: Text within [] is a descriptive place holder for a value.

Code Block
bgColor#eeeeee
titleBGColor#3ec1c1
borderStylesolid
titleXML Response
borderStylesolid
<?xml version="1.0" encoding="UTF-8"?>
 <result>
     <foods>
         <foodLog>
             <isFavorite>[value]</isFavorite>
             <logDate>[value]</logDate>
             <logId>[value]</logId>
             <loggedFood>
                 <accessLevel>[value]</accessLevel>
                 <amount>[value]</amount>
                 <brand>[value]</brand>
                 <calories>[value]</calories>
                 <foodId>[value]</foodId>
                 <mealTypeId>[value]</mealTypeId>
                 <locale>[value]</locale>
                 <name>[value]</name>
                 <unit>
                     <id>[value]</id>
                     <name>[value]</name>
                     <plural>[value]</plural>
                 </unit>
                 <units>
                     <integer> <long>[value]</integer>long>
                     [..]
                 </units>
             </loggedFood>
             <nutritionalValues>
                 <calories>[value]</calories>
                 <carbs>[value]</carbs>
                 <fat>[value]</fat>
                 <fiber>[value]</fiber>
                 <protein>[value]</protein>
                 <sodium>[value]</sodium>
             </nutritionalValues>
         </foodLog>
     </foods>
     <summary>
         <calories>[value]</calories>
         <carbs>[value]</carbs>
         <fat>[value]</fat>
         <fiber>[value]</fiber>
         <protein>[value]</protein>
         <sodium>[value]</sodium>
         <water>[value]</water>
     </summary> 
     <goals>
         <calories>[value]</calories>
         <estimatedCaloriesOut>[value]</estimatedCaloriesOut>
     </goals>
 </result>
Panel

1. <units> field contains references to respective Food Units. <accessLevel> could be PUBLIC, PRIVATE or SHARED. <goals> section includes either manual calorie target or dynamic food goal value for specific date.
2. Note that <foodId> field could have zero value (<foodId>0</foodId>) for those log entries that were created without a link to the food in the Food database.
3. Calorie consumption goal (<calories>) represents either Food GoalPlan's dynamic daily target (if it is activated for the user) or manual calorie goal. Goals are included to the response only for today and 21 days in the past. We include <estimatedCaloriesOut> only for today as for the dates in the past they are exactly matching the <caloriesOut>.

 

Examples

Code Block
bgColor#eeeeee
titleBGColor#3ec1c1
borderStylesolid
titleJSON Response
borderStylesolid
{
    "foods":[
        {
            "isFavorite":true,
            "logDate":"2011-06-29",
            "logId":1820,
            "loggedFood":{
                "accessLevel":"PUBLIC",
                "amount":132.57,
                "brand":"",
                "calories":752,
                "foodId":18828,
                "mealTypeId":4,
                "locale":"en_US",
                "name":"Chocolate, Milk",
                "unit":{"id":147,"name":"gram","plural":"grams"},
                "units":[226,180,147,389]
            },
            "nutritionalValues":{"calories":752,"carbs":66.5,"fat":49,"fiber":0.5,"protein":12.5,"sodium":186}
        }
    ],
    "summary":{"calories":752,"carbs":66.5,"fat":49,"fiber":0.5,"protein":12.5,"sodium":186,"water":0},
    "goals":{
        "calories": 2286
    }
}
Code Block
bgColor#eeeeee
titleBGColor#3ec1c1
borderStylesolid
titleXML Response
borderStylesolid
<?xml version="1.0" encoding="UTF-8"?>
 <result>
     <foods>
         <foodLog>
             <isFavorite>true</isFavorite>
             <logDate>2011-06-29</logDate>
             <logId>1924</logId>
             <loggedFood>
                 <accessLevel>PUBLIC</accessLevel>
                 <amount>132.57</amount>
                 <brand/>
                 <calories>752</calories>
                 <foodId>18828</foodId>
                 <mealTypeId>4</mealTypeId>
                 <locale>en_US</locale>
                 <name>Chocolate, Milk</name>
                 <unit>
                     <id>147</id>
                     <name>gram</name>
                     <plural>grams</plural>
                 </unit>
                 <units>
                     <integer>226< <long>226</integer>long>
                     <integer>180< <long>180</integer>long>
                     <integer>147< <long>147</integer>long>
                     <integer>389< <long>389</integer>long>
                 </units>
             </loggedFood>
             <nutritionalValues>
                 <calories>752</calories>
                 <carbs>66.5</carbs>
                 <fat>49</fat>
                 <fiber>0.5</fiber>
                 <protein>12.5</protein>
                 <sodium>186</sodium>
             </nutritionalValues>
         </foodLog>
     </foods>
     <summary>
         <calories>752</calories>
         <carbs>66.5</carbs>
         <fat>49</fat>
         <fiber>0.5</fiber>
         <protein>12.5</protein>
         <sodium>186</sodium>
         <water>0</water>
     </summary>
     <goals>
         <calories>2286</calories>
     </goals>
 </result>