Developers

GetCategories

Usage

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

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

Mandatory parameters

This method does not have any mandatory parameters.

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 endpoint. Please refer to the Responses section of that endpoint on the Knowledge API Routes page for the response format.

Example

The following example returns all categories:

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