> 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 # CountResources # Package: resources # Namespace: ResourcesService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/count-resources.md ## Permission Scopes: Read Bookings - Public Data: SCOPE.DC-BOOKINGS.READ-BOOKINGS-PUBLIC ## Introduction Counts resources according to given criteria. See [Query Resources](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/query-resources.md) for a list of supported filters. --- ## REST API ### Schema ``` Method: countResources Description: Counts resources according to given criteria. See [Query Resources](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/query-resources.md) for a list of supported filters. URL: https://www.wixapis.com/bookings/v2/resources/count Method: POST Method parameters: param name: filter | type: filter | description: Filter to base the count on. See [Query Resources](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/query-resources.md) for a list of supported filters. param name: search | type: SearchDetails - name: mode | type: Mode | description: Search mode. Defines the search logic for combining multiple terms in the `expression`. - enum: - OR: At least 1 of the search terms must be present. - AND: All search terms must be present. - name: expression | type: string | description: Search term or expression. - name: fields | type: array | description: Fields to search in. If the array is empty, all searchable fields are searched. Use dot notation to specify a JSON path. For example, `locationOptions.availableInAllLocations`. - name: fuzzy | type: boolean | description: Whether to enable the search function to use an algorithm to automatically find results that are close to the search expression, such as typos and declensions. Return type: CountResourcesResponse - name: count | type: integer | description: Total number of resources matching the filter. ``` ### Examples ### Count resources with a filter. Count resources, providing a filter to count specific resources matching the filter. ```curl curl -X POST \ 'https://www.wixapis.com/bookings/v2/resources/count' \ -H 'Authorization: ' \ -d '{ "filter": { "name": { "$eq": "Name that does not exist" } } }' ``` ### Count resources. ```curl curl -X POST \ 'https://www.wixapis.com/bookings/v2/resources/count' \ -H 'Authorization: ' \ -d '{}' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.resources.ResourcesService.countResources(options) Description: Counts resources according to given criteria. See [Query Resources](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/query-resources.md) for a list of supported filters. Method parameters: param name: options | type: CountResourcesOptions none - name: filter | type: object | description: Filter to base the count on. See [Query Resources](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/query-resources.md) for a list of supported filters. Return type: PROMISE - name: count | type: integer | description: Total number of resources matching the filter. ``` ### Examples ### countResources ```javascript import { resources } from '@wix/bookings'; async function countResources(options) { const response = await resources.countResources(options); }; ``` ### countResources (with elevated permissions) ```javascript import { resources } from '@wix/bookings'; import { auth } from '@wix/essentials'; async function myCountResourcesMethod(options) { const elevatedCountResources = auth.elevate(resources.countResources); const response = await elevatedCountResources(options); } ``` ### countResources (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 { resources } from '@wix/bookings'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { resources }, // Include the auth strategy and host as relevant }); async function countResources(options) { const response = await myWixClient.resources.countResources(options); }; ``` ---