Analysis API
#
Endpoint/analysis
#
MethodGET
and PUT
#
DescriptionThe Analysis API performs an analysis of food items from a provided description and/or an image or image URL. It uses SnapCalorie's proprietary model to interpret the input and returns a JSON representation of identified foods and their quantities with corresponding nutrition. Read about our prior research where our team achieved twice the accuracy on nutrition from an image compared to professional nutritionists.
#
URLhttps://us-central1-snapcalorieb2bapi.cloudfunctions.net/analysis
#
Parameterskey
: The API key for authentication (required).description
: Free text description of food items (optional)*.image_url
orimage
: Attached image or URL of an image containing food items (optional)*.
*At least one of description or image must be present.
#
Sample Requestcurl -X GET 'https://us-central1-snapcalorieb2bapi.cloudfunctions.net/analysis?key=YOUR_API_KEY&description=YOUR_DESCRIPTION&image_url=YOUR_IMAGE_URL'
#
Sample ResponsesSuccess Response:
{ "code": 200, "success": true, "data": [ { "name": "big mac", "brand": "McDonald's", "nutrition_per_100g": { // Guaranteed fields "mass_g": 100, "calories_kcal": 225, "carb_g": 18.75, "fat_g": 11.6667, "protein_g": 10.4167, // Detailed Nutrients, if available // All possible fields are shown here, but if a nutrient is not availble, // it will not be present in the response. // Vitamins "b1_mg": , "b2_mg": , "b3_mg": , "b5_mg": , "b6_mg": , "b12_mcg": , "folate_mcg": , "vitamin_a_mcg": , "vitamin_c_mg": , "vitamin_d_iu": 0, "vitamin_e_mg": , "vitamin_k_mcg": , // Minerals "calcium_mg": 0, "copper_mg": , "iron_mg": 1.8, "magnesium_mg": , "manganese_mg": , "phosphorus_mg": , "potassium_mg": 150, "selenium_mcg": , "sodium_mg": 420, "zinc_mg": , // Carbohydrates "fiber_g": 1.2, "starch_g": , "sugar_g": 3.5, // Lipids aka Fats "monounsaturated_g": , "polyunsaturated_g": , "omega_3_fatty_acids_g": , "omega_6_fatty_acids_g": , "saturated_fats_g": 3, "trans_fats_g": 0.4, "cholesterol_mg": 35, // Proteins "cystine_g": , "histidine_g": , "isoleucine_g": , "leucine_g": , "lysine_g": , "methionine_g": , "phenylalanine_g": , "threonine_g": , "tryptophan_g": , "tyrosine_g": , "valine_g": , // Other Details "percent_fruit": 0, // Portion of item that is fruit from 0-1 "percent_vegetable": 0.05, // Portion of item that is vegetable from 0-1 "percent_legume_or_nuts": 0, // Portion of item that is legume or nuts from 0-1 "is_beverage": false, "source_urls": ["https://www.mcdonalds.com/us/en-us/product/big-mac.html"], }, "alt_units": [ { "unit": "serving", "weight_in_grams": 240 }, { "unit": "g", "weight_in_grams": 1 }, { "unit": "sandwich", "weight_in_grams": 240 }, { "unit": "calorie", "weight_in_grams": 0.4444 }, ], "default_portion": { "quantity": 1, "unit": "sandwich" }, "selected_portion": { "quantity": 1, "unit": "sandwich" }, "selected_portion_nutrition": { "mass_g": 240, "calories_kcal": 540, "carb_g": 45, "fat_g": 28.0001, "protein_g": 25.0001, // Detailed Nutrients, if available // Same fields as above in nutrition_per_100_g // "b1_mg": , // "b2_mg": , // ... } } ]}
Error Response:
See Error Responses for how the API will signal malformed or failed requests.
#
Notes- Replace
YOUR_API_KEY
,YOUR_DESCRIPTION
, andYOUR_IMAGE_URL
with your actual values. - Ensure that your requests are sent over HTTPS to maintain security.
- The response format is JSON, providing a list of identified food items and their details.
brand
is an optional field that is only set if relevant to the query.