You can retrieve all the application ids then you can call categories APIs for them, right we dont have any feature to directly get all the categories in company level.
FYR :
const getAllCategories = async () => {
try {
// Fetch and set the OAuth token
const token = await platformConfig.oauthClient.getAccesstokenObj({
grant_type: "client_credentials",
});
platformConfig.oauthClient.setToken(token);
// Initialize platform client
const platformClient = new PlatformClient(platformConfig);
// Fetch applications
const { items: applications } =
await platformClient.configuration.getApplications({
companyId: 8040,
});
// Iterate through each application to fetch departments and categories
for (const app of applications) {
console.log(`Application: ${app.name}`);
const { items: departments } = await platformClient
.application(app._id)
.catalog.getApplicationDepartmentListing({
companyId: "8040",
applicationId: app._id,
});
for (const department of departments) {
console.log(` Department: ${department.name}`);
const categories = await platformClient
.application(app._id)
.catalog.getCategories({
companyId: "8040",
applicationId: app._id,
departmentId: department._id,
});
console.log(JSON.stringify(categories));
}
}
} catch (error) {
console.error("Error fetching categories:", error);
}
};