> 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 # CountEventsByStatus # Package: eventManagement # Namespace: EventManagement # Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/events-v3/count-events-by-status.md ## Permission Scopes: Read Events: SCOPE.DC-EVENTS.READ-EVENTS ## Introduction Counts events by status. See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). --- ## REST API ### Schema ``` Method: countEventsByStatus Description: Counts events by status. See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). URL: https://www.wixapis.com/events/v3/events/count-by-status Method: POST Method parameters: param name: facet | type: array | description: Parameters to count events by. param name: filter | type: filter | description: Filter object in the following format:
`"filter" : { "fieldName1": "value1" }`. param name: includeDrafts | type: includeDrafts | description: Whether draft events should be returned in the response.
**Note:** This parameter requires the `WIX_EVENTS.READ_DRAFT_EVENTS` permission. Return type: CountEventsByStatusResponse - name: pagingMetadata | type: PagingMetadataV2 | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items to return. See [Paging](https://dev.wix.com/api/rest/getting-started/sorting-and-paging#getting-started_sorting-and-paging_paging) for more information. - name: offset | type: integer | description: Requested offset. - 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 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. - name: facets | type: Map | description: Filter facets. - name: counts | type: object | description: Facet counts aggregated per value Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILTER_PARSER_ERROR | Description: The `filter` syntax is invalid. ``` ### Examples ### Count events by the "Canceled" status ```curl curl -X POST 'https://www.wixapis.com/events/v3/events/count-by-status' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' \ -d '{ "query": { "filter": { "status": { "$eq": "CANCELED" } }, "paging": { "limit": 10 } }, "facet": ["status"], "includeDrafts": false }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.eventManagement.EventManagement.countEventsByStatus(options) Description: Counts events by status. See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md). Method parameters: param name: options | type: CountEventsByStatusOptions none - name: filter | type: object | description: Filter object in the following format:
`"filter" : { "fieldName1": "value1" }`. - name: facet | type: array | description: Parameters to count events by. - name: includeDrafts | type: boolean | description: Whether draft events should be returned in the response.
**Note:** This parameter requires the `WIX_EVENTS.READ_DRAFT_EVENTS` permission. Return type: PROMISE - name: pagingMetadata | type: PagingMetadataV2 | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items to return. See [Paging](https://dev.wix.com/api/rest/getting-started/sorting-and-paging#getting-started_sorting-and-paging_paging) for more information. - name: offset | type: integer | description: Requested offset. - 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 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. - name: facets | type: Map | description: Filter facets. - name: counts | type: object | description: Facet counts aggregated per value Possible Errors: HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILTER_PARSER_ERROR | Description: The `filter` syntax is invalid. ``` ### Examples ### countEventsByStatus ```javascript import { wixEventsV2 } from '@wix/events'; async function countEventsByStatus(options) { const response = await wixEventsV2.countEventsByStatus(options); }; ``` ### countEventsByStatus (with elevated permissions) ```javascript import { wixEventsV2 } from '@wix/events'; import { auth } from '@wix/essentials'; async function myCountEventsByStatusMethod(options) { const elevatedCountEventsByStatus = auth.elevate(wixEventsV2.countEventsByStatus); const response = await elevatedCountEventsByStatus(options); } ``` ### countEventsByStatus (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 { wixEventsV2 } from '@wix/events'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { wixEventsV2 }, // Include the auth strategy and host as relevant }); async function countEventsByStatus(options) { const response = await myWixClient.wixEventsV2.countEventsByStatus(options); }; ``` ---