Setup

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

Copy
1
npm install @wix/blog

or

Copy
1
yarn add @wix/blog

Then import { categories } from @wix/blog:

Copy
1
import { categories } from '@wix/blog'
Was this helpful?
Yes
No

getCategory( )

Gets a category by the specified ID.

The getCategory() function returns a Promise that resolves to a category whose ID matches the specified ID.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about permission scopes.
Copy
function getCategory(categoryId: string, options: GetCategoryOptions): Promise<GetCategoryResponse>
Method Parameters
categoryIdstringRequired

Category ID.


optionsGetCategoryOptions

Options specifying which fields to return.

Returns
Return Type:Promise<GetCategoryResponse>
Was this helpful?
Yes
No

getCategoryBySlug( )

Gets a category by the specified slug.

The getCategoryBySlug() function returns a Promise that resolves to a category whose slug matches the specified slug.

The slug is the end of a category's URL that refers to a specific category. For example, if a category's URL is https://example.com/blog/category/{my-category-slug}, the slug is my-post-slug. The slug is case-sensitive string that is generally derived from the category's label, unless specified otherwise.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about permission scopes.
Copy
function getCategoryBySlug(slug: string, options: GetCategoryBySlugOptions): Promise<GetCategoryBySlugResponse>
Method Parameters
slugstringRequired

Slug of the category to retrieve.

The end of a category's URL. For example, 'https:/example.com/blog/category/{my-category-slug}'. Case sensitive and generally based on the category label if not specified.


optionsGetCategoryBySlugOptions

Options specifying which fields to return.

Returns
Return Type:Promise<GetCategoryBySlugResponse>
Was this helpful?
Yes
No

listCategories( )

Retrieves a list of categories.

The listCategories() function returns a Promise that resolves to a list of up to 100 categories per language in order of their displayPosition starting with 0. The displayPosition is the position in which the categories are displayed in the Category Menu page. By default, categories get added to the bottom of the Category Menu with a displayPosition of -1.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about permission scopes.
Copy
function listCategories(options: ListCategoriesOptions): Promise<ListCategoriesResponse>
Method Parameters
optionsListCategoriesOptions

Filter and paging options.

Returns
Return Type:Promise<ListCategoriesResponse>
Was this helpful?
Yes
No

queryCategories( )

Creates a query to retrieve a list of categories.

The queryCategories() function builds a query to retrieve a list of up to 100 categories per language, and returns a CategoriesQueryBuilder object.

The returned object contains the query definition, which is typically used to run the query using the find() function.

You can refine the query by chaining CategoriesQueryBuilder functions to the query. CategoriesQueryBuilder functions enable you to sort, filter, and control the results that queryCategories returns. Any functions chained to the queryCategories() function are applied in the order that they are called.

queryCategories() runs with these CategoriesQueryBuilder defaults, which you can override.

The following CategoriesQueryBuilder functions are supported for queryCategories(). For a full description of the Categories object, see the object returned for the items property in CategoriesQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),hasSome()
labeleq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
postCounteq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
titleeq(),ne(),startsWith(),hasSome(),exists(),in(),ascending(),descending()
rankeq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
displayPositioneq(),ne(),lt(),le(),gt(),ge(),in(),ascending(),descending()
translationIdeq(),ne(),exists(),in()
languageeq(),ne(),exists(),in(),ascending(),descending()
slughasSome(),ascending(),descending()

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about permission scopes.
Copy
function queryCategories(options: QueryCategoriesOptions): CategoriesQueryBuilder
Method Parameters
optionsQueryCategoriesOptions

Options specifying which fields to return.

Returns
Was this helpful?
Yes
No