Edit
Solved this by using the Get Food (https://dev.fitbit.com/build/reference/web-api/food-logging/#get-food) endpoint after finding a food from the Search Foods endpoint. This inflates the servings property of a food which contains information about all the valid units for that food.
Still confused as to why the Get Food Units endpoint doesn't actually return all the units though.
Original Post
I've been working the with food logging API and have come across an odd issue.
The documentation for the Get Food Units endpoint (https://dev.fitbit.com/build/reference/web-api/food-logging/#get-food-units) states;
"The Get Food Units endpoint returns a list of all valid Fitbit food units in the format requested."
The response from this endpoint (at the time of writing) returns an array of 434 units with ID's up to 557 (note: some ID's are skipped so the unit id is not directly related to the index in the array), however, many foods returned from the Search Foods endpoint contain unit id's way greater than 557.
An example of this is below;
{
"accessLevel": "PUBLIC",
"brand": "",
"calories": 68,
"defaultServingSize": 1,
"defaultUnit": {
"id": 22043,
"name": "medium slice (12 cm x 10 cm x 1.25 cm)",
"plural": "medium slice (12 cm x 10 cm x 1.25 cm)"
},
"foodId": 538572063,
"isGeneric": false,
"locale": "en_GB",
"name": "Sour Dough Bread",
"units": [
22043,
147,
22044,
22045,
20868,
226
]
}
The only 2 units from that example that I can find in the response from the Get Food Units endpoint are 147 (grams) and 226 (oz).
Is the response from that endpoint limited? I can't see anything related to pagination so I'm not sure how to get all the food units back.