To use the Categories API, install the @wix/forum
package using npm or Yarn:
npm install @wix/forum
or
yarn add @wix/forum
Then import { categories }
from @wix/forum
:
import { categories } from "@wix/forum";
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Returns a single category by ID.
You can only call this method when authenticated as a Wix app or Wix user identity.
function getCategory(
categoryId: string,
options: GetCategoryOptions,
): Promise<Category>;
ID of the retrieved category.
Options specifying which fields to return.
import { categories } from "@wix/forum";
async function getCategory(categoryId, options) {
const response = await categories.getCategory(categoryId, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Returns a single category by URL slug.
You can only call this method when authenticated as a Wix app or Wix user identity.
function getCategoryBySlug(
slug: string,
options: GetCategoryBySlugOptions,
): Promise<CategoryResponse>;
URL slug.
Options specifying which fields to return.
import { categories } from "@wix/forum";
async function getCategoryBySlug(slug, options) {
const response = await categories.getCategoryBySlug(slug, options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a list of categories, given the provided paging, filtering, and sorting.
Query Categories runs with these defaults, which you can override:
paging.limit
is 10
paging.offset
is 0
For field support for filters and sorting, see Categories: Supported Filters and Sorting.
To learn about working with Query endpoints, see API Query Language, Sorting and Paging, and Field Projection.
You can only call this method when authenticated as a Wix app or Wix user identity.
function queryCategories(
options: QueryCategoriesOptions,
): Promise<QueryCategoriesResponse>;
Options for sorting, filtering, paging, and specifying return fields.
import { categories } from "@wix/forum";
async function queryCategories(options) {
const response = await categories.queryCategories(options);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a category is created.
function onCategoryCreated(handler: function): void;
handler(event: CategoryCreatedEnvelope): void | Promise<void>
import { categories } from "@wix/forum";
categories.onCategoryCreated((event) => {
// handle your event here
});
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a category is removed.
function onCategoryDeleted(handler: function): void;
handler(event: CategoryDeletedEnvelope): void | Promise<void>
import { categories } from "@wix/forum";
categories.onCategoryDeleted((event) => {
// handle your event here
});
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a category is updated.
function onCategoryUpdated(handler: function): void;
handler(event: CategoryUpdatedEnvelope): void | Promise<void>
import { categories } from "@wix/forum";
categories.onCategoryUpdated((event) => {
// handle your event here
});