Skip to main content

Analysis API

Endpoint#

/analysis

Method#

GET

Description#

The Analysis API performs an analysis of food items from a provided description and/or an 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.

URL#

https://us-central1-snapcalorieb2bapi.cloudfunctions.net/analysis

Query Parameters#

  • key: The API key for authentication (required).
  • description: Free text description of food items (optional)*.
  • image_url: URL of an image containing food items (optional)*.

*At least one of description or image_url must be present.

Sample Request#

curl -X GET 'https://us-central1-snapcalorieb2bapi.cloudfunctions.net/analysis?key=YOUR_API_KEY&description=YOUR_DESCRIPTION&image_url=YOUR_IMAGE_URL'

Sample Responses#

  • Success Response:

    {  "code": 200,  "data":    [      {        "name": "Big Mac",        "brand": "McDonald's",        "quantity": 1,        "unit": "burger",        "nutritional_values": {          "calories_kcal": 590,          "carb_g": 46,          "fiber_g": 3,          "sugar_g": 9,          "fat_g": 34,          "protein_g": 25,          "sodium_mg": 1050,          "mass_g": 220,          "vitamin_a_mcg": 0,          "vitamin_c_mg": 0,          "vitamin_d_iu": 0,          "calcium_mg": 120,          "iron_mg": 4.5,          "potassium_mg": 390,          "cholesterol_mg": 85,          "saturated_fats_g": 11,          "trans_fats_g": 1,          "omega_3_fatty_acids_g": 0,          "percent_fruit": 0, // From 0-1          "percent_vegetable": 0.05, // From 0-1          "source_urls": [ "https://fdc.nal.usda.gov/fdc-app.html#/food-details/170720/nutrients" ]        }      }    ]}
  • Error Response:

See Error Responses for how the API will signal malformed or failed requests.

Notes#

  • Replace YOUR_API_KEY, YOUR_DESCRIPTION, and YOUR_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.

Get Started#

Request an API Key