FatSecret Platform API Documentation

Profile - Foods: Create

OAuth 1.0 Latest Premier Exclusive
Description

Creates a food for the user according to the parameters specified. The result of the call is the new unique identifier of the newly created food.

Updates to food labels

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

Please find more information on how to calculate the %DV for your users: Dietary Supplement Label Database

What are the differences between food.create and food.create.v2?
food.create food.create.v2
The Vitamin A value is the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Vitamin A value is the raw value in micrograms (mcg).
It is up to the developer to calculate the %DV (Percent Daily Value)
The Vitamin C value is the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Vitamin C value is the raw value in milligrams (mg).
It is up to the developer to calculate the %DV
The Calcium value is the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Calcium value is the raw value in milligrams (mg).
It is up to the developer to calculate the %DV
The Iron value is the percentage of daily recommended.
It is based on a 2000 calorie diet.
The Iron value is the raw value in milligrams (mg).
It is up to the developer to calculate the %DV
--- Vitamin D is the raw value in micrograms (mcg).
--- Added Sugars is the raw value in grams (g).
It is new for our food_type = "Brand"
Parameters
All
NAME TYPE REQUIRED DESCRIPTION
method String Required MUST be "food.create.v2"
brand_type String Required Either "manufacturer", "restaurant" or "supermarket" (default value is "manufacturer")
brand_name String Required Brand name, only when food_type is "Brand". E.G.: "Quaker"
food_name String Required Name of the food, not including the brand name. E.G.: "Instant Oatmeal"
serving_size String Required Full description of the serving size. E.G.: "1 serving"
calories Decimal Required Energy content in kcal
fat Decimal Required Total fat content in grams
carbohydrate Decimal Required Total carbohydrate content in grams
protein Decimal Required Protein content in grams
serving_amount String Optional The quantity combined with serving_amount_unit to derive the total standardized quantity of the serving
serving_amount_unit String Optional 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 Optional The energy content in kcal from fat
saturated_fat Decimal Optional Saturated fat content in grams (where available)
polyunsaturated_fat Decimal Optional Polyunsaturated fat content in grams (where available)
monounsaturated_fat Decimal Optional Monounsaturated fat content in grams (where available)
trans_fat Decimal Optional Trans fat content in grams (where available)
cholesterol Decimal Optional Cholesterol content in milligrams (where available)
sodium Decimal Optional Sodium content in milligrams (where available)
potassium Decimal Optional Potassium content in milligrams (where available)
fiber Decimal Optional Fiber content in grams (where available)
sugar Decimal Optional Sugar content in grams (where available)
added_sugars Decimal Optional Added Sugars content in grams (where available)
vitamin_d Decimal Optional Vitamin D content in micrograms (where available)
vitamin_a Decimal Optional Vitamin A content in micrograms (where available)
vitamin_c Decimal Optional Vitamin C content in milligrams (where available)
calcium Decimal Optional Calcium content in milligrams (where available)
iron Decimal Optional Iron content in milligrams (where available)
region String Optional Results will be filtered by region. E.G.: "FR" returns results from France
language String Optional (Ignored unless region is also specified) Results will be in the specified language. E.G.: "fr" returns results in French
format String Optional The desired response format. Valid response formats are "xml" or "json" (default value is "xml").
Response
The only storable value returned by this call is food_id.

Each food_id element contains information as follows:

NAME TYPE DESCRIPTION
food_id Long Unique food identifier

Example Response

Example 1:

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

Example 1:

{
  "food_id": {
    "value": "1111111"
  }
}
Error Codes
CODE TYPE DESCRIPTION
2 OAuth 1.0 Missing required oauth parameter: '<details>'
3 OAuth 1.0 Unsupported oauth parameter: '<details>'
4 OAuth 1.0 Invalid signature method: '<details>'
5 OAuth 1.0 Invalid consumer key: '<details>'
6 OAuth 1.0 Invalid/expired timestamp: '<details>'
7 OAuth 1.0 Invalid/used nonce: '<details>'
8 OAuth 1.0 Invalid signature: '<details>'
9 OAuth 1.0 Invalid access token: '<details>'
101 Parameter Missing required parameter: '<details>'
108 Parameter Invalid Type: '<details>'