POST /api/auth/register
Register a new user in the system
Request body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "securepassword"
}
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer"
}
POST /api/auth/login
Login to get an access token (valid for 4 weeks)
Form data: username (email), password
Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer"
}
GET /api/auth/user
Get current authenticated user's information
Headers: Authorization: Bearer {token}
Response:
{
"name": "John Doe",
"email": "john@example.com"
}
POST /api/analyze/process_image
Upload and process an image using YOLO object detection
Form data: image (file)
Response:
{
"message": "Product extracted successfully",
"product_image_name": "f7e5d4c3-b2a1-4f9e-8d7c-6e5f4d3a2b1c.jpg"
}
GET /api/analyze/get_image/{image_name}
Retrieve a processed image by its name
Path parameters: image_name
Response: Image file (JPEG)
POST /api/analyze/process_ingredient
Process a single ingredient and get detailed analysis
Request body:
{
"name": "Monosodium Glutamate"
}
POST /api/analyze/process_product_ingredients
Process multiple ingredients of a product
Headers: Authorization: Bearer {token}
Request body:
{
"ingredients": ["Sugar", "Salt", "Monosodium Glutamate"],
"user_id": 1
}
POST /api/product/add
Add a new product with ingredients and images
Request body:
{
"name": "Maggi 2-Minute Noodles",
"image_names": ["maggi_front.jpg", "maggi_ingredients.jpg"],
"ingredients": [
"Wheat Flour",
"Palm Oil",
"Salt",
"Monosodium Glutamate"
],
"ingredients_count": 4,
"overall_safety_score": 6.5,
"suitable_diet_types": ["Vegetarian"],
"allergy_warnings": ["Contains Wheat (Gluten)"],
"usage_recommendations": "Consume in moderation",
"health_insights": [
"High sodium content may contribute to high blood pressure"
],
"ingredient_interactions": [
"No significant harmful interactions between ingredients"
],
"key_takeaway": "Convenient food option but should be consumed occasionally",
"user_id": 1,
"timestamp": "2025-04-27T15:30:00Z"
}
POST /api/history/scan
Record a new product scan in user history
Protected endpoints require JWT token in Authorization header:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
Tokens are valid for 4 weeks after login.