> 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 # CountCategories # Package: services # Namespace: CategoriesService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/count-categories.md ## Permission Scopes: Read Bookings - Public Data: SCOPE.DC-BOOKINGS.READ-BOOKINGS-PUBLIC ## Introduction Counts categories, given the specified filtering. See [Query Categories](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/query-categories.md) for a list of supported filters. --- ## REST API ### Schema ``` Method: countCategories Description: Counts categories, given the specified filtering. See [Query Categories](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/query-categories.md) for a list of supported filters. URL: https://www.wixapis.com/bookings/v2/categories/count Method: POST Method parameters: param name: filter | type: filter | description: Filter to base the count on. Return type: CountCategoriesResponse - name: count | type: integer | description: Number of categories matching the filter. ``` ### Examples ### Count categories based on a filter ```curl curl -X POST \ 'https://www.wixapis.com/bookings/v2/categories/count' \ -H 'Authorization: ' \ -d '{ "filter": { "name": { "$startsWith": "Category 1" } } }' ``` ### // @Count categories based on a filter @description: Counts categories matching a name filter import { categoriesV2 } from "@wix/bookings"; ```curl async function countCategories() { const response = await categoriesV2.countCategories({ filter: { name: { $startsWith: "Category 1" }, }, }); return response; } ``` ### Count all categories ```curl curl -X POST \ 'https://www.wixapis.com/bookings/v2/categories/count' \ -H 'Authorization: ' \ -d '{}' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.services.CategoriesService.countCategories(options) Description: Counts categories, given the specified filtering. See [Query Categories](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/query-categories.md) for a list of supported filters. Method parameters: param name: options | type: CountCategoriesOptions none - name: filter | type: object | description: Filter to base the count on. Return type: PROMISE - name: count | type: integer | description: Number of categories matching the filter. ``` ### Examples ### countCategories ```javascript import { categoriesV2 } from '@wix/bookings'; async function countCategories(options) { const response = await categoriesV2.countCategories(options); }; ``` ### countCategories (with elevated permissions) ```javascript import { categoriesV2 } from '@wix/bookings'; import { auth } from '@wix/essentials'; async function myCountCategoriesMethod(options) { const elevatedCountCategories = auth.elevate(categoriesV2.countCategories); const response = await elevatedCountCategories(options); } ``` ### countCategories (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 { categoriesV2 } from '@wix/bookings'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { categoriesV2 }, // Include the auth strategy and host as relevant }); async function countCategories(options) { const response = await myWixClient.categoriesV2.countCategories(options); }; ``` ---