Developers

GetPopular

Usage

Use this method to retrieve the most clicked content from the knowledge base.

client.getPopular(options:Object).then(function(response){
    //...
});

Mandatory parameters

This method does not have any mandatory parameters.

Options

Name Type Default Description
categoryId string 0 Category identifier from the knowledge base. Category id 0 is reserved for the root. This parameter allows a string with the categories separated by commas. Example: 1,4,5 will search in the categories 1, 4 and 5.
length integer 5 Maximum number of items that may be returned in a collection. Minimum:1. Max:100
offset integer 0 Starting index within the collection of resource result. Minimum:0.
interval string allTime Time interval to retrieve popular content. Possible values: allTime, lastWeek and lastDay.

Response data format

This method calls the Knowledge API’s GET /contents/popular endpoint. Please refer to the Responses section of that endpoint on the Knowledge API Routes page for the response format.

Example

The following example is set to retrieve the 10 to 20 most popular contents of last week from category 1:

client.getPopular({
    categoryId:1,
    length:10,
    offset:10,
    interval: 'lastWeek'
}).then(function(response){
    response.data.results.forEach(function(result) {
        console.log(`Result(${result.id}): ${result.title}`);
    });
});