Developers

GetCategoryById

Usage

Use this method to get categories from the specified category id in the Knowledge instance:

client.getCategoryById(categoryId:Integer,options:Object).then(function(response){
    //...
});

Mandatory parameters

Name Type Description
categoryId integer The id of the category you wish to retrieve from the Knowledge Base.

Options

Name Type Default Description
maxDepth integer 1 Max children depth from category to downwards. Minimum:-1, this value is reserved for unlimited depth.

Response data format

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

Example

The following example will retrieve category "1" and all its children categories:

client.getCategoryById(1,{
    maxDepth: -1
}).then(function(response){
    response.data.results.forEach(function(result) {
        console.log(`Result(${result.id}): ${result.name}`);
    });
});