Skip to main content

Recommendation API Examples

Lightweight Mode - Send your data directly in the request body

No setup required!

curl -X POST "https://api.trydodo.xyz/api/recommend" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"context": [
{
"product_name": "iPhone 16 512Gb",
"price": 999,
"category": "electronics"
},
{
"product_name": "Rich Dad Poor Dad book",
"price": 10,
"category": "books"
}
],
"catalog": [
"8": {"product_name": "MacBook Pro", "price": 1999, "category": "electronics"},
"4": {"product_name": "iPad Air", "price": 599, "category": "electronics"},
"1": {"product_name": "iPhone 16", "price": 999, "category": "electronics"},
"3": {"product_name": "AirPods Pro", "price": 249, "category": "electronics"},
"5": {"product_name": "Apple Watch", "price": 399, "category": "electronics"},
"6": {"product_name": "Magic Keyboard", "price": 149, "category": "electronics"},
"9": {"product_name": "Magic Mouse", "price": 99, "category": "electronics"},
"7": {"product_name": "Magic Trackpad", "price": 129, "category": "electronics"},
"2": {"product_name": "Apple Pencil", "price": 129, "category": "electronics"},
"10": {"product_name": "USB-C Charge Cable", "price": 19, "category": "accessories"},
],
"template": "Recommend the next product based on the user'\''s purchase history: {context}. Suggest items under $100 that complement these purchases."
}'

Response:

{
"status_code": 200, # successful recommendations
"decision_id": "decision_id", # unique identifier for this recommendation
"results": ["10","9","1","3","5","6","7","2","4"]
}

Performance Mode - Use pre-synced data

There are two options for using pre-synced data:

  1. Re-use entity catalog but different context: Send custom context data while leveraging the pre-synced entity catalog for recommendations.
curl -X POST "https://api.trydodo.xyz/api/recommend" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"context": [
{
"product_name": "iPhone 16 512Gb",
"price": 999,
"category": "electronics"
},
{
"product_name": "Rich Dad Poor Dad book",
"price": 10,
"category": "books"
}
],
"template": "Recommend the next product based on the user'\''s purchase history: {context}. Suggest items under $100 that complement these purchases."
}'
  1. Rigid pipeline (not supported now, future feature): This would require only user-id and rely entirely on pre-synced interaction data and entity catalog without additional context.