The Food Nutrients API allows you to analyze food images and get detailed nutritional information. This reference provides all the details you need to integrate with our API.
Base URL: https://tastyapi.com
All API requests require authentication using an API key. Include your API key in the Authorization header as a Bearer token.
Authorization: Bearer YOUR_API_KEY
You can get an API key by subscribing to one of our plans.
Analyze a food image and get detailed nutritional information.
The food image to analyze. Must be a JPEG or PNG file.
Returns the analysis of the food image with nutritional information.
{
"analysis": {
"foodName": "Grilled Chicken Salad with Balsamic Vinaigrette",
"servingSize": {
"amount": 250,
"unit": "g"
},
"nutrients": {
"calories": {
"amount": 350,
"unit": "kcal"
},
"protein": {
"amount": 30,
"unit": "g"
},
"carbohydrates": {
"amount": 15,
"unit": "g"
},
"fat": {
"amount": 20,
"unit": "g"
},
// Additional nutrients...
},
"dietaryInfo": {
"isVegetarian": false,
"isVegan": false,
"isGlutenFree": true,
// Additional dietary information...
}
}
}
Invalid input. Returned when the request is malformed or missing required parameters.
{
"error": "No image file provided"
}
Authentication failed. Returned when the API key is invalid or expired.
{
"error": "Invalid or expired token",
"paymentUrl": "https://example.com/checkout"
}
The API returns nutritional information in JSON format. Here's a description of the main fields:
Field | Type | Description |
---|---|---|
foodName | string | The name of the food detected in the image |
servingSize | object | Information about the serving size, including amount and unit |
nutrients | object | Detailed nutritional information, including calories, macronutrients, vitamins, and minerals |
dietaryInfo | object | Information about dietary compatibility (vegetarian, vegan, gluten-free, etc.) |
allergens | object | Information about allergens contained in the food |
glycemicInfo | object | Glycemic index and load information |
ingredients | array | List of detected ingredients in the food |
dailyValuePercentages | object | Percentage of daily recommended values for various nutrients |
imageAnalysis | object | Information about the image quality and confidence of the analysis |
This endpoint returns subscription usage information. Here's a description of the fields:
Field | Type | Description |
---|---|---|
status | string | Current status of the subscription (active) |
plan | string | The subscription plan type (Basic, Professional, or Annual) |
usage.total | number | Total API calls allowed in the subscription period |
usage.used | number | Number of API calls used so far |
usage.remaining | number | Number of API calls remaining in the subscription period |
usage.percentUsed | number | Percentage of the total usage limit consumed |
subscription.created | string | ISO timestamp of when the subscription was created |
subscription.expires | string | ISO timestamp of when the subscription will expire |
subscription.daysRemaining | number | Number of days remaining in the current subscription period |
curl -X POST https://tastyapi.com/analyze-image \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@./path/to/food-image.jpg"
curl -X GET https://tastyapi.com/api/usage \
-H "Authorization: Bearer YOUR_API_KEY"
// Analyze Image
const formData = new FormData();
formData.append('image', fileInput.files[0]);
fetch('https://tastyapi.com/analyze-image', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Check Usage
fetch('https://tastyapi.com/api/usage', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// Cancel Subscription
fetch('https://tastyapi.com/api/subscription/cancel', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
# Analyze Image
url = "https://tastyapi.com/analyze-image"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
files = {
"image": open("path/to/food-image.jpg", "rb")
}
response = requests.post(url, headers=headers, files=files)
data = response.json()
print(data)
# Check Usage
usage_url = "https://tastyapi.com/api/usage"
usage_response = requests.get(usage_url, headers=headers)
usage_data = usage_response.json()
print(usage_data)
# Cancel Subscription
cancel_url = "https://tastyapi.com/api/subscription/cancel"
cancel_response = requests.post(cancel_url, headers=headers)
cancel_data = cancel_response.json()
print(cancel_data)
API calls are limited based on your subscription plan:
Plan | Monthly Limit | Price |
---|---|---|
Basic | 5,000 requests | $29 per month |
Professional | 15,000 requests | $69 per month |