Nutrition Analysis API Documentation
We have released the OpenAPI specification for the Nutrition Analysis API!
The Edamam B2B API is accessed by sending HTTPS requests on specific URLs as described below. The base URL is https://api.edamam.com, and you obtain the full URL by appending request’s path to the base URL, for example, https://api.edamam.com/api/nutrition-details.
This API covers all key use cases related to recipe and food text natural language processing and nutrition analysis. The API employs NLP (Natural Language Processing) which allows for extraction of food entities from unstructured text.
Covered Use Cases
- Full analysis of food recipes in real time – entity extraction, measure and quantity extraction with computation of the applicable nutrition for the recipe, applicable health and diet labels, and recipe classification for cuisine, meal, and dishtypes. Finally, it adjusts quantity for certain ingredients to account for the cooking process. For example, it calculates oil absorption for fried recipes, excludes solids from stock and broth recipes, calculates marinate absorption for marinates and much more.
- Extraction of food entities with measures and quantities from unstructured text.
- Usage in chatbots transcribing natural speech to text.
The above OpenAPI specification for our API can be found here.
More information on OpenAPI can be found at: https://swagger.io/.
Food Logging
As stated in the specification, the food logging feature can be enabled by changing the “nutrition-type” parameter in the Nutrition Data GET request to “logging.” If you use the food logging context feature it will modify the NLP response in the following ways:
- You can submit items without quantity. We will try to match them and assign quantity to them based on expected serving size
- Only foods ready for direct consumption will be matched – no raw meats, raw dry goods or vegetables which need cooking for example
- Edamam can handle single items and two part compound items only – i.e. “chicken” or “rice AND chicken”. Make sure the URL is encoded properly
Edamam Platform Assistant
The Edamam Platform Assistant is a chatbot integrated into four of Edamam’s API. This can provide an easy to use intuitive interface for your customers. The assistant allows you to submit natural language queries and receive back the necessary API calls needed in order to obtain the data requested by your query.
The Nutrition Analysis API is integrated into this service, allowing the Edamam Platform Assistant to construct requests using all the parameters seen above. The Edamam Platform Assistant Documentation can be found here.
Active User Tracking
In order to have Active User tracking, your app_id should be configured with this feature. If the app_id has been configured with this feature, the header for the user ID becomes mandatory or else an error will occur. If your app_id has not been set up for this feature, requests with it will result in error. Contact us if this is a feature you require.
There are restrictions on valid characters for user_ids. Allowed characters are: a-z/A-Z, 0-9, “-”, “_”, “.”. With a maximum length of 30 characters.
Nutrient Guide
The list of all of the nutrients that may be contained as part of a recipe’s nutritional information under the totalNutrients and the totalDaily section of the response. totalNutrients is the absolute nutrient amount, while totalDaily is the percent of daily recommended nutrient intake.
NTR Code | Name | Unit |
---|---|---|
SUGAR.added | Added sugar | g |
CA | Calcium, Ca | mg |
CHOCDF.net | Carbohydrate (net) | g |
CHOCDF | Carbohydrate, by difference | g |
CHOLE | Cholesterol | mg |
ENERC_KCAL | Energy | kcal |
FAMS | Fatty acids, total monounsaturated | g |
FAPU | Fatty acids, total polyunsaturated | g |
FASAT | Fatty acids, total saturated | g |
FATRN | Fatty acids, total trans | g |
FIBTG | Fiber, total dietary | g |
FOLDFE | Folate, DFE | µg |
FOLFD | Folate, food | µg |
FOLAC | Folic acid | µg |
FE | Iron, Fe | mg |
MG | Magnesium | mg |
NIA | Niacin | mg |
P | Phosphorus, P | mg |
K | Potassium, K | mg |
PROCNT | Protein | g |
RIBF | Riboflavin | mg |
NA | Sodium, Na | mg |
Sugar.alcohol | Sugar alcohols | g |
SUGAR | Sugars, total | g |
THIA | Thiamin | mg |
FAT | Total lipid (fat) | g |
VITA_RAE | Vitamin A, RAE | µg |
VITB12 | Vitamin B-12 | µg |
VITB6A | Vitamin B-6 | mg |
VITC | Vitamin C, total ascorbic acid | mg |
VITD | Vitamin D (D2 + D3) | µg |
TOCPHA | Vitamin E (alpha-tocopherol) | mg |
VITK1 | Vitamin K (phylloquinone) | µg |
WATER | Water | g |
ZN | Zinc, Zn | mg |
Nutrient Structure
The structure of the Nutrients based on what is under the totalNutrients and totalDaily sections of the response.
Field | Type | Description |
---|---|---|
uri |
string | Ontology identifier |
label |
string | Display label |
quantity |
float | Quantity of specified units |
unit |
string | Units |
Response Guide
Ingredient Structure
The structure of the Ingredients based on what is under the ingredients section of the response.
Please note that some plans may not include all of the fields for the ingredient object.
Field | Type | Description |
---|---|---|
foodId |
string | Food identifier |
quantity |
float | Quantity of specified measure |
measure |
Measure | Measure |
weight |
float | Total weight, g |
food |
Food | Food |
foodCategory |
string | Shopping aisle category |
Diet Labels
The list of all possible Diet Labels generated from the nutrient information on the recipes. These labels describe commonly used nutrient level aspects of the recipe.
Type | Web Label | Response Label | Definition |
---|---|---|---|
Diet |
Balanced | BALANCED | Protein/Fat/Carb values in 15/35/50 ratio |
Diet |
High-Fiber | HIGH_FIBER | More than 5g fiber per serving |
Diet |
High-Protein | HIGH_PROTEIN | More than 50% of total calories from proteins |
Diet |
Low-Carb | LOW_CARB | Less than 20% of total calories from carbs |
Diet |
Low-Fat | LOW_FAT | Less than 15% of total calories from fat |
Diet |
Low-Sodium | LOW_SODIUM | Less than 140mg Na per serving |
Health Labels
The list of all possible Health Labels generated from the ingredient information on the recipes. These labels describe commonly used ingredient level aspects of the recipe.
Type | Web Label | Response Label | Definition |
---|---|---|---|
Health |
Alcohol-Cocktail | ALCOHOL_COCKTAIL | Describes an alcoholic cocktail |
Health |
Alcohol-Free | ALCOHOL_FREE | No alcohol used or contained |
Health |
Celery-Free | CELERY_FREE | Does not contain celery or derivatives |
Health |
Crustcean-Free | CRUSTACEAN_FREE | Does not contain crustaceans (shrimp, lobster etc.) or derivatives |
Health |
Dairy-Free | DAIRY_FREE | No dairy; no lactose |
Health |
DASH | DASH | Dietary Approaches to Stop Hypertension diet |
Health |
Egg-Free | EGG_FREE | No eggs or products containing eggs |
Health |
Fish-Free | FISH_FREE | No fish or fish derivatives |
Health |
FODMAP-Free | FODMAP_FREE | Does not contain FODMAP foods |
Health |
Gluten-Free | GLUTEN_FREE | No ingredients containing gluten |
Health |
Immuno-Supportive | IMMUNO_SUPPORTIVE | Recipes which fit a science-based approach to eating to strengthen the immune system |
Health |
Keto-Friendly | KETO_FRIENDLY | Maximum 7 grams of net carbs per serving |
Health |
Kidney-Friendly | KIDNEY_FRIENDLY | Per serving – phosphorus less than 250 mg AND potassium less than 500 mg AND sodium less than 500 mg |
Health |
Kosher | KOSHER | Contains only ingredients allowed by the kosher diet. However it does not guarantee kosher preparation of the ingredients themselves |
Health |
Low Potassium | LOW_POTASSIUM | Less than 150mg per serving |
Health |
Low Sugar | LOW_SUGAR | No simple sugars – glucose, dextrose, galactose, fructose, sucrose, lactose, maltose |
Health |
Lupine-Free | LUPINE_FREE | Does not contain lupine or derivatives |
Health |
Mediterranean | MEDITERRANEAN | Mediterranean diet |
Health |
Mollusk-Free | MOLLUSK_FREE | No mollusks |
Health |
Mustard-Free | MUSTARD_FREE | Does not contain mustard or derivatives |
Health |
No oil added | NO_OIL_ADDED | No oil added except to what is contained in the basic ingredients |
Health |
Paleo | PALEO | Excludes what are perceived to be agricultural products; grains, legumes, dairy products, potatoes, refined salt, refined sugar, and processed oils |
Health |
Peanut-Free | PEANUT_FREE | No peanuts or products containing peanuts |
Health |
Pescatarian | PESCATARIAN | Does not contain meat or meat based products, can contain dairy and fish |
Health |
Pork-Free | PORK_FREE | Does not contain pork or derivatives |
Health |
Red-Meat-Free | RED_MEAT_FREE | Does not contain beef, lamb, pork, duck, goose, game, horse, and other types of red meat or products containing red meat. |
Health |
Sesame-Free | SESAME_FREE | Does not contain sesame seed or derivatives |
Health |
Shellfish-Free | SHELLFISH_FREE | No shellfish or shellfish derivatives |
Health |
Soy-Free | SOY_FREE | No soy or products containing soy |
Health |
Sugar-Conscious | SUGAR_CONSCIOUS | Less than 4g of sugar per serving |
Health |
Sulfite-Free | SULPHITE_FREE | No Sulfites |
Health |
Tree-Nut-Free | TREE_NUT_FREE | No tree nuts or products containing tree nuts |
Health |
Vegan | VEGAN | No meat, poultry, fish, dairy, eggs or honey |
Health |
Vegetarian | VEGETARIAN | No meat, poultry, or fish |
Health |
Wheat-Free | WHEAT_FREE | No wheat, can have gluten though |
Recipe Classification (beta)
As part of the Nutrition Analysis of recipes, the responses include the inferred cuisines (Italian, French, etc.), meals (Breakfast, Dinner, Snack, etc.), and dish type (Breads, Desserts, Omelet, Soup, etc.) of the recipes you submit to the Nutrition Analysis API. The full lists of cuisine, meal, and dish types are listed below.
As this is a beta feature, in order for the reponse to include the inferred recipe classification types, the “beta” parameter must be set to “true” in the request to the API. This “beta” parameter can be used in the OpenAPI documentation at the top of this page.
This feature is currently only enabled on Developer Plans. If you are on an Enterprise Core or Enterprise Unlimited Plan, contact us if interested.
Meal Types
List of all possible Meal Types. The meal types refer to the meals in a day the recipe is commonly consumed in.
Type | Value |
---|---|
mealType |
breakfast |
mealType |
brunch |
mealType |
lunch/dinner |
mealType |
snack |
mealType |
teatime |
Dish Types
List of all possible Dish Types. The dish types refer to the category of food the recipe would fall under.
Type | Value |
---|---|
dishType |
alcohol cocktail |
dishType |
biscuits and cookies |
dishType |
bread |
dishType |
cereals |
dishType |
condiments and sauces |
dishType |
desserts |
dishType |
drinks |
dishType |
egg |
dishType |
ice cream and custard |
dishType |
main course |
dishType |
pancake |
dishType |
pasta |
dishType |
pastry |
dishType |
pies and tarts |
dishType |
pizza |
dishType |
preps |
dishType |
preserve |
dishType |
salad |
dishType |
sandwiches |
dishType |
seafood |
dishType |
side dish |
dishType |
soup |
dishType |
special occasions |
dishType |
starter |
dishType |
sweets |
Cuisine Types
The list of all possible Cuisine Types. The cuisine types refer to the cuisine that the recipe would fall under.
Type | Value |
---|---|
cuisineType |
american |
cuisineType |
asian |
cuisineType |
british |
cuisineType |
caribbean |
cuisineType |
central europe |
cuisineType |
chinese |
cuisineType |
eastern europe |
cuisineType |
french |
cuisineType |
greek |
cuisineType |
indian |
cuisineType |
italian |
cuisineType |
japanese |
cuisineType |
korean |
cuisineType |
kosher |
cuisineType |
mediterranean |
cuisineType |
mexican |
cuisineType |
middle eastern |
cuisineType |
nordic |
cuisineType |
south american |
cuisineType |
south east asian |
cuisineType |
world |
New recipes, resubmission and licensing count
Once you submit a recipe via the API you start paying Edamam a monthly licensing fee for each new analyzed recipe. Sometimes however, you may need to refresh the nutrition data for an already submitted recipe, in case you have lost the nutrition data for example. Submitting a recipe directly will count as analyzing a new recipe, and you will be charged again licensing fee for the nutrition information. To avoid that we’ve implemented a system based on HTTP’s ETag mechanism.
First, each successfully processed recipe will also return a tag in the ETag
response header. This value must be preserved together with the recipe. Then, when resubmitting the recipe, you should include the value in the If-None-Match
request header.
There three possible outcomes:
- You are already using the most up to date version of the Edamam data. That is, you already have the newest version of the nutritional info. In this case, the system will return HTTP status code 304 – Not Modified. Note, that you can force the reevaluation in this case (for example if you lost your data) by passing the
force
parameter. Edamam will know that you are already paying license for the nutrition information for this recipe, and you will not be charged twice. - We have updated our database, the recipe is processed again. In this case you’ll receive the possibly updated nutrition data as well as the updated
ETag
header. You should store that new value and use it for further resubmissions. - The recipe you submitted has been changed by you. As the
ETag
hash contains a “signature” for the recipe content the system will respond with HTTP status code 409 – Conflict. In case you have used the wrongETag
you can use correct the code, or if the recipe has changed you can resubmit the recipe as a new one (that is, without sending theIf-None-Match
header).
Licensing count example. You have analyzed 100 recipes in the first month, 50 the second month and 1 the third month. The first month you will pay a licensing fee for the nutrition of 100 recipes, the second month for 150 and the third for 151. If you don’t analyze any more recipes after the third month you will pay licensing fee for the nutrition for the total of 151 recipes every month thereafter.
Unique food text/ingredient line, resubmission and licensing count
Once you submit an ingredient line via the API you start paying Edamam a monthly licensing fee for each new analyzed ingredient line. Sometimes however, you may need to refresh the nutrition data for an already submitted ingredient line, in case you have lost the nutrition data for example. Submitting an ingredient line directly will count as analyzing a new ingredient line, and you will be charged again licensing fee for the nutrition information. To avoid that we’ve implemented a system based on HTTP’s ETag mechanism.
First, each successfully processed ingredient line will also return a tag in the ETag
response header. This value must be preserved together with the ingredient line. Then, when resubmitting the ingredient line, you should include the value in the If-None-Match
request header.