View on GitHub

foodWeb | Open Source JavaScript Documentation

foodWeb is an open source project that makes it simple to access the USDA's Nutrient Standard Reference Database.

Download this project as a .zip file Download this project as a tar.gz file


foodWeb is an open source project that makes it simple to access the USDA’s Nutrient Standard Reference Database.


$ npm i -S foodweb
$ yarn add foodweb


var foodWeb = require('foodweb');

var item ='cheez it')[0];

// kilocalories in 100 grams
var calories =;
// kilocalories in a serving
var serving = Math.round(( / 100) * calories);
// description of serving
var servingDescription =;

console.log(servingDescription, 'is', serving, 'calories');
// 29 crackers is 135 calories

Note: While foodWeb works best in Node.js, it is fully compatible with client packagers like webpack. See a demo here!

Methods, maxLength)

Search the pre-built index. For more advanced documentation (like using weighting or rough matches) read this documentation.

var foodWeb = require('foodweb');

var term = 'butter'; // the search term
var maxLength = 5; // the maximum number of items to return, maxLength);
 [foodMatch {
     internal: {...},
     score: Number,
     data: foodItem {...}
 }, ...]

Returns an array of foodMatch objects in descending relatedness.



An instance from the internal search library used.


A score and metadata from the internal search library used.


A fraction representing how close the search term was to the matched item.

A foodItem object containing all of the information about the item.


The foodItem has children for all data about the item.



MIT (C) Russell Steadman. Learn more in the LICENSE file.

The source data is released by the USDA under a Creative Commons 4.0 Attributional License. The contents of the files were modified.

Support Me

Like this project? Buy me a cup of coffee. ☕ Here are more of my projects.