Introduction
With the Categories API, you can create and assign various categories to their events. You can use this API to display similar events on different site pages and sorting events in your dashboard. For example, you can create separate pages for jazz, blues, and folk events, but also pages for different venues. The same jazz event can be displayed on your jazz page and also on your downtown location page.
The Categories API allows you to:
- Assign/unassign events to a category or multiple categories.
- Create, delete, and update categories.
- Reorder events that are assigned to the same category on the Events widget.
- Get the details about all categories.
Terminology
- Category: A way to organize or classify events based on their characteristics or themes.
- Event: A gathering organized by an individual or business for a group of people.
Setup
To use the Categories API, install the @wix/events
package using npm or Yarn:
1npm install @wix/events
or
1yarn add @wix/events
Then import { categories }
from @wix/events
:
1import { categories } from '@wix/events'
Assigns events to a single category.
function assignEvents(categoryId: string, eventId: Array<string>): Promise<void>
Assigns events to multiple categories.
function bulkAssignEvents(categoryId: Array<string>, options: BulkAssignEventsOptions): Promise<BulkAssignEventsResponse>
Assigns filtered events to multiple categories.
function bulkAssignEventsAsync(categoryId: Array<string>, options: BulkAssignEventsAsyncOptions): Promise<void>
Creates new categories.
function bulkCreateCategory(categories: Array<Category>): Promise<BulkCreateCategoryResponse>
Unassigns events from multiple categories.
function bulkUnassignEvents(categoryId: Array<string>, options: BulkUnassignEventsOptions): Promise<BulkUnassignEventsResponse>
Unassigns filtered events from multiple categories.
function bulkUnassignEventsAsync(categoryId: Array<string>, options: BulkUnassignEventsAsyncOptions): Promise<void>
Creates a category.
function createCategory(category: Category): Promise<Category>
Deletes a category.
function deleteCategory(categoryId: string): Promise<void>
Retrieves a list of categories that are not in the HIDDEN
state.
function listEventCategories(eventId: string): Promise<ListEventCategoriesResponse>
Creates a query to retrieve a list of categories.
The queryCategories()
function builds a query to retrieve a list of categories 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 onto the query. CategoriesQueryBuilder
functions enable you to sort, filter, and control the results queryCategories()
returns.
queryCategories()
runs with these CategoriesQueryBuilder
defaults, which you can override:
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() |
name | eq() |
function queryCategories(options: QueryCategoriesOptions): CategoriesQueryBuilder
Unassigns events from a category.
function unassignEvents(categoryId: string, eventId: Array<string>): Promise<void>