Build REST API endpoints for recommendation service
Overview
Create FastAPI-based REST endpoints for the recommendation engine.
Endpoints
GET /api/v1/recommendations/{user_id}
Get personalized recommendations for a user
Query params:
-
limit(default: 10, max: 50) -
context(optional): home, search, checkout -
filters(optional): category, price_range
Response:
{
"user_id": "12345",
"recommendations": [
{"item_id": "abc", "score": 0.95, "reason": "similar_users"},
{"item_id": "def", "score": 0.87, "reason": "trending"}
],
"generated_at": "2025-01-15T10:30:00Z"
}
POST /api/v1/feedback
Record user interaction feedback
Tech Stack
- FastAPI
- Pydantic for validation
- Async request handling
Dependencies
- Requires Redis caching (#2 (closed))
- Requires collaborative filtering (#1 (closed))