> 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

# QueryGroupMembers

# Package: memberManagement

# Namespace: GroupMembersService

# Method link: https://dev.wix.com/docs/api-reference/crm/community/groups/member-management/members/query-group-members?apiView=SDK.md

## Permission Scopes:
## Method Code Examples

--- Code Example: Query members of a group ---

## Introduction

Retrieves a list of up to 100 group members, given the provided paging, sorting and filtering.
Groups managers can retrieve group members of any group.

Supported fields for filtering:
- `role`

Supported fields for sorting:
- `joinedOn`
- `role`

---

## REST API

### Schema

```
 Method: queryGroupMembers
 Description: Retrieves a list of up to 100 group members, given the provided paging, sorting and filtering. Groups managers can retrieve group members of any group.  Supported fields for filtering: - `role`  Supported fields for sorting: - `joinedOn` - `role`
 URL: https://www.wixapis.com/social-groups-proxy/members/v2/groups/{groupId}/members/query
 Method: POST
 Method parameters:
   param name: query | type: Query    
        - name: filter | type: Value | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
           - ONE-OF: 
              - name: nullValue | type:  | description:   
              - name: numberValue | type: number | description:   
              - name: stringValue | type: string | description:   
              - name: boolValue | type: boolean | description:   
              - name: structValue | type: object | description:   
              - name: listValue | type: ListValue | description:   
                 - name: values | type: array<Value> | description:   
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
        - name: paging | type: Paging | description: Paging options to limit and skip the number of items.  
           - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
           - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
        - name: fields | type: array<string> | description: Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.  
        - name: fieldsets | type: array<string> | description: Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.  
 Return type: QueryGroupMembersResponse
  - name: members | type: array<GroupMember> | description: Group members.  
     - name: memberId | type: string | description: Member GUID. See the Members API for more details.  | read-only: true | validation: format GUID
     - name: role | type: GroupRole | description: Group member role.  
        - name: value | type: Role | description: Member's role.  
             - enum:
             -     MEMBER: Regular group member.
             -     ADMIN: Group administrator.
     - name: joinedDate | type: string | description: Date and time the group Member joined the group.  | read-only: true | validation: format date-time
  - name: metadata | type: PagingMetadata | description: Paging information.  
     - 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.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  


```

### Examples

### QueryGroupMembers
```curl
~~~cURL
curl -X POST \
    https://wixapis.com/social-groups/v2/groups/8a258cf5-49f3-41dc-b320-65ec2598315b/members/query \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Authorization: <AUTH>'
    -d '{
        "query": {
            "filter": {
                "role": {
                    "$eq": "ADMIN"
                }
            },
            "sort": [
                {
                    "fieldName": "joinedOn",
                    "order": "DESC"
                }
            ],
            "paging": {
                "offset": 0,
                "limit": 100
            }
        }
    }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.groups.members.queryGroupMembers(groupId, options)
 Description: Retrieves a list of up to 100 group members, given the provided paging, sorting and filtering. Groups managers can retrieve group members of any group.  Supported fields for filtering: - `role`  Supported fields for sorting: - `joinedOn` - `role`
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  groupId
 Method parameters: 
   param name: groupId | type: string | description: Group GUID. | required: true | validation: format GUID
   param name: options | type: QueryGroupMembersOptions  none  
        - name: query | type: Query | description:   
           - name: filter | type: any<Value> | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
              - ONE-OF: 
                 - name: nullValue | type:  | description:   
                 - name: numberValue | type: number | description:   
                 - name: stringValue | type: string | description:   
                 - name: boolValue | type: boolean | description:   
                 - name: structValue | type: object | description:   
                 - name: listValue | type: ListValue | description:   
                    - name: values | type: array<Value> | description:   
           - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  
              - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
              - name: order | type: SortOrder | description: Sort order.  
                     - enum: ASC, DESC
              - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
                 - name: latitude | type: number | description: Address latitude.  
                 - name: longitude | type: number | description: Address longitude.  
           - name: paging | type: Paging | description: Paging options to limit and skip the number of items.  
              - name: limit | type: integer | description: Number of items to load.  | validation: minimum 0, format int32
              - name: offset | type: integer | description: Number of items to skip in the current sort order.  | validation: minimum 0, format int32
           - name: fields | type: array<string> | description: Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.  
           - name: fieldsets | type: array<string> | description: Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.  
 Return type: PROMISE<QueryGroupMembersResponse>
  - name: members | type: array<GroupMember> | description: Group members.  
     - name: memberId | type: string | description: Member GUID. See the Members API for more details.  | read-only: true | validation: format GUID
     - name: role | type: GroupRole | description: Group member role.  
        - name: value | type: Role | description: Member's role.  
             - enum:
             -     MEMBER: Regular group member.
             -     ADMIN: Group administrator.
     - name: joinedDate | type: Date | description: Date and time the group Member joined the group.  | read-only: true 
  - name: metadata | type: PagingMetadata | description: Paging information.  
     - 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.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  


```

### Examples

### Query members of a group
```javascript
import { members } from '@wix/groups';

export function myQueryGroupMembersFunction(groupId) {
  return members.queryGroupMembers(groupId)
    .find()
    .then((results) => {
      const items = results.items;
      const firstItem = items[0];
      const pageSize = results.pageSize;
      const totalPages = results.totalPages;
      const totalCount = results.totalCount;
      const currentPage = results.currentPage;
      const next = results.next();
      const previous = results.prev();
      const hasNext = results.hasNext();
      const hasPrev = results.hasPrev();
      const length = results.length;

      return items;
    })
    .catch((error) => {
      console.error(error);
    });
}

/* Returns items:
 * [
 *  { 
 *     "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
 *     "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
 *     "role": {"value": "ADMIN"}
 *   },
 *   {
 *     "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
 *     "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
 *     "role": {"value": "MEMBER"}
 *   }
 * ]
 */
```

### Query members of a group (with elevated permissions)
```javascript
import { members } from '@wix/groups';
import { auth } from '@wix/essentials';

const elevatedQueryGroupMembers = auth.elevate(members.queryGroupMembers);

export function myQueryGroupMembersFunction() {
  return elevatedQueryGroupMembers(groupId)
    .find()
    .then((results) => {
      const items = results.items;
      const firstItem = items[0];
      const pageSize = results.pageSize;
      const totalPages = results.totalPages;
      const totalCount = results.totalCount;
      const currentPage = results.currentPage;
      const next = results.next();
      const previous = results.prev();
      const hasNext = results.hasNext();
      const hasPrev = results.hasPrev();
      const length = results.length;

      return items;
    })
    .catch((error) => {
      console.error(error);
    });
}

/* Returns items:
 * [
 *  { 
 *     "joinedDate": "Sun Aug 01 2021 12:32:35 GMT+0300"
 *     "memberId": "437cd3db-e9be-4980-93c1-a6d767a11050"
 *     "role": {"value": "ADMIN"}
 *   },
 *   {
 *     "joinedDate": "Tues Jun 30 2019 10:09:33 GMT+0300"
 *     "memberId": "7fe8e9e1-d050-4c86-9684-e7f231600a34"
 *     "role": {"value": "MEMBER"}
 *   }
 * ]
 */
```

### queryGroupMembers (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 { members } from '@wix/groups';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { members },
  // Include the auth strategy and host as relevant
});


async function queryGroupMembers(groupId,options) {
  const response = await myWixClient.members.queryGroupMembers(groupId,options);
};
```

---