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 postman collection example json file provides an example to help you get started quickly you can test it easily by importing it into postman and running it with the sample image already set up { "name" "food analyse", "method" "post", "url" "https //gai spikeapi com/v2/nutrition/detailed analyse", "description" "utilizing advanced image recognition and machine learning algorithms, the api identifies food items within an image and calculates their nutritional content ", "tab" "examples", "examples" { "languages" \[ { "id" "5kt 11ikry2clgd2yd0fb", "language" "yaml", "code" "", "customlabel" "examples" } ], "selectedlanguageid" "5kt 11ikry2clgd2yd0fb" }, "results" { "languages" \[ { "id" "ws9v gib4tg5wcnzmzokl", "language" "200", "customlabel" "", "code" "{\n \\"name\\" \\"grilled salmon salad\\",\n \\"description\\" \\"a healthy salad featuring grilled salmon, mixed greens, and assorted vegetables \\",\n \\"score\\" \\"a\\",\n \\"ingredients\\" \[\n {\n \\"name\\" \\"grilled salmon\\",\n \\"servingsize\\" 150,\n \\"calories\\" 280,\n \\"carbohydrates\\" 0,\n \\"proteins\\" 30,\n \\"fats\\" 18,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 3,\n \\"polyunsaturatedfat\\" 4,\n \\"monounsaturatedfat\\" 7,\n \\"transfat\\" 0,\n \\"fibre\\" 0,\n \\"sugar\\" 0,\n \\"cholesterol\\" 70,\n \\"sodium\\" 50,\n \\"potassium\\" 490,\n \\"vitamina\\" 50,\n \\"vitaminc\\" 0,\n \\"calcium\\" 20,\n \\"iron\\" 0 5\n }\n },\n {\n \\"name\\" \\"mixed greens\\",\n \\"servingsize\\" 50,\n \\"calories\\" 10,\n \\"carbohydrates\\" 2,\n \\"proteins\\" 1,\n \\"fats\\" 0 2,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 0,\n \\"polyunsaturatedfat\\" 0 1,\n \\"monounsaturatedfat\\" 0,\n \\"transfat\\" 0,\n \\"fibre\\" 1,\n \\"sugar\\" 0 5,\n \\"cholesterol\\" 0,\n \\"sodium\\" 10,\n \\"potassium\\" 150,\n \\"vitamina\\" 200,\n \\"vitaminc\\" 15,\n \\"calcium\\" 20,\n \\"iron\\" 0 5\n }\n },\n {\n \\"name\\" \\"broccoli\\",\n \\"servingsize\\" 40,\n \\"calories\\" 14,\n \\"carbohydrates\\" 2 8,\n \\"proteins\\" 1 2,\n \\"fats\\" 0 2,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 0,\n \\"polyunsaturatedfat\\" 0 1,\n \\"monounsaturatedfat\\" 0,\n \\"transfat\\" 0,\n \\"fibre\\" 1 1,\n \\"sugar\\" 1 2,\n \\"cholesterol\\" 0,\n \\"sodium\\" 12,\n \\"potassium\\" 230,\n \\"vitamina\\" 31,\n \\"vitaminc\\" 40,\n \\"calcium\\" 20,\n \\"iron\\" 0 3\n }\n },\n {\n \\"name\\" \\"cauliflower\\",\n \\"servingsize\\" 30,\n \\"calories\\" 7,\n \\"carbohydrates\\" 1 4,\n \\"proteins\\" 0 6,\n \\"fats\\" 0 1,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 0,\n \\"polyunsaturatedfat\\" 0,\n \\"monounsaturatedfat\\" 0,\n \\"transfat\\" 0,\n \\"fibre\\" 0 6,\n \\"sugar\\" 0 6,\n \\"cholesterol\\" 0,\n \\"sodium\\" 15,\n \\"potassium\\" 150,\n \\"vitamina\\" 0,\n \\"vitaminc\\" 20,\n \\"calcium\\" 10,\n \\"iron\\" 0 2\n }\n },\n {\n \\"name\\" \\"zucchini\\",\n \\"servingsize\\" 30,\n \\"calories\\" 5,\n \\"carbohydrates\\" 1,\n \\"proteins\\" 0 4,\n \\"fats\\" 0 1,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 0,\n \\"polyunsaturatedfat\\" 0,\n \\"monounsaturatedfat\\" 0,\n \\"transfat\\" 0,\n \\"fibre\\" 0 3,\n \\"sugar\\" 0 8,\n \\"cholesterol\\" 0,\n \\"sodium\\" 2,\n \\"potassium\\" 150,\n \\"vitamina\\" 10,\n \\"vitaminc\\" 8,\n \\"calcium\\" 10,\n \\"iron\\" 0 2\n }\n },\n {\n \\"name\\" \\"tomato\\",\n \\"servingsize\\" 20,\n \\"calories\\" 4,\n \\"carbohydrates\\" 0 9,\n \\"proteins\\" 0 2,\n \\"fats\\" 0 1,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 0,\n \\"polyunsaturatedfat\\" 0,\n \\"monounsaturatedfat\\" 0,\n \\"transfat\\" 0,\n \\"fibre\\" 0 3,\n \\"sugar\\" 0 6,\n \\"cholesterol\\" 0,\n \\"sodium\\" 1,\n \\"potassium\\" 100,\n \\"vitamina\\" 42,\n \\"vitaminc\\" 6,\n \\"calcium\\" 5,\n \\"iron\\" 0 1\n }\n },\n {\n \\"name\\" \\"parmesan cheese\\",\n \\"servingsize\\" 10,\n \\"calories\\" 43,\n \\"carbohydrates\\" 0 3,\n \\"proteins\\" 3 9,\n \\"fats\\" 3,\n \\"micronutrients\\" {\n \\"saturatedfat\\" 1 9,\n \\"polyunsaturatedfat\\" 0 1,\n \\"monounsaturatedfat\\" 0 8,\n \\"transfat\\" 0,\n \\"fibre\\" 0,\n \\"sugar\\" 0 1,\n \\"cholesterol\\" 9,\n \\"sodium\\" 180,\n \\"potassium\\" 12,\n \\"vitamina\\" 40,\n \\"vitaminc\\" 0,\n \\"calcium\\" 110,\n \\"iron\\" 0 2\n }\n }\n ]\n}" } ], "selectedlanguageid" "ws9v gib4tg5wcnzmzokl" }, "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[ { "name" "x api key", "kind" "required", "type" "string", "description" "your authentication key for accessing the service, which you will obtain from the spike team ", "children" \[] } ], "bodydataparameters" \[ { "name" "useruuid", "kind" "required", "type" "string", "description" "a unique identifier for your end user that you use internally within your application " }, { "name" "imagelink", "kind" "required", "type" "string", "description" "a string containing the url of the meal image use this parameter when your image is hosted online and accessible via a public url ensure that the link points directly to the image file (e g , ends with jpg, png) either imagelink or imagebase64 is required in your request ", "children" \[] }, { "name" " imagebase64", "kind" "required", "type" "string", "description" "a string of the meal image encoded in base64 format use this parameter to send the image directly within the request payload, without the need for external hosting this is useful when you prefer not to expose the image publicly either imagebase64 or imagelink is required in your request ", "children" \[] }, { "name" "config", "kind" "optional", "type" "object", "description" "configurable parameters for each query ", "children" \[ { "name" "language", "kind" "optional", "type" "string", "description" "specifies the language in which the meal information will be delivered; the default is english " }, { "name" "micronutrients", "kind" "optional", "type" "boolean", "description" "specifies whether to include micronutrient information; the default is false " }, { "name" "score", "kind" "optional", "type" "boolean", "description" "specifies whether to include nutri score rating; the default is false" } ], "schema" \[ { "name" "language", "kind" "optional", "type" "string", "description" "specifies the language in which the meal information will be delivered; the default is english " }, { "name" "micronutrients", "kind" "optional", "type" "boolean", "description" "specifies whether to include micronutrient information; the default is false " }, { "name" "score", "kind" "optional", "type" "boolean", "description" "specifies whether to include nutri score rating; the default is false" } ] } ], "formdataparameters" \[] }, "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } usage guidelines for end user for optimal results capture a photo of the food you plan to eat, centering on the contents of your plate ensure the meal occupies the majority of the image for better recognition take off any packaging or utensils before snapping the photo keep the background clutter free; include only your plate or glass without additional items use natural or bright lighting to clearly capture details of the food adjust the angle to minimize items obscuring each other and at a slight angle for the best perspective avoid using filters or enhancements that might alter the food’s appearance requirements & errors image size minimum image size required 512x512 pixel errors "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 errors "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 errors "error" { "name" "badrequestexception", "status" 400, "faults" \[ "useruuid useruuid must be a string" ] } invalid api key no or wrong api key provided errors "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 errors "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 //) errors "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