PredictionIO-NodeJS-Client icon indicating copy to clipboard operation
PredictionIO-NodeJS-Client copied to clipboard

Node.js client for PredictionIO

PredictionIO Client

Installation

Configuration

Set up PredictionIO credentials

var prediction = require('predictionio');
prediction.config.APP_KEY = '...';
prediction.config.APP_HOST = 'http://localhost:8000' // default

Usage

Manage users

var prediction = require('predictionio');
prediction.user.getUser(userId, customOptions, callback);
prediction.user.createUser(userId, customOptions, callback);
prediction.user.deleteUser(userId, customOptions, callback);

Manage items

var prediction = require('predictionio');
prediction.item.getItem(itemId, customOptions, callback);
prediction.item.postItem(itemId, itemTypes, customOptions, callback);
prediction.item.deleteItem(itemId, customOptions, callback);

Create actions

var prediction = require('predictionio');
prediction.action.rate(userId, itemId, rate, customOptions, callback);
prediction.action.like(userId, itemId, customOptions, callback);
prediction.action.dislike(userId, itemId, customOptions, callback);
prediction.action.view(userId, itemId, customOptions, callback);
prediction.action.conversion(userId, itemId, customOptions, callback);

Fetch similar/recommended items

var prediction = require('predictionio');
prediction.engine.similarItems(engineName, itemId, maxNumber, customOptions, callback);
prediction.engine.recommendedItems(engineName, userId, maxNumber, customOptions, callback);