Skip to content

Developer Guide

Recipe to Shopping List API: Build Shoppable Grocery Lists

Shopping lists fail when recipe ingredients are plain text strings. Recipe API links every ingredient across 25,000+ recipes to a stable UUID, structured quantity, unit, preparation note, and substitutions — making deduplication, aisle grouping, and retail SKU mapping straightforward.

Get free API keyRead API docs50 evaluation requests, no card. Every call uses 1 request.

1. What the API returns for every ingredient

On GET /api/v1/recipes/{id}, ingredients are grouped by dish component and every line item carries a typed quantity, unit, preparation, substitutions, and a canonical ingredient_id.

GET /api/v1/recipes/{id} — ingredients[] excerpt
{
  "group_name": "Chili Base",
  "items": [
    {
      "name": "stewing beef",
      "quantity": 910,
      "unit": "g",
      "preparation": "cut into 1.3cm (1/2 inch) cubes",
      "notes": null,
      "substitutions": [],
      "ingredient_id": "09f2eef4-739a-4fca-8b63-97d697257990",
      "nutrition_source": "USDA FoodData Central"
    },
    {
      "name": "garlic",
      "quantity": 2,
      "unit": null,
      "preparation": "peeled",
      "notes": "about 6g",
      "substitutions": [],
      "ingredient_id": "30109e1e-d8e8-4f76-a6f4-82ac5b071fde",
      "nutrition_source": "USDA FoodData Central"
    },
    {
      "name": "salt",
      "quantity": null,
      "unit": null,
      "preparation": null,
      "notes": "to taste",
      "substitutions": [],
      "ingredient_id": "2631739c-2de4-4389-a6e3-ed3d06d0406f",
      "nutrition_source": "USDA FoodData Central"
    }
  ]
}

2. Search ingredients, map aisles, and filter by pantry

Use GET /api/v1/ingredients to search the 10,000+ ingredient catalogue and GET /api/v1/ingredient-categories for the 23 canonical aisle categories. Pass those same UUIDs back into GET /api/v1/recipes?ingredients=... for pantry matching or cart cross-sell.

# 1. Look up canonical ingredient UUIDs (1 request per search)
curl -s "https://recipe-api.com/api/v1/ingredients?q=chickpeas&per_page=5" \
  -H "X-API-Key: $RECIPE_API_KEY"

# 2. Fetch aisle categories for grouping your grocery list (1 request)
curl -s "https://recipe-api.com/api/v1/ingredient-categories" \
  -H "X-API-Key: $RECIPE_API_KEY"

# 3. Find recipes containing ALL specified pantry/cart ingredient UUIDs (1 request)
curl -s "https://recipe-api.com/api/v1/recipes?ingredients=693538c2-09f5-4a24-9460-0d968be35a2f,30109e1e-d8e8-4f76-a6f4-82ac5b071fde" \
  -H "X-API-Key: $RECIPE_API_KEY"

3. Handle real-world aggregation edge cases

Merging across recipes is reliable when you group by (ingredient_id, unit) and keep unquantified staples separate:

Swipe table horizontally →

Ingredient shapeShopping-list ruleWhy it matters
quantity: number, unit: 'g' | 'ml'Sum by (ingredient_id, unit)Metric weights and volumes add cleanly across recipes without string matching.
quantity: number, unit: nullCount-based item (e.g., 2 bay leaves, 6 chilies)Key by (ingredient_id, 'count') and check notes (e.g., 'about 30g') when mapping to retail pack sizes.
quantity: null, notes: 'to taste'Pantry / seasoning listKeep unquantified staples separate so you never display 'NaN salt' in a cart.
preparation: 'diced' vs 'whole'Preserve preparation notes on the line itemYou buy one bunch of garlic at the store, then show per-recipe prep notes when cooking.
GET /api/v1/ingredients/{id}category (23 canonical aisles) + per_100g nutritionMap each ingredient_id to its grocery category (Produce, Legumes, Dairy, Spices) or your retailer's SKU catalog.

4. Runnable Node.js shopping-list merger

Download shopping-list.mjs, set RECIPE_API_KEY in your server environment, and run node shopping-list.mjs on Node.js 22+. It makes 3 requests (1 search + 2 recipe lookups) and prints a deduplicated grocery list.

shopping-list.mjs — downloadable example
// Node.js 22+. Keep RECIPE_API_KEY on your server, never in browser code.
// Fetches 2 dinner recipes (1 search + 2 detail calls = 3 requests) and
// merges their ingredients by stable ingredient_id + unit into a shopping list.
import { pathToFileURL } from "node:url";

