> 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

# QueryVotes

# Package: comments

# Namespace: Votes

# Method link: https://dev.wix.com/docs/api-reference/crm/community/feedback-moderation/comments/vote-v1/query-votes.md

## Permission Scopes:
Read comment votes: SCOPE.DC_COMMENTS.READ-VOTES

## Introduction

Retrieves a list of votes, given the provided paging and filtering.

Visitor and member callers receive their own votes in the specified app and context.
Authorized application callers can retrieve votes from multiple identities in that context.
Filter by `resourceId`, using `$in` to retrieve votes for multiple comment IDs.
Results don't include comments without a matching vote.

Specify `query.cursorPaging.limit` to control the page size. To retrieve the next page,
set `query.cursorPaging.cursor` to the returned `paging.cursors.next` and keep the same context.
Offset paging and field projection aren't supported. Don't depend on a particular result order.

To learn about working with Query methods, see
[API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md) and
[Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md).
Retain the permission checked by RequestContextResolver for app identities.

---

## REST API

### Schema

```
 Method: queryVotes
 Description: Retrieves a list of votes, given the provided paging and filtering.  Visitor and member callers receive their own votes in the specified app and context. Authorized application callers can retrieve votes from multiple identities in that context. Filter by `resourceId`, using `$in` to retrieve votes for multiple comment GUIDs. Results don't include comments without a matching vote.  Specify `query.cursorPaging.limit` to control the page size. To retrieve the next page, set `query.cursorPaging.cursor` to the returned `paging.cursors.next` and keep the same context. Offset paging and field projection aren't supported. Don't depend on a particular result order.  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md) and [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md). Retain the permission checked by RequestContextResolver for app identities.
 URL: https://www.wixapis.com/v1/votes
 Method: POST
 Method parameters:
   param name: contextData | type: ContextData | description: Identifies the app and context containing the resource. When provided, `contextData` takes precedence over the deprecated `contextToken`.  
        - name: appDefId | type: string | description: GUID of the app that owns the context.  | validation: format GUID
        - name: contextId | type: string | description: GUID of the context containing the resource.  | validation: maxLength 128
        - name: contextType | type: string | description: Optional type used by the app to resolve its context.  
   param name: contextToken | type: contextToken | description: Legacy context token. Use `contextData` instead.  
   param name: query | type: QueryV2    
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | 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).  
           - 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: 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.  
 Query fields:
   - field: resourceId | operators: $eq, $ne, $in | sort: none | aggregatable: undefined | searchable: undefined
 Return type: QueryVotesResponse
  - name: votes | type: array<Vote> | description: Votes matching the query.  
     - name: resourceId | type: string | description: GUID of the resource receiving the vote. For comments, this is the comment GUID.  | validation: maxLength 128
     - name: resourceFqdn | type: string | description: Entity type receiving the vote. For comments, this is `wix.comments.v2.comment`.  | validation: maxLength 300
     - name: voteId | type: string | description: Vote GUID.  | read-only: true | validation: format GUID
     - name: type | type: Type | description: Vote type.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown vote type.
         -     UPVOTE: Vote in favor of the resource.
         -     DOWNVOTE: Vote against the resource.
     - name: createdBy | type: SocialIdentity | description: Identity that cast the vote.  | read-only: true 
        - name: identityId | type: string | description:   | validation: format GUID
        - name: identityType | type: IdentityType | description:   
             - enum: ANONYMOUS, MEMBER, USER, SERVICE, MEMBER_GROUP
     - name: createdDate | type: string | description: Date and time the vote was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the vote was updated.  | read-only: true | validation: format date-time
     - name: context | type: VoteContext | description: App and context containing the resource.  
        - name: contextId | type: string | description: GUID of the context containing the resource.  | validation: maxLength 128
        - name: contextType | type: string | description: Type used by the app to identify the context.  
        - name: appDefId | type: string | description: GUID of the app that owns the context.  | read-only: true | validation: format GUID
        - name: metaSiteId | type: string | description: Site GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments when the vote is updated.  | read-only: true 
  - name: paging | type: PagingMetadataV2 | description: Paging metadata containing cursors for retrieving additional 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

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_FIELDS | Description: The query filter contains fields other than `resourceId`.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_METASITE_CONTEXT | Description: The authenticated request does not contain a site context.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.


```

### Examples

### Continue a vote query
Specify the exact cursor returned by the previous query, keeping the same filter and context.

```curl
curl -X POST \
'https://www.wixapis.com/v1/votes' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "contextData": {
    "appDefId": "91c9d6a7-6667-41fb-b0b4-7d3b3ff0b02e",
    "contextId": "64ad407e0bf87891bba7de3a"
  },
  "query": {
    "filter": {"resourceId": {"$in": ["90616636-cfe2-4f3d-88ce-1c3d8e3eaa67"]}},
    "cursorPaging": {
      "cursor": "<NEXT_CURSOR>"
    }
  }
}'
```

