Recipe API

Servings Need First-Class Recipe Data

Model yield, serving size, and scalable ingredient quantities explicitly so recipe apps can power nutrition, shopping, and meal planning.

recipe-datanutritionapi-design

Servings are not just display text

Recipe apps often show servings as copy: "serves 4," "makes 12 muffins," or "2 bowls." That is useful to a reader, but it is not enough for a product that scales ingredients, estimates nutrition, builds grocery lists, or recommends recipes for a household. Those features need serving data that can be queried and transformed.

A practical recipe API should treat yield, serving size, and ingredient quantities as related but separate fields. Schema.org's Recipe type includes recipeYield for the quantity produced and recipeIngredient for ingredient entries. Google's recipe structured data guidance also uses recipe yield and ingredients as recipe-level data. That public markup is a good interoperability layer, but app builders usually need more normalized fields behind it.

Separate yield from serving size

recipeYield answers "how much does this recipe make?" Serving size answers "how much does one eating occasion represent?" They are related, but they are not always the same type of value.

A soup might yield 2 liters and be served as 6 bowls. A sheet cake might make one pan and be cut into 16 pieces. A sauce might yield 500 grams while the default serving is 2 tablespoons. If the API stores only servings: 6, clients cannot safely rescale, compare nutrition, or explain the portion unit.

A more useful shape is explicit:

{
  "yield": {
    "amount": 6,
    "unit": "servings",
    "display": "Serves 6"
  },
  "servingSize": {
    "amount": 1,
    "unit": "bowl",
    "grams": null
  }
}

When a gram weight is known, include it. When it is not known, return null rather than inventing precision. That lets product code distinguish unknown weight from a true zero value.

Ingredient quantities need original and normalized forms

Scaling a recipe is hard when quantities live only inside ingredient text. "1 can tomatoes," "a handful of basil," and "salt to taste" should not all be forced into fake numeric precision, but the parts that can be parsed should be available as data.

Spoonacular's recipe information endpoint documents structured ingredient fields such as amount, unit, and original text alongside recipe servings in its food API docs. Edamam's recipe API exposes recipe yield and nutrition-oriented fields in its recipe API documentation. Those API designs point to the same product requirement: keep human-readable ingredient lines, but also expose machine fields where the source supports them.

A builder-friendly ingredient item can look like this:

{
  "display": "2 tablespoons olive oil",
  "quantity": 2,
  "unit": "tablespoon",
  "food": "olive oil",
  "scalable": true,
  "confidence": "parsed"
}

For "salt to taste," the same API can return quantity: null, scalable: false, and preserve the original display text. That is better than pretending every ingredient scales cleanly.

Scaling should be a deliberate API operation

If a recipe serves 4 and the user wants 6 portions, clients can multiply parsed quantities by 1.5. But production apps need guardrails. Some ingredients should scale linearly, some should be rounded to practical shopping units, and some should stay as notes.

Useful fields include:

  • baseServings: the original recipe serving count
  • requestedServings: the target count for a scaled response
  • scaleFactor: the multiplier applied
  • quantityOriginal: the source quantity before scaling
  • quantityScaled: the computed quantity after scaling
  • scalingNote: warnings such as "season to taste" or "round can quantity manually"

That design keeps the math transparent. If a grocery list rounds 1.5 cans to 2 cans, the UI can show why.

Nutrition depends on portion clarity

Nutrition features also depend on serving semantics. Calories per recipe, calories per serving, calories per 100 grams, and calories per grocery package are different values. If an API blurs them, downstream apps will display confident but misleading nutrition.

For recipe and nutrition APIs, include the basis for every nutrition value:

{
  "nutrition": {
    "basis": "perServing",
    "servingsPerRecipe": 6,
    "servingSizeGrams": 340,
    "calories": 420
  }
}

If serving weight is missing, say so. Meal planners can still use the recipe, but they should treat nutrition comparisons as lower confidence.

Builder takeaway

Do not model servings as a single string. Store recipe yield, serving size, ingredient quantities, original ingredient text, scaling confidence, and nutrition basis separately. That gives recipe apps the raw material for reliable meal planning, grocery lists, nutrition views, and AI explanations without making up precision the source data does not provide.

Start Building

One consistent schema on every response. Get a free key and ship in minutes.