npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nutrient-data-laboratory

v1.4.1

Published

API wrapper for the USDA Nutrient Data Laboratory REST API (https://ndb.nal.usda.gov/ndb/api/doc)

Downloads

13

Readme

Node.js | USDA Nutrient Data Laboratory API


Summary

Node.js API wrapper for the USDA Nutrient Data Laboratory REST API

For more information, visit https://ndb.nal.usda.gov/ndb/api/doc

Installation

npm install nutrient-data-laboratory --save

Usage

NutrientDataLaboratory#foodReports()

Parameters

| Parameter | Required | Default | Description | | --- | --- | --- | --- | | api_key | y | n/a | Must be a data.gov registered API key | | ndbno | y | n/a | NDB no. May send as a list of NDB nos. up to a maixum of 20 per request | | type | n | b (basic) | Report type: [b]asic or [f]ull or [s]tats | format | n | JSON | Report format: xml or json |

Example

let ndl = new NutrientDataLaboratory('DEMO_KEY')

ndl.foodReports({
  ndbno: '01009',
  type: 'b'
}, (err, res) => {
  if (err) console.error(err)
  else console.log(res)
})

NutrientDataLaboratory#lists()

Parameters

| Parameter | Required | Default | Description | | --- | --- | --- | --- | | api_key | y | n/a | Must be a data.gov registered API key | | lt | n | f | list type(lt): f = food , n = all nutrients, ns = speciality nutrients, nr = standard release nutrients only,g = food group | | max | n | 50 | maximum number of items to return | | offset | n | 0 | beginning item in the result set | | sort | n | n | sort order: n=name or id (Meaning of id varies by list type: nutrient number for a nutrient list, NDBno for a foods list ,food group id for a food group list | | format | n | JSON | report format: JSON or XML |

Example

let ndl = new NutrientDataLaboratory('DEMO_KEY')

ndl.lists({
  lt: 'f',
  sort: 'n'
}, (err, res) => {
  if (err) console.error(err)
  else console.log(res)
})

NutrientDataLaboratory#nutrientReports()

Parameters

| Parameter | Required | Default | Description | | --- | --- | --- | --- | | api_key |y | n/a | Must be a data.gov registered API key | | fg | n | "" | limit your nutrients to one or more food groups by providing a list of food group ID's via the fg parameter. The default is a blank list meaning no food group filtering will be applied. Up to 10 food groups may be specified. | | format | n | JSON | Report format: xml or json | max | n | 50 | Number of rows to return. The maximum per request is 1,500. | | offset | n | 0 | beginning row in the result set to begin | | nbno | n | n/a | Report the nutrients for a single food identified by it's unique id -- nutrient number | | nutrients | y | n/a | a list of up to a maximum of 20 nutrient_id's to include in the report | | sort | n | f | Sort the list of foods by (f)ood name or nutrient (c)ontent. If you are requesting more than one nutrient and specifying sort = c then the first nutrient in your list is used for the content sort. | | subset | n | 0 | You may indicate all the foods in the SR database or an abridged list from the pull down menu. Set the subset parameter to 1 for the abridged list of about 1,000 foods commonly consumed in the U.S. The default 0 for all of the foods in the database |

Example

let ndl = new NutrientDataLaboratory('DEMO_KEY')

ndl.nutrientReports({
  nutrients: ['205', '204', '208', '269']
}, (err, res) => {
  if (err) console.error(err)
  else console.log(res)
})

NutrientDataLaboratory#search()

Parameters

| Parameter | Required | Default | Description | | --- | --- | --- | --- | | api_key | y | n/a | Must be a data.gov registered API key | | q | n | "" | Search terms | | ds | n | "" | Data source. Must be either 'Branded Food Products' or 'Standard Reference' | | fg | n | "" | Food group ID | | sort | n | r | Sort the results by food name (n) or by search relevance (r) | | max | n | 50 | maximum rows to return | | offset | n | 0 | beginning row in the result set to begin | | format | n | JSON | results format: json or xml |

Example

let ndl = new NutrientDataLaboratory('DEMO_KEY')

ndl.search({
  q: 'butter',
  max: 25,
  offset: 0
}, (err, res) => {
  if (err) console.error(err)
  else console.log(res)
})