Food Log

Preview server-authoritative macros for a (food_id, quantity, unit) tuple

post/api/food-log/preview-macros

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/preview-macros
  • Auth
    HTTP bearer

Request body

food_idstring required

FatSecret food id

quantitynumber required
unitstring required

Unit label (g, oz, each, large, …)

serving_idstring

FatSecret serving_id the user picked from the food's servings array. When provided, the recompute uses THAT serving's per-serving nutrition and metric reference instead of the FS default. Required for foods whose servings are not linear scalings of each other (raw vs cooked, with-skin vs without, piece vs volume) — without it, preview anchors on the wrong baseline. When the id does not match any serving the food currently exposes, falls back to the FS default and logs a warning.

regionstring

FatSecret region override. Currently advisory only — getFoodDetails is region-agnostic, so the value is echoed back in the response but does not affect the FS lookup. Matches createFoodLog/editFoodLog behavior. Reserved for future region-scoped lookups.

Example request

{
  "food_id": "12345",
  "quantity": 70,
  "unit": "g",
  "serving_id": "57969",
  "region": "US"
}

Response

unknown required

Example response

{
  "mode": "server_authoritative",
  "food_id": "33691",
  "name": "Chicken Breast",
  "quantity": 4,
  "unit": "oz",
  "serving_id": "57969",
  "region": null,
  "scale": 1.134,
  "calories": 221,
  "protein": 33.5,
  "carbs": 0,
  "fat": 8.8,
  "fiber": 0,
  "sugar": 0,
  "sodium": 84,
  "nutrition": [
    {
      "name": "Calories",
      "value": 221,
      "unit": "kcal"
    },
    {
      "name": "Protein",
      "value": 33.5,
      "unit": "g"
    },
    {
      "name": "Carbohydrates",
      "value": 0,
      "unit": "g"
    },
    {
      "name": "Fat",
      "value": 8.8,
      "unit": "g"
    },
    {
      "name": "Fiber",
      "value": 0,
      "unit": "g"
    },
    {
      "name": "Sodium",
      "value": 84,
      "unit": "mg"
    }
  ],
  "fs_default": null
}

Changes

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