> 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: onlinePrograms

# Namespace: CategoriesService

# Method link: https://dev.wix.com/docs/api-reference/business-management/online-programs/categories/query-categories.md

## Permission Scopes:
Manage Online Programs: SCOPE.CHALLENGES.MANAGE

## Introduction

Retrieves Categories using [WQL - Wix Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).

The query supports filtering and sorting by `id`. Extended field values aren't supported as filters.

By default, the response contains up to 100 Categories. Set `query.cursorPaging.limit` to request a smaller page, and pass a cursor from `pagingMetadata.cursors` to retrieve another page.

---

## REST API

### Schema

```
 Method: queryCategories
 Description: Retrieves Categories using [WQL - Wix Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).  The query supports filtering and sorting by `id`. Extended field values aren't supported as filters.  By default, the response contains up to 100 Categories. Set `query.cursorPaging.limit` to request a smaller page, and pass a cursor from `pagingMetadata.cursors` to retrieve another page.
 URL: https://www.wixapis.com/_api/program-categories-service/v3/categories/query
 Method: POST
 Method parameters:
   param name: query | type: CursorQuery    
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  Default: `100`.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order: ascending (`ASC`) or descending (`DESC`).  Default: `ASC`.  
                 - enum:
                 -     ASC: Ascending order.
                 -     DESC: Descending order.
 Query fields:
   - field: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryCategoriesResponse
  - name: categories | type: array<Category> | description: Retrieved Categories.  
     - name: id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the Category is updated. To prevent conflicting changes, the current `revision` must be passed when updating the Category.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the Category was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the Category was last updated.  | read-only: true | validation: format date-time
     - name: label | type: string | description: Category's display label. The primary-language label must be unique within the site. Localized reads return the Wix Multilingual translation when one exists, and otherwise fall back to the primary label.  | validation: maxLength 100
     - name: assignedTo | type: array<string> | description: IDs of Programs assigned to this Category. For routine assignment changes, use [Bulk Assign Categories to Program](https://dev.wix.com/docs/api-reference/business-management/online-programs/categories/bulk-assign-categories-to-program.md), whose 10-Category-per-Program check is best-effort. Direct writes to `assignedTo` through Create Category, Bulk Create Categories, or Update Category bypass that check; callers using them must keep each Program at or below 10 Categories. Relationship updates are eventually consistent across the Program Categories and Programs APIs.  | validation: maxItems 200, format GUID
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the Category. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard for `wix.achievements.categories.v3.category` before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: pagingMetadata | type: CursorPagingMetadata | description: Cursor paging information for the returned Categories.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - 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
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query categories by ID
Retrieves Categories matching the supplied IDs. The published query contract supports the ID field.

```curl
curl -X POST \
'https://www.wixapis.com/online-programs/v3/categories/query' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "query": {
    "filter": {
      "id": {
        "$in": [
          "f69516df-6a8d-4fb7-894e-5c8291c23573"
        ]
      }
    },
    "cursorPaging": {
      "limit": 100
    }
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.onlinePrograms.categories.queryCategories(query)
 Description: Retrieves Categories using [WQL - Wix Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).  The query supports filtering and sorting by `id`. Extended field values aren't supported as filters.  By default, the response contains up to 100 Categories. Set `query.cursorPaging.limit` to request a smaller page, and pass a cursor from `pagingMetadata.cursors` to retrieve another page.
 # 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: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  Default: `100`.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order: ascending (`ASC`) or descending (`DESC`).  Default: `ASC`.  
                 - enum:
                 -     ASC: Ascending order.
                 -     DESC: Descending order.
 Query fields:
   - field: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryCategoriesResponse>
  - name: categories | type: array<Category> | description: Retrieved Categories.  
     - name: _id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the Category is updated. To prevent conflicting changes, the current `revision` must be passed when updating the Category.  | read-only: true | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the Category was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the Category was last updated.  | read-only: true 
     - name: label | type: string | description: Category's display label. The primary-language label must be unique within the site. Localized reads return the Wix Multilingual translation when one exists, and otherwise fall back to the primary label.  | validation: maxLength 100
     - name: assignedTo | type: array<string> | description: IDs of Programs assigned to this Category. For routine assignment changes, use [Bulk Assign Categories to Program](https://dev.wix.com/docs/api-reference/business-management/online-programs/categories/bulk-assign-categories-to-program.md), whose 10-Category-per-Program check is best-effort. Direct writes to `assignedTo` through Create Category, Bulk Create Categories, or Update Category bypass that check; callers using them must keep each Program at or below 10 Categories. Relationship updates are eventually consistent across the Program Categories and Programs APIs.  | validation: maxItems 200, format GUID
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the Category. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard for `wix.achievements.categories.v3.category` before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: pagingMetadata | type: CursorPagingMetadata | description: Cursor paging information for the returned Categories.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - 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
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query categories by ID
```javascript
import { categories } from "@wix/online-programs";

async function queryCategoriesExample() {
  const result = await categories
    .queryCategories()
    .eq("_id", "0a4314a1-5237-4b7f-992f-d8ecdcbe73fc")
    .limit(100)
    .find();
  return result;
}

/* Promise resolves to (captured result properties; Date values serialized as ISO strings):
{
  "items": [
    {
      "revision": "1",
      "label": "Fitness",
      "assignedTo": [],
      "_id": "0a4314a1-5237-4b7f-992f-d8ecdcbe73fc",
      "_createdDate": "2026-10-15T08:16:44.427Z",
      "_updatedDate": "2026-10-15T08:16:44.427Z"
    }
  ],
  "cursors": {},
  "length": 1,
  "pageSize": 100
}
*/
// The result also provides hasNext(), hasPrev(), next(), and prev() methods.

```

### 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/online-programs';
// 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) {
  const response = await myWixClient.categories.queryCategories(query);
};
```

---