Skip to content

API_Usage

ryanbsull edited this page Sep 16, 2021 · 5 revisions

Food Data Central API

Usage:

The FDC API stores relevant caloric, macro-nutrient and descriptive data about all foods in their database. Through a GET or POST call including relevant data, one can obtain data about almost all foods currently sold today. The most accurate way to get relevant data would be to sent a GET request with the FDC ID of the food in question, but with only a barcode string then a POST request with a query object is the most realistic utilization of this service.

Example API calls:

FDC ID known:

curl https://api.nal.usda.gov/fdc/v1/food/######?api_key=DEMO_KEY

(######) to be replaced with the FDC ID of the food in question

Barcode known:

curl -XPOST -H "Content-Type:application/json" -d '{"query":"BARCODE HERE"}' https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY

(BARCODE HERE) to be replaced with the barcode string of the food in question

Clone this wiki locally