Setup

To use the Categories API, install the @wix/forum package using npm or Yarn:

Copy
npm install @wix/forum

or

Copy
yarn add @wix/forum

Then import { categories } from @wix/forum:

Copy
import { categories } from "@wix/forum";
Did this help?

getCategory( )


Developer Preview

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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function getCategory(
  categoryId: string,
  options: GetCategoryOptions,
): Promise<Category>;
Method Parameters
categoryIdstringRequired

ID of the retrieved category.


optionsGetCategoryOptions

Options specifying which fields to return.

Returns
Return Type:Promise<Category>
JavaScript
import { categories } from "@wix/forum"; async function getCategory(categoryId, options) { const response = await categories.getCategory(categoryId, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getCategoryBySlug( )


Developer Preview

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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function getCategoryBySlug(
  slug: string,
  options: GetCategoryBySlugOptions,
): Promise<CategoryResponse>;
Method Parameters
slugstringRequired

URL slug.


optionsGetCategoryBySlugOptions

Options specifying which fields to return.

Returns
Return Type:Promise<CategoryResponse>
JavaScript
import { categories } from "@wix/forum"; async function getCategoryBySlug(slug, options) { const response = await categories.getCategoryBySlug(slug, options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

queryCategories( )


Developer Preview

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.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function queryCategories(
  options: QueryCategoriesOptions,
): Promise<QueryCategoriesResponse>;
Method Parameters
optionsQueryCategoriesOptions

Options for sorting, filtering, paging, and specifying return fields.

Returns
Return Type:Promise<QueryCategoriesResponse>
JavaScript
import { categories } from "@wix/forum"; async function queryCategories(options) { const response = await categories.queryCategories(options); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCategoryCreated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Note: This method registers a callback function as an event handler. Subscribe your app to the relevant event via the Webhooks page in the Wix Dev Center to enable it. For more information, see Handle Events With Webhooks.

Triggered when a category is created.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function onCategoryCreated(handler: function): void;
Method Parameters
handlerfunction

handler(event: CategoryCreatedEnvelope): void | Promise<void>

JavaScript
import { categories } from "@wix/forum"; categories.onCategoryCreated((event) => { // handle your event here });
Did this help?

onCategoryDeleted( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Note: This method registers a callback function as an event handler. Subscribe your app to the relevant event via the Webhooks page in the Wix Dev Center to enable it. For more information, see Handle Events With Webhooks.

Triggered when a category is removed.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function onCategoryDeleted(handler: function): void;
Method Parameters
handlerfunction

handler(event: CategoryDeletedEnvelope): void | Promise<void>

JavaScript
import { categories } from "@wix/forum"; categories.onCategoryDeleted((event) => { // handle your event here });
Did this help?

onCategoryUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Note: This method registers a callback function as an event handler. Subscribe your app to the relevant event via the Webhooks page in the Wix Dev Center to enable it. For more information, see Handle Events With Webhooks.

Triggered when a category is updated.

Permissions
Manage Forums
Read Forums
Learn more about app permissions.
Method Declaration
Copy
function onCategoryUpdated(handler: function): void;
Method Parameters
handlerfunction

handler(event: CategoryUpdatedEnvelope): void | Promise<void>

JavaScript
import { categories } from "@wix/forum"; categories.onCategoryUpdated((event) => { // handle your event here });
Did this help?