export function mergeShoppingList(recipes) {
  const merged = new Map();
  const pantryNotes = [];

  for (const recipe of recipes) {
    for (const group of recipe.ingredients ?? []) {
      for (const item of group.items ?? []) {
        const id = item.ingredient_id ?? item.name.toLowerCase();
        // Keep unquantified items ("to taste") separate from summed amounts.
        if (item.quantity == null) {
          pantryNotes.push({
            ingredient_id: item.ingredient_id ?? null,
            name: item.name,
            notes: item.notes ?? "as needed",
            recipe: recipe.name,
          });
          continue;
        }
        const unitKey = item.unit ?? "count";
        const key = `${id}::${unitKey}`;
        const existing = merged.get(key);
        if (existing) {
          existing.quantity = Math.round((existing.quantity + item.quantity) * 100) / 100;
          if (!existing.recipes.includes(recipe.name)) existing.recipes.push(recipe.name);
          if (item.preparation && !existing.preparations.includes(item.preparation)) {
            existing.preparations.push(item.preparation);
          }
        } else {
          merged.set(key, {
            ingredient_id: item.ingredient_id ?? null,
            name: item.name,
            quantity: item.quantity,
            unit: item.unit,
            preparations: item.preparation ? [item.preparation] : [],
            recipes: [recipe.name],
          });
        }
      }
    }
  }

  return {
    items: [...merged.values()].sort((a, b) => a.name.localeCompare(b.name)),
    pantry_notes: pantryNotes,
  };
}

export async function shoppingListExample(apiKey, fetcher = fetch) {
  if (!apiKey) throw new Error("Set RECIPE_API_KEY to your own API key.");

  async function get(path) {
    const response = await fetcher(`https://recipe-api.com/api/v1/${path}`, {
      headers: { "X-API-Key": apiKey },
      signal: AbortSignal.timeout(30_000),
    });
    if (!response.ok) {
      const retry = response.headers.get("Retry-After");
      throw new Error(
        `Recipe API returned ${response.status}.${
          retry ? ` Retry after ${retry} seconds.` : " Check your key and remaining allowance."
        }`,
      );
    }
    return response.json();
  }

  const query = new URLSearchParams({
    category: "Dinner",
    max_calories: "650",
    per_page: "2",
  });
  const search = await get(`recipes?${query}`);
  if (!Array.isArray(search.data) || !search.data.length) {
    return { recipes: [], shopping_list: { items: [], pantry_notes: [] } };
  }

  const details = [];
  for (const summary of search.data) {
    const detail = await get(`recipes/${encodeURIComponent(summary.id)}`);
    details.push(detail.data);
  }

  return {
    recipes: details.map((r) => ({ id: r.id, name: r.name, yields: r.meta?.yields ?? null })),
    shopping_list: mergeShoppingList(details),
  };
}

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
  try {
    console.log(JSON.stringify(await shoppingListExample(process.env.RECIPE_API_KEY), null, 2));
  } catch (error) {
    console.error(error.message);
    process.exitCode = 1;
  }
}

Check plan rights and caching limits before persisting ingredient catalogs or recipes in a commercial grocery app.

Frequently asked questions

Why use ingredient_id instead of grouping by ingredient name?
Text names drift across recipes ('fresh garlic', 'garlic cloves', 'minced garlic'). Recipe API attaches a stable UUID (ingredient_id) and keeps preparation separate, so grouping by ingredient_id merges duplicates accurately across a full week of meals.
How do I group a shopping list by grocery aisle?
Call GET /api/v1/ingredient-categories to fetch the 23 canonical ingredient categories, and GET /api/v1/ingredients (or /api/v1/ingredients/{id}) to inspect each ingredient's category field. Cache those lookups on paid plans so aisle mapping costs zero extra calls at checkout.
Can I build shoppable recipes that link into a grocery cart?
Yes. Because every recipe ingredient carries a stable ingredient_id, quantity, unit, and optional substitutions array, you map each ingredient_id once to your retailer's SKU or Instacart/grocery fulfillment catalog — and offer substitutions when an item is out of stock.
How does pantry or cart-based recipe discovery work?
Pass comma-separated ingredient UUIDs to GET /api/v1/recipes?ingredients=id1,id2. The API returns recipes containing all specified ingredients, which works for both 'cook what is in my fridge' and 'add one more meal using items already in the cart'.

Related guides

How to Build a Meal Planner
Assemble a 7-day plan by macros, then feed the selected recipes into this merger.
Recipe Nutrition Data Guide
Inspect per-100g USDA nutrition on any ingredient UUID.
Recipe Schema Reference
Full field reference for ingredients[], substitutions, and units.

Build shoppable recipes on clean entities

Test the ingredient endpoints and download the shopping-list script with a free evaluation key — 50 requests, no card.