Search foods by name

Search foods the way a food-diary user types them. Results mix two catalogs: generic foods ("banana", "whole milk"), which are what a diary entry usually refers to, and packaged products from the Tuduu master catalog. Each result already carries its macronutrients per 100 g and its portion, so listing a search result needs no follow-up call. Pages hold 15 items and their size is not configurable. Up to 5 generic foods open the first page when the query matches any; everything after them, on that page and on every later one, comes from the packaged catalog. To scroll, send back the 'meta.nextCursor' you received, with no 'searchText' needed: the cursor already carries the query, and it wins if you send both. A null 'nextCursor' means there is nothing more. Scrolling stops after the first 1000 packaged items — refine the query to reach beyond that. Matching tolerates accents, singular/plural and extra modifiers: "caffè zuccherato" returns coffee rather than an empty list. Only foods with known calories are returned; packaged results are restricted to edible categories and to products that declare a brand, because a product described by nothing but its name cannot be told apart from its duplicates — those products stay addressable by id. Packaged results declaring a portion come first. Italian only: this endpoint answers 406 for any other Accept-Language, because generic food names exist in Italian alone.

POST
/foods/search
Foods
Cost: 20 credits

Request

application/json
object

FoodSearchRequest

object

searchText?

Free-text food name to search for, as a diary user would type it. Required to start a search; ignored when 'cursor' is also sent

string | null

cursor?

Opaque token returned as 'meta.nextCursor' by a previous call, to fetch the page after that one. It already carries the query, so 'searchText' is not needed and is ignored when both are sent. Send no cursor to start a new search

string | null