> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # QueryCategories # Package: eventManagement # Namespace: CategoryManagement # Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/categories/query-categories.md ## Permission Scopes: Read Events: SCOPE.DC-EVENTS.READ-EVENTS ## Introduction Retrieves a list of categories, given the provided paging, filtering, and sorting. Query Categories runs with these defaults, which you can override: - `name` is sorted in `ASC` order - `paging.limit` is `100` - `paging.offset` is `0` To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection). --- ## REST API ### Schema ``` Method: queryCategories Description: Retrieves a list of categories, given the provided paging, filtering, and sorting. Query Categories runs with these defaults, which you can override: - `name` is sorted in `ASC` order - `paging.limit` is `100` - `paging.offset` is `0` To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection). URL: https://www.wixapis.com/events/v1/categories/query Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: query Method parameters: param name: fieldset | type: array
| description: Predefined sets of fields to return. - `COUNTS`: Returns `assignedEventsCount`. - enum: - COUNTS: Include `assignedEventsCount` in the response. param name: query | type: QueryV2 | required: true - name: paging | type: Paging | description: Pointer to page of results using offset. See [Pagination](https://dev.wix.com/api/rest/getting-started/pagination). - name: limit | type: integer | description: Number of items to load per page. - name: offset | type: integer | description: Number of items to skip in the current sort order. - name: filter | type: object | description: Filter. See [supported fields and operators](https://dev.wix.com/api/rest/wix-events/wix-events/filter-and-sort#wix-events_wix-events_filter-and-sort_list-query-events). - name: sort | type: array | description: Sort object in the form [{"fieldName":"sortField1"},{"fieldName":"sortField2","direction":"DESC"}] See [supported fields](https://dev.wix.com/api/rest/wix-events/wix-events/filter-and-sort#wix-events_wix-events_filter-and-sort_list-query-events). - name: fieldName | type: string | description: Name of the field to sort by - name: order | type: SortOrder | description: Sort order (ASC/DESC). Defaults to ASC - enum: ASC, DESC Return type: QueryCategoriesResponse - name: categories | type: array | description: List of categories. - name: id | type: string | description: Category GUID. - name: name | type: string | description: Category name. - name: createdDate | type: string | description: Date and time when category was created. - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category. - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category. - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded. - name: states | type: array | description: Category state. Default: `MANUAL`. **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`. - enum: - MANUAL: Categoty is created manually by the user. - AUTO: Category is created automatically. - RECURRING_EVENT: Category is created automatically when publishing recurring events. - HIDDEN: Category is hidden. - name: metaData | type: PagingMetadataV2 | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field. - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. ``` ### Examples ### Query categories by name ```curl curl -X POST 'https://www.wixapis.com/events/v1/categories/query' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -d '{ { "query": { "filter": { "name": { "$eq": "food" } } } } ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.eventManagement.CategoryManagement.queryCategories(query, options) Description: Retrieves a list of categories, given the provided paging, filtering, and sorting. Query Categories runs with these defaults, which you can override: - `name` is sorted in `ASC` order - `paging.limit` is `100` - `paging.offset` is `0` To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: query Method parameters: param name: options | type: QueryCategoriesOptions none - name: fieldset | type: array | description: Predefined sets of fields to return. - `COUNTS`: Returns `assignedEventsCount`. - enum: - COUNTS: Include `assignedEventsCount` in the response. param name: query | type: CategoryQuery | required: true - name: paging | type: Paging | description: Pointer to page of results using offset. See [Pagination](https://dev.wix.com/api/rest/getting-started/pagination). - name: limit | type: integer | description: Number of items to load per page. - name: offset | type: integer | description: Number of items to skip in the current sort order. - name: filter | type: object | description: Filter. See [supported fields and operators](https://dev.wix.com/api/rest/wix-events/wix-events/filter-and-sort#wix-events_wix-events_filter-and-sort_list-query-events). - name: sort | type: array | description: Sort object in the form [{"fieldName":"sortField1"},{"fieldName":"sortField2","direction":"DESC"}] See [supported fields](https://dev.wix.com/api/rest/wix-events/wix-events/filter-and-sort#wix-events_wix-events_filter-and-sort_list-query-events). - name: fieldName | type: string | description: Name of the field to sort by - name: order | type: SortOrder | description: Sort order (ASC/DESC). Defaults to ASC - enum: ASC, DESC Return type: PROMISE - name: categories | type: array | description: List of categories. - name: _id | type: string | description: Category GUID. - name: name | type: string | description: Category name. - name: _createdDate | type: Date | description: Date and time when category was created. - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category. - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category. - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded. - name: states | type: array | description: Category state. Default: `MANUAL`. **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`. - enum: - MANUAL: Categoty is created manually by the user. - AUTO: Category is created automatically. - RECURRING_EVENT: Category is created automatically when publishing recurring events. - HIDDEN: Category is hidden. - name: metaData | type: PagingMetadataV2 | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set. - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field. - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. ``` ### Examples ### Retrieve all categories ```javascript import { categories } from '@wix/events'; export async function myQueryCategoriesFunction() { try { const items = await categories.queryCategories() .find(); console.log('Categories: ', items); return items; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "_items": [ * { * "name": "workshop-leather", * "states": [ * "MANUAL" * ], * "_id": "db3e2663-4ed3-43f7-ba68-5d71611702c8", * "_createdDate": "2024-06-20T07:12:41.366Z" * }, * { * "name": "Cosmic Odyssey: Exploring the Mysteries of the ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "a03a6667-2ada-45d6-9835-834351ab995f", * "_createdDate": "2024-04-30T10:31:56.791Z" * }, * { * "name": "Mindful Living Retreat: Nurturing Wellness and ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "eebe3ed6-ffef-46e4-a83a-e883d7ad8fdd", * "_createdDate": "2023-07-13T13:42:12.833Z" * }, * { * "name": "food", * "states": [ * "MANUAL" * ], * "_id": "bd964127-63ff-47e0-92af-8714037de8c9", * "_createdDate": "2023-07-12T12:40:57.129Z" * }, * { * "name": "technology", * "states": [ * "MANUAL" * ], * "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88", * "_createdDate": "2023-07-12T11:07:35.776Z" * }, * { * "name": "science", * "states": [ * "MANUAL" * ], * "_id": "4a69c13e-eb55-47a8-8ccf-9b55198428a0", * "_createdDate": "2023-07-12T10:51:00.029Z" * }, * { * "name": "Professional Leather Handbag, a course by Lili ...", * "states": [ * "AUTO", * "RECURRING_EVENT", * "HIDDEN" * ], * "_id": "9dadda33-659d-4376-a69d-19d50fad585a", * "_createdDate": "2023-07-11T14:28:07.061Z" * } * ], * "_originQuery": { * "filterTree": { * "$and": [] * }, * "invalidArguments": [], * "encoder": {}, * "transformationPaths": {}, * "sort": [], * "paging": {}, * "pagingMethod": "OFFSET", * "builderOptions": { * "cursorWithEmptyFilterAndSort": true * } * }, * "_limit": 50, * "_totalCount": 8, * "_offset": 0 * } */ ``` ### queryCategories (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { categories } from '@wix/events'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { categories }, // Include the auth strategy and host as relevant }); async function queryCategories(query,options) { const response = await myWixClient.categories.queryCategories(query,options); }; ``` ---