PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2015-10-01 (4 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 231 All time: 7,926 This week: 284Up
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
  Performance   Level  
Name: Dave Smith <contact>
Classes: 47 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 29x

Winner: 6x

 

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

Copyright 2015 Wagon Trader, All Rights Reserved


Description:

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


Files:

ndbwrap.class.php - Main class

example.food.php - 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.search.php - example to search and display foods that match keywords query


Installation:

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


Configuration:

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 http://ndb.nal.usda.gov/ndb/api/doc (select sign up now in
Gaining Access section)

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

$datagovKey - Your data.gov 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.


Usage:

Refer to example files for usage examples.

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

Changelog

0.1

beta release
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.food.php 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.search.php 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  
 0%
Total:231
This week:0
All time:7,926
This week:284Up