food.create.v2

Description

Creates a food for the user according to the parameters specified.


Why are we introducing version 2?

On May 27, 2016 the USA Food and Drug Administration (FDA) published new rules on the new Nutrition Facts label for packaged foods to reflect new scientific information,
including the link between diet and chronic diseases such as obesity and heart disease.

Manufacturers in the USA with $10 million or more in annual sales were required to switch to the new label by January 1, 2020; manufacturers with less than $10 million in annual food sales have until January 1, 2021 to comply.

More information can be found here: Changes to the Nutrition Facts Label


What are the differences between food.create (v1) and food.create.v2?

food.create (v1) food.create.v2
The Vitamin A value is posted as the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Vitamin A value is posted as the raw value in micrograms (mcg).
The Vitamin C value is posted as the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Vitamin C value is posted as the raw value in milligrams (mg).
The Calcium value is posted as the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Calcium value is posted as the raw value in milligrams (mg).
The Iron value is posted as the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Iron value is posted as the raw value in milligrams (mg).
It is up to the developer to calculate the %DV
--- Vitamin D is posted as the raw value in micrograms (mcg).
--- Added Sugars is posted as the raw value in grams (g).

Parameters

Required

Name Type Description
oauth_consumer_key String Your API key when you registered as a developer
oauth_signature_method String The method used to generate the signature (only HMAC-SHA1 is supported)
oauth_timestamp Int The date and time, expressed in the number of seconds since January 1, 1970 00:00:00 GMT. The timestamp value must be a positive integer and must be equal or greater than the timestamp used in previous requests
oauth_nonce String A randomly generated string for a request that can be combined with the timestamp to produce a unique value
oauth_version String MUST be "1.0"
oauth_signature String The signature, a consistent reproducible concatenation of the request elements into a single string. The string is used as an input in hashing or signing algorithms.
method String MUST be "food.create.v2"
oauth_token String The key of the profile to use.
brand_type String The type of brand of the food to create. Valid brand types are "manufacturer", "restaurant" and "supermarket" (default value is "manufacturer")
brand_name String The name of the brand to create. E.G.: "Kraft"
food_name String The name of the food to create. E.G.: "Swiss Cheese Singles"
serving_size String The serving size of the food to create. E.G.: "1 slice"
calories Decimal The energy content in kcal
fat Decimal The total fat content in grams
carbohydrate Decimal The total carbohydrate content in grams
protein Decimal The protein content in grams

Optional

Name Type Description
format String The desired response format. Valid reponse formats are "xml" or "json" (default value is "xml").
serving_amount Decimal The quantity combined with serving_amount_unit to derive the total standardized quantity of the serving
serving_amount_unit String The metric unit of measure for the serving size – either "g" or "ml" or "oz" – combined with metric_serving_amount to derive the total standardized quantity of the serving (default value is "g")
calories_from_fat Decimal The energy content in kcal from fat
saturated_fat Decimal The saturated fat content in grams
polyunsaturated_fat Decimal The polyunsaturated fat content in grams
monounsaturated_fat Decimal The monounsaturated fat content in grams
trans_fat Decimal The trans fat content in grams
cholesterol Decimal The cholesterol content in milligrams
sodium Decimal The sodium content in milligrams
potassium Decimal The potassium content in milligrams
fiber Decimal The fiber content in grams
sugar Decimal The sugar content in grams
added_sugars Decimal The Added Sugars content in grams
vitamin_d Decimal The Vitamin D content in micrograms
vitamin_a Decimal The Vitamin A content in micrograms
vitamin_c Decimal The Vitamin C content in milligrams
calcium Decimal The Calcium content in milligrams
iron Decimal The Iron content in milligrams

Response

The result of the call is the new unique identifier of the newly created food.

Example Return XML

<?xml version="1.0" encoding="utf-8" ?>
<food_id xmlns="http://platform.fatsecret.com/api/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://platform.fatsecret.com/api/1.0/ http://platform.fatsecret.com/api/1.0/fatsecret.xsd">1111111</food_id>

Example Return JSON

{ "food_id": {"value": "1111111" }}

Error Code

Code Description
2 Missing required oauth parameter: "<detail>"
3 Unsupported oauth parameter: "<detail>"
4 Invalid signature method: "<detail>"
5 Invalid consumer key: "<detail>"
6 Invalid/expired timestamp: "<detail>"
7 Invalid/used nonce: "<detail>"
8 Invalid signature: "<detail>"
101 Missing required parameter: "<detail>"
108 Invalid Type: "<detail>"
FatSecret Sites
For Developers

For Professionals

For Everyone

FatSecret Platform API

Support
API

About FatSecret

© 2021 FatSecret. All rights reserved.