PHP Classes

USDA PHP Nutritional Products Database Wrapper: Retrieve nutritional data from USDA database

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 242 All time: 7,965 This week: 190Up
Version License PHP version Categories
ndbwrap 0.1GNU General Publi...5PHP 5, Web services, Biology
Description Author

This can retrieve nutritional data from USDA database.

It can send HTTP requests to USDA database service API Web server to perform several types of queries about food products and their nutrients.

Currently it can get information about a given nutrient, get information about a given food product, get information about a list of products or nutrients, and search for food products by keywords.

Innovation Award
PHP Programming Innovation award nominee
November 2015
Number 10
The information about the nutrients contained in each type of food can be useful for applications that deal with food.

This class can get the information about nutrients contained in different types of food retrieving them from the USDA Nutritional Products Database.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 57
All time rank: 639 in United States United States
Week rank: 8 Up1 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Class: ndbwrap
Version: 0.1 beta 10/1/2015

Copyright 2015 Wagon Trader, All Rights Reserved


This class will retrieve nutritional information for food from the USDA Nutritional Database.


ndbwrap.class.php - Main class - example to request and display food information

example.list.php - example to request and display data lists

example.nutrient.php - example to request and display specific nutritional information for foods - example to search and display foods that match keywords query


Upload files to a web accessible location on your server (eg. public_html)


For testing, you can use the supplied API key 'DEMO_KEY'. If you are going to use this class in production
you will need to get you own API key available at (select sign up now in
Gaining Access section)

You can change the following settings in the class to meet your specific needs...

$datagovKey - Your API key.

$ndbFormat - format of request results. Currently only JSON is supported so you should not change this value

$USDAcitation - Recommended citation from the USDA. The USDA data is in the public domain, so there are no
    restrictions for using it, however this citation is the official text for the source.

$dbDomain - URL to REST API. You should only need to change this if the USDA changes their API location.


Refer to example files for usage examples.

Refer to ndbwrap.class.php file for instructions on using methods



beta release
  Files folder image Files  
File Role Description
Accessible without login Plain text file Example Example Usage
Accessible without login Plain text file example.list.php Example Example Usage
Accessible without login Plain text file example.nutrient.php Example Example Usage
Accessible without login Plain text file Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Accessible without login Plain text file manual.txt Doc. Documentation
Plain text file ndbwrap.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,965
This week:190Up
For more information send a message to info at phpclasses dot org.