Recommendation library for Vapor

Recommender for Vapor

A recommender service for Vapor, using the gorse recommender system

Getting started

Added Recommender to your Package.swift

.package(url: "", from: "0.0.1-alpha1"),


Recommender uses gorse to recommend items based on Users ratings. The default config expects the gorse service to be available at

You can use the example docker-compose.yml file:

cd docker
docker-compose build
docker-compose up

Extend you Item's model:

extension Item: RecommendableItem { }

Now you can add ratings (in the context of an authenticated user)

let protected = routes.grouped(User.authenticator())"items", ":itemId", "like") {
  let user = try request.auth.require(User.self)
          return request
              .insertFeedback(userId: try user.requireID().uuidString, itemId: request.parameters.get("itemId")!, rating: 5)
              .map { .ok }

To retrieve a list of recommended items

let protected = routes.grouped(User.authenticator())
protected.get("items", "recommended") {
  let user = try request.auth.require(User.self)
  return Item.recommended(req: request, userId: try user.requireID())

Retrieve a list of popular items

routes.get("items", "popular") {
  return Item.popular(req: Request, number: 10)


Add the following queries:

  • Latest items
  • Random items
  • Similar items


  • Swift Tools
View More Packages from this Author


  • None
Last updated: Wed Mar 15 2023 12:20:48 GMT-0500 (GMT-05:00)