Food API Documentation
A comprehensive guide to using our Food API
API Endpoints
POST /api/v1/images/analyze
Analyzes food in an uploaded image and returns nutritional information.
Request Body:
Form data with the following parameters:
image- The food image file to analyze (JPEG, PNG, or WebP format, max 10MB)
Request Headers:
Authorization- Bearer YOUR_API_KEYContent-Type- Must bemultipart/form-data
Example Response:
{
"data": {
"analysis": {
"meal_name": "Chicken Salad",
"proteins": 25,
"carbohydrates": 15,
"fats": 8,
"total_weight": 350
},
"meta": {
"processing_time": "1.2s"
}
}
}
Error Responses:
400- Invalid image format or corrupted image413- Image file too large (max 10MB)422- No food detected in the image
Rate Limits
Rate limits depend on your subscription plan:
| Plan | Requests per Month | Rate Limit |
|---|---|---|
| Free | 1,000 | 60 per minute |
| Basic | 5,000 | 120 per minute |
| Premium | 25,000 | 300 per minute |
| Pro | 100,000 | 600 per minute |
Error Handling
The API uses standard HTTP response codes to indicate the success or failure of requests:
200 OK- Request succeeded400 Bad Request- Invalid request parameters401 Unauthorized- Authentication failed or API key missing403 Forbidden- Valid API key but insufficient permissions404 Not Found- Resource not found429 Too Many Requests- Rate limit exceeded500 Server Error- Something went wrong on our end
Error Response Format:
{
"error": {
"code": "rate_limit_exceeded",
"message": "You have exceeded your rate limit.",
"details": "Request rate limited. Please try again in 60 seconds."
}
}
API Usage Examples
cURL Example
curl -X POST \ https://foodapi.devco.solutions/api/v1/images/analyze \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: multipart/form-data' \ -F 'image=@/path/to/your/food-image.jpg'
JavaScript Example
const form = new FormData();
form.append('image', imageFile);
fetch('https://foodapi.devco.solutions/api/v1/images/analyze', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: form
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Error:', error);
});
PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://foodapi.devco.solutions/api/v1/images/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => [
'image' => new CURLFile('/path/to/your/food-image.jpg')
],
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error: " . $err;
} else {
$result = json_decode($response, true);
print_r($result);
}
Need more help with our API?
Contact Support