Common scenarios
Real features, built from the four levers in Querying. Each one is a request you can lift straight into your app.
Barcode → food lookup
The canonical "scan a product" flow: resolve a barcode to a food with an exact
filter. Empty data means no match in the catalog.
Send the code as scanned. Barcodes are stored as 14-digit GTINs, and the filter
pads your value to that form before matching, so the 12-digit UPC a scanner gives
you (041570110645) resolves the same food as 00041570110645:
curl -G https://api.noms.sh/v1/foods \ --data-urlencode "barcode=041570110645" \ --data-urlencode "include=brand" \ -H "Authorization: Bearer $NOMS_KEY"
Typo-tolerant search box
Power an autocomplete with ?q=. Trim the payload to just what the dropdown shows
with fields[foods], and keep the page small for snappy results. A sparse
fieldset returns exactly the fields you name, so ask for id if you want it
back:
curl -G https://api.noms.sh/v1/foods \ --data-urlencode "q=chedar chese" \ --data-urlencode "fields[foods]=id,name,brand_id" \ --data-urlencode "page_size=5" \ -H "Authorization: Bearer $NOMS_KEY"
Full nutrition breakdown
Render a nutrition label: fetch one food with its nutrients and its serving sizes,
then convert each value to the serving. Nutrition data explains
the model in full; the short version is
value × serving[basis_unit] / 100.
curl -G https://api.noms.sh/v1/foods/TIgbNPnzCIjX \ --data-urlencode "include=nutrients,serving_sizes" \ -H "Authorization: Bearer $NOMS_KEY"
Rank & filter by nutrient
Build a diet or fitness feature, such as "highest-protein meats", by sorting on a
nutrient value and filtering by group. This one trims the payload with
fields[foods], so the rows come back with just the keys the list needs:
curl -G https://api.noms.sh/v1/foods \ --data-urlencode "food_group_id=MEAT" \ --data-urlencode "sort=-nutrient[PROTEIN]" \ --data-urlencode "fields[foods]=id,name,basis_unit" \ --data-urlencode "page_size=3" \ -H "Authorization: Bearer $NOMS_KEY"
Two things to know when you sort on a nutrient. Sorting by it does not put it
in the payload, so add include=nutrients if you want the values. And when you do,
name nutrients in fields[foods] as well, or the sparse fieldset trims the
grafted relation away with everything else you did not ask for.
Keep going
These are starting points. Combine q, filters, sort, include and fields
freely. The API explorer lists every field
and operator you can reach.
Next steps
- Rate limits & quotas: what each plan allows, and how to stay inside it.