### Find votes for displayed comments
Find votes for displayed comments.

```curl
curl -X POST \
'https://www.wixapis.com/v1/votes' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "contextData": {
    "appDefId": "91c9d6a7-6667-41fb-b0b4-7d3b3ff0b02e",
    "contextId": "64ad407e0bf87891bba7de3a"
  },
  "query": {
    "filter": {
      "resourceId": {
        "$in": [
          "90616636-cfe2-4f3d-88ce-1c3d8e3eaa67"
        ]
      }
    },
    "cursorPaging": {
      "limit": 20
    }
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.comments.votes.queryVotes(query, options)
 Description: Retrieves a list of votes, given the provided paging and filtering.  Visitor and member callers receive their own votes in the specified app and context. Authorized application callers can retrieve votes from multiple identities in that context. Filter by `resourceId`, using `$in` to retrieve votes for multiple comment GUIDs. Results don't include comments without a matching vote.  Specify `query.cursorPaging.limit` to control the page size. To retrieve the next page, set `query.cursorPaging.cursor` to the returned `paging.cursors.next` and keep the same context. Offset paging and field projection aren't supported. Don't depend on a particular result order.  To learn about working with Query methods, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md) and [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md). Retain the permission checked by RequestContextResolver for app identities.
 # 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: QueryVotesOptions  none  
        - name: contextData | type: ContextData | description: App and context containing the resource.  
           - name: appDefId | type: string | description: GUID of the app that owns the context.  | validation: format GUID
           - name: contextId | type: string | description: GUID of the context containing the resource.  | validation: maxLength 128
           - name: contextType | type: string | description: Optional type used by the app to resolve its context.  
   param name: query | type: VoteQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | 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).  
           - 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.  
 Query fields:
   - field: resourceId | operators: $eq, $ne, $in | sort: none | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryVotesResponse>
  - name: votes | type: array<Vote> | description: Votes matching the query.  
     - name: resourceId | type: string | description: GUID of the resource receiving the vote. For comments, this is the comment GUID.  | validation: maxLength 128
     - name: resourceFqdn | type: string | description: Entity type receiving the vote. For comments, this is `wix.comments.v2.comment`.  | validation: maxLength 300
     - name: voteId | type: string | description: Vote GUID.  | read-only: true | validation: format GUID
     - name: type | type: Type | description: Vote type.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown vote type.
         -     UPVOTE: Vote in favor of the resource.
         -     DOWNVOTE: Vote against the resource.
     - name: createdBy | type: SocialIdentity | description: Identity that cast the vote.  | read-only: true 
        - name: identityId | type: string | description:   | validation: format GUID
        - name: identityType | type: IdentityType | description:   
             - enum: ANONYMOUS, MEMBER, USER, SERVICE, MEMBER_GROUP
     - name: _createdDate | type: Date | description: Date and time the vote was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the vote was updated.  | read-only: true 
     - name: context | type: VoteContext | description: App and context containing the resource.  
        - name: contextId | type: string | description: GUID of the context containing the resource.  | validation: maxLength 128
        - name: contextType | type: string | description: Type used by the app to identify the context.  
        - name: appDefId | type: string | description: GUID of the app that owns the context.  | read-only: true | validation: format GUID
        - name: metaSiteId | type: string | description: Site GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments when the vote is updated.  | read-only: true 
  - name: paging | type: PagingMetadataV2 | description: Paging metadata containing cursors for retrieving additional 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

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: UNSUPPORTED_FILTER_FIELDS | Description: The query filter contains fields other than `resourceId`.
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: MISSING_METASITE_CONTEXT | Description: The authenticated request does not contain a site context.
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions.


```

### Examples

### QueryVotes for the current identity
Use visitor or member authentication and replace the sample IDs with your comment, vote, and voting-enabled category IDs as applicable.

```javascript
import { votes } from "@wix/comments";

export async function queryVotesExample() {
  const response = await votes.queryVotes({
    filter: { resourceId: { $in: ["90616636-cfe2-4f3d-88ce-1c3d8e3eaa67"] } },
    cursorPaging: { limit: 20 },
  }, {
    contextData: {
      appDefId: "91c9d6a7-6667-41fb-b0b4-7d3b3ff0b02e",
      contextId: "64ad407e0bf87891bba7de3a",
    },
  });
  return response;
}

/* Promise resolves to:
{"votes": [], "paging": {"cursors": {}}}
*/

```

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

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


async function queryVotes(query,options) {
  const response = await myWixClient.votes.queryVotes(query,options);
};
```

---