Nutritionix API v2.0 Beta NodeJS Client Library
NOTE This library is still in beta and subject to change.
Installation
npm install nutritionix --save
var NutritionixClient = require('nutritionix');
var nutritionix = new NutritionixClient({
appId: 'YOUR_APP_ID',
appKey: 'YOUR_APP_KEY'
});
Execute an autocomplete query
nutritionix.autocomplete({ q: 'chedar che' })
.then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
Execute a natural search
var ingredients = [
'1 tbsp sugar',
'1 red pepper'
];
nutritionix.natural(ingredients.join('\n'))
.then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
Get Item By id
or search resource_id
nutritionix.item({ id: 'zgcjnYV' })
.then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
;
Get Brand By id
nutritionix.brand({ id: 'bV'})
.then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
Standard Search
nutritionix.search.standard({
q:'salad',
limit: 10,
offset: 0,
search_nutrient: 'calories'
}).then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
Brand Search
nutritionix.brand_search({
q: 'just salad',
limit: 10,
offset: 0,
type: 1
}).then(successHandler, errorHandler)
.catch(uncaughtExceptionHandler);
Take a look tests/index.js
for an end to end usecase for these libraries.