{"message":"Perfume Recommendation API","version":"4.0.0","description":"Optimized API for perfume recommendations with efficient batch processing for Apps Script integration","endpoints":{"optimized_batch":{"method":"POST","endpoint":"/batch","description":"⭐ RECOMMENDED: Optimized batch processing for up to 50 customers","content_type":"application/json","max_batch_size":50,"body_format":{"customers":[{"phone":"0769655200","email":"customer@gmail.com","perfume":"Dior Sauvage EDP"}],"fail_fast":false,"max_batch_size":50,"sheet_url":"https://docs.google.com/spreadsheets/d/your-sheet-id/edit#gid=0 (optional)"},"response_format":{"total_requested":"int","total_processed":"int","total_successful":"int","total_failed":"int","results":"array (maintains exact input order)","processing_time_seconds":"float","batch_id":"string","quota_used":"int","quota_remaining":"int"},"benefits":["🚀 Single Google Sheets connection for entire batch","📋 Maintains exact input order in response","🛡️ Comprehensive error handling per customer","⚡ Optimized for Apps Script bulk operations","📊 Built-in quota management and monitoring","🔗 Dynamic Google Sheets URL support","🔥 Up to 50x faster than individual calls"],"apps_script_integration":{"recommended_batch_size":"25-50 rows per API call","example_usage":"Process spreadsheet rows in chunks for optimal performance"}},"single_customer":{"method":"GET","endpoint":"/customer","description":"Process single customer via query parameters","parameters":{"required":["phone OR email (at least one)","perfume (name of purchased perfume)"]},"examples":{"with_phone_and_email":"/customer?phone=0769655200&email=customer@gmail.com&perfume=Dior Sauvage EDP","phone_only":"/customer?phone=0769655200&perfume=Dior Sauvage EDP","email_only":"/customer?email=customer@gmail.com&perfume=Dior Sauvage EDP"}},"legacy_batch":{"method":"POST","endpoint":"/customer","description":"Legacy batch processing (up to 30 customers)","note":"⚠️ Use /batch endpoint instead for better performance","content_type":"application/json","max_batch_size":30}},"functionality":"Automatically detects if customer exists and either updates existing customer or creates new customer with perfume purchase. Perfume rankings are dynamically loaded from Sheet2. Tracks recommendation history to avoid duplicate recommendations.","process":["1. Load perfume rankings from Sheet2 (cached for 5 minutes)","2. Search for customer by phone/email in Sheet1","3. If found: Update customer with new perfume purchase","4. If not found: Create new customer with phone/email/perfume","5. Parse previous recommendations from Recommendation column","6. Determine gender category based on purchase history","7. Generate recommendation excluding purchased + previously recommended perfumes","8. Log new recommendation to Recommendation column","9. Return customer info + recommendation"],"response_format":{"single":"Returns single customer data with recommendation","batch":"Returns array of results with processed_count and error_count"},"google_sheets_integration":{"recommended_approach":"Use POST /batch with optimized batch processing","batch_size":"Process 25-50 rows per API call for optimal performance","rate_limiting":"Built-in batch processing eliminates rate limiting issues","sheet_structure":{"Sheet1":"Customer data (Phone, Email, Perfume Orders, Recommendation, etc.)","Sheet2":"Perfume rankings with 'Men' and 'Women' columns","recommendation_tracking":"New 'Recommendation' column logs all recommendations to avoid duplicates","cache_duration":"5 minutes for perfume rankings"}}}