UPC API
#
Endpoint/upc
#
MethodGET
#
DescriptionThe UPC API allows users to look up nutritional data from a UPC.
#
URLhttps://us-central1-snapcalorieb2bapi.cloudfunctions.net/upc
#
Parameterskey
: The API key for authentication (required).upc
: The barcode number (required)
#
Sample Requestcurl -X GET 'https://us-central1-snapcalorieb2bapi.cloudfunctions.net/upc?key=YOUR_API_KEY&upc=123456789'
#
Sample Responses- Success Response:
{ "code": 200, "success": true, "data": { "name": "Packaged Apple Slices", "nutrition_per_100g": { // Guaranteed fields "mass_g": 100, "calories_kcal": 61, "carb_g": 14.8, "fat_g": 0.15, "protein_g": 0.17,
// 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": 3, "vitamin_c_mg": 4.6, "vitamin_d_iu": , "vitamin_e_mg": , "vitamin_k_mcg": ,
// Minerals "calcium_mg": 5, "copper_mg": , "iron_mg": 0.03, "magnesium_mg": , "manganese_mg": , "phosphorus_mg": , "potassium_mg": 104, "selenium_mcg": , "sodium_mg": 0, "zinc_mg": ,
// Carbohydrates "fiber_g": 2.1, "starch_g": , "sugar_g": 12.1,
// Lipids aka Fats "monounsaturated_g": , "polyunsaturated_g": , "omega_3_fatty_acids_g": 0.051, "omega_6_fatty_acids_g": , "saturated_fats_g": 0, "trans_fats_g": , "cholesterol_mg": 0,
// 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": 1, // Portion of item that is fruit from 0-1 "percent_vegetable": 0, // 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://fdc.nal.usda.gov/fdc-app.html#/food-details/2344711/nutrients" ] }, "alt_units": [ { "unit": "package", "weight_in_grams": 100 }, { "unit": "g", "weight_in_grams": 1 }, { "unit": "serving", "weight_in_grams": 100 }, ], "default_portion": { "quantity": 1, "unit": "serving" }, "selected_portion": { "quantity": 100, "unit": "g" }, "selected_portion_nutrition": { "mass_g": 100, "calories_kcal": 61, "carb_g": 14.8, "fat_g": 0.15, "protein_g": 0.17,
// Detailed Nutrients, if available // Same fields as above in nutrition_per_100_g // "b1_mg": , // "b2_mg": , // ... } }}
- UPC Value Not Found or Non Food Item:
{ "code": 200, "success": false, "data": null, "text": "Upc Not Found"}
- Error Response:
See Error Responses for how the API will signal malformed or failed requests.