Nutrition Label API
#
Endpoint/nutrition-label
#
MethodGET
and PUT
#
DescriptionThe Nutrition Label API allows users to parse an image of a nutrition label into the nutrition of the item. It also accepts an optional image of the front of the product package and will parse the name of the item as well.
#
URLhttps://us-central1-snapcalorieb2bapi.cloudfunctions.net/upc
#
Parameterskey
: The API key for authentication (required).image_url
orimage
: The attached image or a URL of an image containing a nutritional label (optional)*.product_image_url
orproduct_image
: The attached image or a URL of an image containing the front of the product package (optional)*.ocr_text
: A ocr text dump string from a nutrition label (optional)*.
*At least one of these is required.
#
Sample Requestcurl -X GET 'https://us-central1-snapcalorieb2bapi.cloudfunctions.net/nutrition-label?key=YOUR_API_KEY&image_url=https://www.fda.gov/files/nfl-howtounderstand-honey.png&product_image_url=http://tiny.cc/fphszz'
#
Sample Responses- Success Response:
{ "code": 200, "success": true, "data": { "name": "Pure Honey", // Food name if present, otherwise the empty string. "alt_units": [ { "unit": "serving", "weight_in_grams": 21 } ], "selected_portion": { "quantity": 1, "unit": "serving" }, "selected_portion_nutrition": { // If field is available and visible on nutriton label. "mass_g": 21, "calories_kcal": 60, "carb_g": 17, "fat_g": 0, "protein_g": 0, "sugar_g": 17, "fiber_g": 0, "sodium_mg": 0, "vitamin_c_mg": 0, "vitamin_d_iu": 0, "calcium_mg": 0, "iron_mg": 0, "potassium_mg": 0, "cholesterol_mg": 0, "saturated_fats_g": 0, "trans_fats_g": 0 }, "nutrition_per_100g": { // This is only returned if mass is visible on the label "mass_g": 100, "calories_kcal": 285.7143, "carb_g": 80.9524, "fat_g": 0, "protein_g": 0,
// Detailed Nutrients if available on label "sugar_g": 80.9524, "fiber_g": 0, "sodium_mg": 0, "vitamin_c_mg": 0, "vitamin_d_iu": 0, "calcium_mg": 0, "iron_mg": 0, "potassium_mg": 0, "cholesterol_mg": 0, "saturated_fats_g": 0, "trans_fats_g": 0 }, }, "product_image_uri": "http://tiny.cc/fphszz"}
- Incomplete Nutrition Label or No Label in Image:
{ "code": 200, "success": false, "text": "Unable to Parse Label"}
- Error Response:
See Error Responses for how the API will signal malformed or failed requests.