{"openapi":"3.0.3","info":{"title":"TastyAPI","version":"1.0.0","description":"Food-nutrition API. Send a food photo or a plain-text description and receive a full nutritional breakdown — calories, macronutrients, vitamins, minerals, allergens, and dietary flags — as JSON. Responses are available in 8 languages.","termsOfService":"https://tastyapi.com/terms","contact":{"name":"TastyAPI Support","email":"support@tastyapi.com","url":"https://tastyapi.com"}},"servers":[{"url":"https://tastyapi.com","description":"Production"}],"externalDocs":{"description":"API reference","url":"https://tastyapi.com/api-reference"},"tags":[{"name":"Analysis","description":"Food image and text analysis"}],"security":[{"bearerAuth":[]}],"paths":{"/analyze-image":{"post":{"tags":["Analysis"],"summary":"Analyze a food image","description":"Identify the food in a photo and return its full nutrition. Send the image as multipart form-data (`image` file field) or as JSON with a base64-encoded `image` string.","operationId":"analyzeImage","parameters":[{"$ref":"#/components/parameters/Lang"},{"name":"breakdown","in":"query","description":"When `true`, include a per-ingredient nutrition breakdown.","required":false,"schema":{"type":"boolean","default":false}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"image":{"type":"string","format":"binary","description":"Food image file (JPEG, PNG, WebP)."}},"required":["image"]}},"application/json":{"schema":{"type":"object","properties":{"image":{"type":"string","description":"Base64-encoded image data."}},"required":["image"]}}}},"responses":{"200":{"$ref":"#/components/responses/Analysis"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/analyze-food":{"post":{"tags":["Analysis"],"summary":"Analyze a food by name or description","description":"Return full nutrition for a food described in plain text. Send the description as the raw request body with `Content-Type: text/plain` (for example, \"grilled chicken salad, 2 cups\").","operationId":"analyzeFood","parameters":[{"$ref":"#/components/parameters/Lang"}],"requestBody":{"required":true,"content":{"text/plain":{"schema":{"type":"string","example":"grilled chicken salad, 2 cups"}}}},"responses":{"200":{"$ref":"#/components/responses/Analysis"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/health":{"get":{"tags":["Analysis"],"summary":"Health check","description":"Returns a plain-text liveness string. No authentication required.","operationId":"health","security":[],"responses":{"200":{"description":"Service is running.","content":{"text/plain":{"schema":{"type":"string","example":"Nutrients API is running"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Pass your API key as a bearer token: `Authorization: Bearer YOUR_API_KEY`."}},"parameters":{"Lang":{"name":"lang","in":"query","description":"Response language. Falls back to the `Accept-Language` header, then English.","required":false,"schema":{"type":"string","enum":["en","es","fr","de","it","pt","ar","tr"],"default":"en"}}},"responses":{"Analysis":{"description":"Nutritional analysis.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalysisResponse"}}}},"BadRequest":{"description":"Missing or malformed input (e.g. no image or empty food name).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"API key is invalid, expired, or over its usage limit.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PaymentRequired":{"description":"No API key supplied, or the subscription requires payment. Includes checkout details.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"ServerError":{"description":"The analysis could not be completed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","example":"No image file provided"}},"required":["error"]},"AnalysisResponse":{"type":"object","description":"Wrapper returned by both analysis endpoints.","properties":{"analysis":{"$ref":"#/components/schemas/FoodNutrients"},"language":{"type":"string","example":"en"}},"required":["analysis","language"]},"FoodNutrients":{"type":"object","properties":{"foodName":{"type":"string","example":"Grilled Chicken Salad"},"servingSize":{"type":"object","properties":{"amount":{"type":"number","example":250},"unit":{"type":"string","example":"g"}},"required":["amount","unit"]},"nutrients":{"type":"object","properties":{"calories":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"kcal"}},"required":["amount","unit"]},"protein":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"g"}},"required":["amount","unit"]},"carbohydrates":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"g"}},"required":["amount","unit"]},"fat":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"g"}},"required":["amount","unit"]},"vitamins":{"type":"object","properties":{"vitaminA":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"IU"}},"required":["amount","unit"]},"vitaminC":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"mg"}},"required":["amount","unit"]},"vitaminD":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"IU"}},"required":["amount","unit"]}}},"minerals":{"type":"object","properties":{"calcium":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"mg"}},"required":["amount","unit"]},"iron":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"mg"}},"required":["amount","unit"]},"potassium":{"type":"object","properties":{"amount":{"type":"number"},"unit":{"type":"string","example":"mg"}},"required":["amount","unit"]}}}},"required":["calories","protein","carbohydrates","fat"]},"allergens":{"type":"object","properties":{"contains":{"type":"array","items":{"type":"string"},"example":["gluten","dairy"]},"mayContain":{"type":"array","items":{"type":"string"},"example":[]}}},"dietaryInfo":{"type":"object","properties":{"isVegetarian":{"type":"boolean"},"isVegan":{"type":"boolean"},"isGlutenFree":{"type":"boolean"},"isKosher":{"type":"boolean"},"isHalal":{"type":"boolean"}}},"preparation":{"type":"object","properties":{"isRaw":{"type":"boolean"},"isCooking":{"type":"boolean"},"isProcessed":{"type":"boolean"}}},"imageAnalysis":{"type":"object","description":"Present for image analysis; reflects input quality and ambiguity.","properties":{"quality":{"type":"number","format":"float","minimum":0,"maximum":1},"multipleFoods":{"type":"boolean"},"needsClarification":{"type":"boolean"}}},"dailyValuePercentages":{"type":"object","description":"Share of FDA Daily Values contributed by the serving.","additionalProperties":{"type":"number"}},"confidence":{"type":"number","format":"float","minimum":0,"maximum":1,"example":0.92},"ingredients":{"type":"array","items":{"type":"string"}},"ingredientBreakdown":{"type":"array","description":"Per-ingredient breakdown; returned only when `breakdown=true`.","items":{"type":"object","properties":{"name":{"type":"string"},"estimatedWeight":{"type":"number","description":"grams"},"macros":{"type":"object","properties":{"calories":{"type":"number"},"protein":{"type":"number"},"carbohydrates":{"type":"number"},"fat":{"type":"number"}}}}}}},"required":["foodName","servingSize","nutrients"]}}}}