Nutritionix - Nutrition Database

FREE
By msilverman
Updated 23 days ago
Food
8.6/10
Popularity Score
550ms
Latency
98%
Success Rate
Reggz4 years ago
error 401 unauthorized accessHello nutriionix team, today I'm testing my application and try to call the nutritionix api, but it said unauthorized access and the API could not understand the request, what should I do to solve this? Here is the error shown:The API could not understand the request. Please review your parameters before making any new attempt. HTTP/1.1 401 Unauthorized They said I must provide appId and appKey, where do I get these key?
msilverman4 years ago
Our API always required an API key.
Reggz4 years ago
Thanks mate. I've just resolved it right before you posted :). Anw, since when did it require an API key?
msilverman4 years ago
You can get your free API key here: https://developer.nutritionix.com/signup Thanks!
Hi Developer, feel free to post your answer:

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.get("https://nutritionix-api.p.rapidapi.com/v1_1/search/cheddar%20cheese?fields=item_name%2Citem_id%2Cbrand_name%2Cnf_calories%2Cnf_total_fat")
.header("X-RapidAPI-Host", "nutritionix-api.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication