> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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<fieldset> | description: Predefined sets of fields to return. - `COUNTS`: Returns `assignedEventsCount`.  | validation: maxItems 1
                 - 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.  | validation: minimum 0, maximum 1000, format int32
        - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
        - 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<Sorting> | 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).  | validation: maxItems 20
           - name: fieldName | type: string | description: Name of the field to sort by  | validation: maxLength 100
           - name: order | type: SortOrder | description: Sort order (ASC/DESC). Defaults to ASC  
                 - enum: ASC, DESC
 Query fields:
   - field: id | operators: $eq | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: name | operators: $eq | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: states | operators: $hasSome | sort: none | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: none | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryCategoriesResponse
  - name: categories | type: array<Category> | description: List of categories.  
     - name: id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
     - name: name | type: string | description: Category name.  | validation: minLength 1, maxLength 30
     - name: createdDate | type: string | description: Date and time when category was created.  | read-only: true | validation: format date-time
     - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category.  | read-only: true 
        - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category.  | validation: format int32
        - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded.  | validation: format int32
     - name: states | type: array<State> | description: Category state.  Default: `MANUAL`.  **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`.  | validation: maxItems 3
         - 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.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - 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.  | validation: format int32
     - 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.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### Examples

### Query categories by name
```curl
curl -X POST 'https://www.wixapis.com/events/v1/categories/query' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH TOKEN>' \
-d '{
      "query": {
        "filter": {
          "name": {
            "$eq": "food"
          }
        }
      }
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.events.categories.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: 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.  | validation: minimum 0, maximum 1000, format int32
        - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
        - 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<Sorting> | 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).  | validation: maxItems 20
           - name: fieldName | type: string | description: Name of the field to sort by  | validation: maxLength 100
           - name: order | type: SortOrder | description: Sort order (ASC/DESC). Defaults to ASC  
                 - enum: ASC, DESC
   param name: options | type: QueryCategoriesOptions  none  
        - name: fieldset | type: array<CategoryFieldset> | description: Predefined sets of fields to return. - `COUNTS`: Returns `assignedEventsCount`.  | validation: maxItems 1
             - enum:
             -     COUNTS: Include `assignedEventsCount` in the response.
 Query fields:
   - field: _id | operators: $eq | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: name | operators: $eq | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: states | operators: $hasSome | sort: none | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: none | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryCategoriesResponse>
  - name: categories | type: array<Category> | description: List of categories.  
     - name: _id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
     - name: name | type: string | description: Category name.  | validation: minLength 1, maxLength 30
     - name: _createdDate | type: Date | description: Date and time when category was created.  | read-only: true 
     - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category.  | read-only: true 
        - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category.  | validation: format int32
        - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded.  | validation: format int32
     - name: states | type: array<State> | description: Category state.  Default: `MANUAL`.  **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`.  | validation: maxItems 3
         - 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.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - 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.  | validation: format int32
     - 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.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### 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-managed)
Self-managed 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);
};
```

---