Recommendation APIs — Complete Guide
Recommendation APIs — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of ML.NET Tutorial on Toolliyo Academy.
On this page
ML.NET Tutorial · Lesson 58 of 100
Recommendation APIs
Foundations ✓ → Models ✓ → NLP & advanced → MLOps
NLP & advanced · 3 — Recs, text, ONNX · ~10 min · Module 6: Recommendation Systems
What is this?
Recommendation APIs expose scored item lists over HTTP with stable contracts and fallbacks.
Why should you care?
AIPredict ShopNest mobile apps call a .NET API, not an embedded model on the device.
See it live — copy this example
Use a .NET console or Web API project with Microsoft.ML. Run dotnet run after pasting.
app.MapPost("/api/recs/products", (RecRequest req, PredictionEnginePool<UserProduct, ProductScore> pool) =>
{
var scores = req.CandidateIds.Select(id =>
pool.Predict(new UserProduct { UserId = req.UserId, ProductId = id }).Score);
return Results.Ok(scores.Zip(req.CandidateIds).OrderByDescending(x => x.First).Take(req.TopN));
});
What happened?
- Use PredictionEnginePool for thread-safe scoring.
- Accept candidate ids from search, score, return ordered ids.
Practice next
- Register pool in Program.cs.
- MapPost rec endpoint.
- Return id+score JSON.
- Add cache key per user.
- Return explain metadata (category match).
Remember
Pool for inference. Candidates in, ranked out. Stable DTO contract.
AIPredict rec API
App requests top-10 from search candidates.
Outcome: Sub-50ms ranked lists at scale.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!