Executive Summary: A skincare routine builder needs structured product data and a way to match it to the user's preferences. This guide shows how to read ingredient lists and find ingredients by function in Node.js, using The Beauty API.

A user looking for moisturizing ingredients gives your app a concrete starting point: look for functions such as humectant or emollient, then show the matching ingredients. With product details and ingredient functions already organized, you can spend your time on the routine-building experience.

Read the product's ingredient data

Start with a full product record from GET /v1/products/{id}. Ingredient data uses a single list, named sections or kit components. This helper reads each list while keeping its component and section labels together:

// Keep each component and section attached to its ingredient list.
function ingredientLists(record, component = null) {
  if (Array.isArray(record.components)) {
    return record.components.flatMap(part => ingredientLists(part, part.name));
  }
  if (Array.isArray(record.ingredient_sections)) {
    return record.ingredient_sections.map(section => ({
      component,
      section: section.heading,
      ingredients: section.ingredients ?? [],
    }));
  }
  return [{ component, section: null, ingredients: record.ingredients ?? [] }];
}

Match ingredients to a preference

Ingredient functions describe their roles in cosmetics. Use them to find matches and show the ingredient names behind each suggestion:

function matchFunctions(product, wantedFunctions) {
  const wanted = new Set(wantedFunctions.map(value => value.toLowerCase()));
  return ingredientLists(product).map(list => ({
    component: list.component,
    section: list.section,
    matches: list.ingredients
      .filter(ingredient => (ingredient.functions ?? []).some(
        value => wanted.has(value.toLowerCase())
      ))
      .map(ingredient => ({
        name: ingredient.name ?? ingredient.label_name,
        position: ingredient.position,
        functions: ingredient.functions,
      })),
  }));
}

// product is the full record fetched by your backend.
const matches = matchFunctions(product, ["humectant", "emollient"]);
console.log(matches);

The result gives your interface something specific to explain: which ingredients match the selected functions, and where they appear in the product or kit. Keep this as preference matching, rather than a medical assessment of the finished product.

Build on a shared ingredient dictionary

Canonical INCI links help you compare ingredients across products without maintaining a separate synonym table. The API also provides ingredient functions, identifiers and reference ratings. Use the field reference to choose the metadata your feature needs.

For a hosted application, fetch records from your server and keep the API key in an environment variable. If you prefer to import the catalogue into your own database, The Complete Archive provides CSV, JSONL and SQLite files with an accompanying schema guide. Its numeric IDs are separate from the API's UUIDs.

Turn matches into a routine

  • Start with product search. Let users choose the products they own or want to try.
  • Explain each match. Show the ingredient name and the function that matches the user's preference.
  • Keep kit components distinct. Present matches under the component they belong to.
  • Add product images. Use the API's image_url, or the Archive's image_name with its image files.

For the complete API flow, see our skincare recommender guide. Product lookup, ingredient matching and discovery give you the building blocks for a routine builder with explanations your users can follow.