Setup
To use the Categories API, install the @wix/blog
package using npm or Yarn:
1npm install @wix/blog
or
1yarn add @wix/blog
Then import { categories }
from @wix/blog
:
1import { categories } from '@wix/blog'
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:function getCategory(categoryId: string, options: GetCategoryOptions): Promise<GetCategoryResponse>
Category ID.
Options specifying which fields to return.
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:function getCategoryBySlug(slug: string, options: GetCategoryBySlugOptions): Promise<GetCategoryBySlugResponse>
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.
Options specifying which fields to return.
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:function listCategories(options: ListCategoriesOptions): Promise<ListCategoriesResponse>
Filter and paging options.
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
.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,hasSome() |
label | eq() ,ne() ,startsWith() ,hasSome() ,exists() ,in() ,ascending() ,descending() |
postCount | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,in() ,ascending() ,descending() |
title | eq() ,ne() ,startsWith() ,hasSome() ,exists() ,in() ,ascending() ,descending() |
rank | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,in() ,ascending() ,descending() |
displayPosition | eq() ,ne() ,lt() ,le() ,gt() ,ge() ,in() ,ascending() ,descending() |
translationId | eq() ,ne() ,exists() ,in() |
language | eq() ,ne() ,exists() ,in() ,ascending() ,descending() |
slug | hasSome() ,ascending() ,descending() |
Permission Scopes
For app development, you must have one of the following permission scopes:function queryCategories(options: QueryCategoriesOptions): CategoriesQueryBuilder
Options specifying which fields to return.