Namespace: client

client

Methods

(static) add_item(item_info, callback)

Attempts to add an item, specified by the item_info JSON object, to the PredictionIO database, then calls a callback function on the server's response if the request is successful.
Parameters:
Name Type Description
item_info Object Key-value information about the item to be added.
Requires:
- pio_iid: the id of the item to be added. Should be unique. If this id is already in use, the old record will be overwritten.
- pio_itypes: item types that the item belongs to, as a comma-separated string.

Optional:
- pio_latlng: Latitude and longitude for action in comma-separated doubles, e.g. 12.34,5.67.
- pio_inactive: status of item, 'true' or 'false'.
- pio_startT: start time that item becomes available, in ISO 8601 format or milliseconds since the epoch.
- pio_endT: expiration time that the itme becomes unavailable.
- pio_price: price of item.
- pio_profit: profit from item when it is sold.
Other keys without the prefix 'pio' will be stored with the item.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) add_user(user_info, callback)

Attempts to add a user, specified by the user_info JSON object, to the PredictionIO database, then calls a callback function on the server's response if the request is successful.
Parameters:
Name Type Description
user_info Object Key-value information about the user to be added.
Requires:
- pio_uid: the id of the user to be added. Should be unique. If this id is already in use, the old record will be overwritten.

Optional:
- pio_latlng: Latitude and longitude for action in comma-separated doubles, e.g. 12.34,5.67.
- pio_inactive: status of item, 'true' or 'false'.
Other keys without the prefix 'pio' will be stored with the user.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) delete_item(pio_iid, callback)

Attempts to delete an item from the PredictionIO database, then calls a callback function on the response if the request is successful.
Parameters:
Name Type Description
pio_iid string PredictionIO item id of the item to delete.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) delete_user(pio_uid, callback)

Attempts to delete a user from the PredictionIO database, then calls a callback function on the response if the request is successful.
Parameters:
Name Type Description
pio_uid string PredictionIO userid of the user to delete.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) get_item(pio_iid, callback)

Attempts to get information about an item from the PredictionIO database, then calls a callback function on the response if the request is successful.
Parameters:
Name Type Description
pio_iid string PredictionIO item id of the item to get.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) get_user(pio_uid, callback)

Attempts to get information about a user from the PredictionIO database, then calls a callback function on the response if the request is successful.
Parameters:
Name Type Description
pio_uid string PredictionIO userid of the user to get.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) item_recommendations(engine_name, query, callback)

Attempts to get top N item recommendations for a user, from a recommendation engine, then call a callback function on the server's response if the request is successful.
Parameters:
Name Type Description
engine_name String the name of the engine to query.
query Object Key-value pairs specifying the query.
Requires:
- pio_uid: id of user to get recommendations for.
- pio_n: max number of item recommendations returned.

Optional:
- pio_itypes: types(s) of items to be recommended, comma-separated.
- pio_latlng: Geo search point with latitude and longitude.
- pio_within: bounding distance from geo serach point.
- pio_unit: unit of pio_within, 'km' or 'mi'.
- pio_attributes: custom attributes to be returned.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source:

(static) record(action_info)

Record a user-to-item action in the PredictionIO database.
Parameters:
Name Type Description
action_info Object Key-value information about the action.
Requires:
- pio_uid: the id of the user that took the action.
- pio_iid: the id of the item that the user took action on.
- pio_action: the type of action, from 'rate', 'like', 'dislike', 'view', and 'conversion'.
If pio_action is 'rate', then 'pio_rate' is also required (an integer 1-5).

Optional:
- pio_latlng: Latitude and longitude for action in comma-separated doubles, e.g. 12.34,5.67.
- pio_t: Time of action, in ISO 8601 format or milliseconds since the epoch.
Source:

(static) similar_items(engine_name, query, callback)

Attempts to get top N similar items to a given item, from a recommendation engine, then call a callback function on the server's response if the request is successful.
Parameters:
Name Type Description
engine_name String the name of the engine to query.
query Object Key-value pairs specifying the query.
Requires:
- pio_iid: id of item to get recommendations for.
- pio_n: max number of item recommendations returned.

Optional:
- pio_itypes: types(s) of items to be recommended, comma-separated.
- pio_latlng: Geo search point with latitude and longitude.
- pio_within: bounding distance from geo serach point.
- pio_unit: unit of pio_within, 'km' or 'mi'.
- pio_attributes: custom attributes to be returned.
callback function Callback function to be called when server's response is received. Response is a plain object with properties.
Source: