Food Log

Paginate alternative matches for a multi-ingredient option (powers the mobile "show more" swap control)

The initial fatsecretSearch response for a multi-ingredient query ships 3 options per ingredient (primary + 2 alternatives). This endpoint returns additional options for a single ingredient — positions offset..offset+limit-1 from FatSecret's search results — in the same FoodOption shape so the mobile client can append to the existing alternatives array without re-fetching the original search. Defaults: offset=3 (skip the 3 already shown), limit=5. Stateless; re-runs searchFoodsWithNutrition on each call.

get/api/food-log/ingredient-alternatives

Request

  • Base URL
    https://api.rewritelifestyle.ai (the document declares no server; this is the origin it was published from)
  • URL
    https://api.rewritelifestyle.ai/api/food-log/ingredient-alternatives
  • Auth
    HTTP bearer

Query parameters

searchTermstring required
Example:ribeye steak

The search term for this ingredient (typically the parsedIngredient / originalName field from a prior fatsecretSearch response).

quantitynumber
Example:30

Quantity the user logged for this ingredient. Needed for correct macro scaling. If omitted, macros scale to FatSecret's default serving.

unitstring
Example:oz

Unit for the quantity (oz / g / cup / tbsp / etc.).

brandstring
Example:chobani

Optional brand hint — if the parser detected a brand in the original query, pass it here so FatSecret re-ranks toward branded matches.

offsetnumber
Example:3

Zero-based result offset. Defaults to 3 (skip the primary + 2 alternatives already shown). Clamped to [0, 20].

limitnumber
Example:5

How many additional alternatives to return. Defaults to 5. Clamped to [1, 20].

Response

unknown required

Example response

{
  "success": true,
  "searchTerm": "ribeye steak",
  "offset": 3,
  "limit": 5,
  "alternatives": [
    {
      "id": "...",
      "name": "Grass-Fed Beef Ribeye Steak",
      "brand": "Butcher Box",
      "quantity": 30,
      "unit": "oz",
      "calories": 2210,
      "protein": 170,
      "fat": 158
    },
    {
      "id": "...",
      "name": "Beef Ribeye Steaks",
      "brand": "Great American Steak Company",
      "quantity": 30,
      "unit": "oz",
      "calories": 2310,
      "protein": 161,
      "fat": 168
    }
  ]
}

Changes

No recorded changes to this operation across all 34 revisions of this API.