Nutrition AI API

Getting Started

  1. Obtain an API key from the Spike Team.
  2. Make HTTP requests to the API endpoint, including the necessary parameters.
  3. Parse the JSON responses to extract and utilize the nutritional data within your application.

Usage

Guidelines for End User to get optimal results

  1. Capture a photo of the food you plan to eat, centering on the contents of your plate.
  2. Ensure the meal occupies the majority of the image for better recognition.
  3. Take off any packaging or utensils before snapping the photo.
  4. Keep the background clutter-free; include only your plate or glass without additional items.
  5. Use natural or bright lighting to clearly capture details of the food.
  6. Adjust the angle to minimize items obscuring each other and at a slight angle for the best perspective.
  7. Avoid using filters or enhancements that might alter the food’s appearance.

Requirements & Errors

Image Size

Minimum image size required: 512x512 pixel.


"error": {
        "name": "Error",
        "status": 500,
        "faults": [
            "Image is too small"
        ]
    }

No Food Detected

Computer vision has not detected any food or drink in the provided image.


"error": {
     "name": "Error",
     "status": 400,
     "faults": [
         "No Food Detected"
    ]
}

User ID not found

Bad Request, userUuid must be provided in String format. It is a unique identifier for your end-user that you use internally within your application.


"error": {
     "name": "BadRequestException",
     "status": 400,
     "faults": [
         "userUuid: userUuid must be a string"
    ]
}

Invalid API Key

No or wrong API key provided.


"error": {
   "name": "UnauthorizedException",
   "status": 401,
   "faults": [
       "Invalid API key"
   ]
}

Request is too large

The request entity size can be up to a maximum of 10MB when using an image in Base64 format.


"error": {
    "name": "BadRequestException",
    "status": 413,
    "faults": [
       "RequestEntityTooLarge"
   ]
}

Missing or Incorrect Image URL

The imageLink must be an absolute URL that includes the full protocol (e.g., https://).


"error": {
    "name": "TypeError",
    "status": 500,
    "faults": [
       "Only absolute URLs are supported"
   ]
}

Measurement units

{
    "servingSize": g,
    "calories": kcal,
    "macroNutrients": {
        "carbohydrates": g,
        "proteins": g,
        "fats": g
    }
    "microNutrients": {
        "saturatedFat": g,
        "polyunsaturatedFat": g,
        "monounsaturatedFat": g,
        "transFat": g,
        "fibre": g,
        "sugar": g,
        "cholesterol": mg,
        "sodium": mg,
        "potassium": mg,
        "vitaminA": mcg,
        "vitaminC": mg,
        "calcium": mg,
        "iron": mg
    }
}

Response times

Response times can vary because the AI doesn’t always process images at the same speed. Even with the same photo, the system might take longer due to internal factors in how it analyzes the image and provides nutritional information. This means you might experience different wait times even when scanning the same meal.