You can query for items that trended over past X hours in the following way:
$p('register', {
max: 10, // Large number requested so you can see our full range of items
widget: 'default-widget', // name of widget
opts: {
"rankingKey": "click",
"hoursBehind": 24
},
callback: function(resp) {
console.log(JSON.stringify(resp, null, 2));
console.log("// TEST.");
}
}
);
Note that rankingKey and hoursBehind has been set in opts. Setting hoursBehind to X will make our system return items that trended for the past X hours.
Here are the parameters specific to this endpoint, that you can set in opts:
rankingKeyis the key used to rank the items in decreasing order. The following values are allowed for rankingKey: "click", "visible", "show", "click:visible", "click:show", and "visible:show". Keys with a ":" inside them are interpreted as ratios, so we rank in decreasing order of the ratio of the numerator to the denominator. If a value is not specified here, we return the top items but in an essentially random order.lookupKeyis a key with two possible values: "popular" and "click". The "popular" key restricts consideration to a shortlist of items that have received a lot of views. The "click" key restricts consideration to a shortlist of items that have received a lot of clicks. The default value oflookupKeyis "click".hoursBehindis the number of hours behind to go in this computation. For instance, setting this to 24 means that we will return the top items (based onrankingKeyandlookupKey) over the last 24 hours.
Using the feature through REST API
If you want to use the same feature using REST API, you can define the key-value pairs in
optsabove to the JSON body instead of nesting it intooptsobject. The feature is documented more on the REST API model endpoint page.
