New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nutritionix

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nutritionix

Official Nutritionix NodeJS Client Library

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-58.33%
Maintainers
1
Weekly downloads
 
Created
Source

Nutritionix API v2.0 Beta NodeJS Client Library

NOTE This library is still in beta and subject to change.

Installation

npm install nutritionix --save
// Require inside your project
var NutritionixClient = require('nutritionix');
var nutritionix = new NutritionixClient({
    appId: 'YOUR_APP_ID',
    appKey: 'YOUR_APP_KEY'
    // debug: true, // defaults to false
});

Execute an autocomplete query

// This will perform a fuzzy autocomplete query and return suggestions
nutritionix.autocomplete({ q: 'chedar che' })
    .then(successHandler, errorHandler)
    .catch(uncaughtExceptionHandler);
var ingredients = [
  '1 tbsp sugar',
  '1 red pepper'
];

// ensure you are passing a string with queries delimited by new lines.
nutritionix.natural(ingredients.join('\n'))
    .then(successHandler, errorHandler)
    .catch(uncaughtExceptionHandler);

Get Item By id or search resource_id

// this will locate an item by its (id, resource_id, or upc)
nutritionix.item({ id: 'zgcjnYV' })
    .then(successHandler, errorHandler)
    .catch(uncaughtExceptionHandler);
;

Get Brand By id

// this will locate a brand by its id
nutritionix.brand({ id: 'bV'})
    .then(successHandler, errorHandler)
    .catch(uncaughtExceptionHandler);
// This will perform a search. The object passed into this function
// can contain all the perameters the API accepts in the `POST /v2/search` endpoint
nutritionix.search.standard({
  q:'salad',
  // use these for paging
  limit: 10,
  offset: 0,
  // controls the basic nutrient returned in search
  search_nutrient: 'calories'
}).then(successHandler, errorHandler)
  .catch(uncaughtExceptionHandler);
// This will perform a search. The object passed into this function
// can contain all the perameters the API accepts in the `GET /v2/search/brands` endpoint
nutritionix.brand_search({
    q: 'just salad',
    limit: 10,
    offset: 0,
    type: 1 // (1:restaurant, 2:cpg, 3:usda/nutritionix) defaults to undefined
}).then(successHandler, errorHandler)
  .catch(uncaughtExceptionHandler);

Take a look tests/index.js for an end to end usecase for these libraries.

Keywords

FAQs

Package last updated on 23 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc