> 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 # QueryServiceOptionsAndVariants # Package: services # Namespace: ServiceOptionsAndVariantsService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/service-options-and-variants/query-service-options-and-variants.md ## Permission Scopes: Wix Multilingual - Nile Wrapper Domain Events Read: SCOPE.MULTILINGUAL.NILE_WRAPPER_DOMAIN_EVENTS_READ ## Introduction Retrieves a list of `serviceOptionsAndVariants` objects, given the provided paging, filtering, and sorting. Query Service Options And Variants* runs with these defaults, which you can override: - `id` sorted in `ASC` order. - `cursorPaging.limit` set to `100`. To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/getting-started/field-projection.md). --- ## REST API ### Schema ``` Method: queryServiceOptionsAndVariants Description: Retrieves a list of `serviceOptionsAndVariants` objects, given the provided paging, filtering, and sorting. Query Service Options And Variants* runs with these defaults, which you can override: - `id` sorted in `ASC` order. - `cursorPaging.limit` set to `100`. To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/getting-started/field-projection.md). URL: https://www.wixapis.com/bookings/v1/serviceOptionsAndVariants/query Method: POST # 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: query | type: QueryV2 | required: true - ONE-OF: - required: true - 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. - name: offset | type: integer | description: Number of items to skip in the current sort order. - 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. - 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. - name: filter | type: object | description: Filter object. Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section). - name: sort | type: array | description: Sort object. Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: QueryServiceOptionsAndVariantsResponse - name: serviceOptionsAndVariantsList | type: array | description: Retrieved `serviceOptionsAndVariants` objects. - name: id | type: string | description: GUID of the `serviceOptionsAndVariants` object. - name: serviceId | type: string | description: GUID of the service related to these options and variants. - name: options | type: ServiceOptions | description: Service options. Note that currently only a single option is supported per service. - name: values | type: array | description: Values of the service options. Max: 1 service option - ONE-OF: - name: customData | type: CustomServiceOption | description: Details about the custom option. Available only for `CUSTOM` options. - name: name | type: string | description: Name of the service option. For example, `Age group`, `Location`, `Equipment`, or `Time`. - name: choices | type: array | description: Available choices for the service option. For example, `child`, `student`, `adult`, and `senior` for a service option named `Age group`. Each value must be unique. The value's case is ignored, meaning `Child` and `child` are considered to be identical. Currently, only a single choice is supported because a service can have only a single option. Max: 1 choice - name: durationData | type: DurationServiceOption | description: - name: name | type: string | description: Optional name of the duration option. For example, `Short Class`, or `Extended Class`. - name: id | type: string | description: GUID of the service option. - name: type | type: ServiceOptionType | description: Type of the service option. - enum: - UNKNOWN: There is no information about the option type. - CUSTOM: The service option is based on a custom parameter. For example, age group, booked equipment, or appointment timing. - STAFF_MEMBER: It's a [staff member](https://dev.wix.com/docs/rest/business-solutions/bookings/staff-members/introduction.md) based option. - DURATION: It's a duration-based option. - name: variants | type: ServiceVariants | description: Information about the service's variants. - name: values | type: array | description: Values of the service variants. - name: choices | type: array | description: Choices for the service option. Currently, only a single choice is supported because a service can have only a single option. Max: 1 choice - ONE-OF: - name: custom | type: string | description: Name of the custom choice. - name: staffMemberId | type: string | description: GUID of the [resource](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/introduction.md) associated with the [staff member](https://dev.wix.com/docs/api-reference/business-solutions/bookings/staff-members/introduction.md) providing the service. - name: duration | type: Duration | description: Information about the option's duration. - name: minutes | type: integer | description: Duration of the service in minutes. Min: `1` minute Max: `44639` minutes (30 days, 23 hours, and 59 minutes) - name: name | type: string | description: Name of the duration option. Default: Human-readable text of `minutes`. For example, `1 hr 30 min`. - name: optionId | type: string | description: GUID of the service option. - name: price | type: Money | description: Information about the service variant's price. - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. - name: minPrice | type: Money | description: Price of the cheapest service variant. - name: maxPrice | type: Money | description: Price of the most expensive service variant. - name: revision | type: string | description: Revision number, which increments by 1 each time the `serviceOptionsAndVariants` object is updated. To prevent conflicting changes, the current revision must be passed when updating and deleting the `serviceOptionsAndVariants` object. Ignored when creating a `serviceOptionsAndVariants` object. - name: extendedFields | type: ExtendedFields | description: Extensions enabling users to save custom data related to service options and variants. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: pagingMetadata | type: PagingMetadataV2 | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - 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 string 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. ``` ### Examples ### Query custom options and variants, sorting by service ID and limiting the responses to 3 items ```curl curl -X POST \ 'https://wixapis.com/bookings/v1/serviceOptionsAndVariants/query ' \ -H 'Authorization: ' \ -d '{ "query": { "sort": [ { "fieldName": "serviceId", "order": "DESC" } ], "fieldsets": [], "fields": [], "cursorPaging": { "limit": 3 } } }' ``` ### Query options and variants with a cursor from a previous request ```curl curl -X POST \ 'https://wixapis.com/bookings/v1/serviceOptionsAndVariants/query' \ -H 'Authorization: ' \ -d '{ "query": { "sort": [], "fieldsets": [], "fields": [], "cursorPaging": { "limit": 3, "cursor": "d86a982cdc306046bacbd2724e9a3ac0ad102341.GjUKCXNlcnZpY2VJZBABGiYaJGMwZWNiZDEyLWJlYTYtNDM2YS04Mjk4LWFmNDA1MWY4MjU2YSIkNWIzMWI0ZDQtYjYxMi00OWUxLTkxYjgtMjM0YmJkNjQxM2Qy" } } }' ``` ### Query custom options and variants, filtering by option name ```curl curl -X POST \ 'https://wixapis.com/bookings/v1/serviceOptionsAndVariants/query' \ -H 'Authorization: ' \ -d '{ "query": { "sort": [], "fieldsets": [], "fields": [], "filter": { "options.values.optionSpecificData.customData.name": { "$hasSome": ["Client type"] } } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.services.ServiceOptionsAndVariantsService.queryServiceOptionsAndVariants(query) Description: Retrieves a list of `serviceOptionsAndVariants` objects, given the provided paging, filtering, and sorting. Query Service Options And Variants* runs with these defaults, which you can override: - `id` sorted in `ASC` order. - `cursorPaging.limit` set to `100`. To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/getting-started/field-projection.md). # 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: query | type: ServiceOptionsAndVariantsQuery | required: true - ONE-OF: - required: true - 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. - name: offset | type: integer | description: Number of items to skip in the current sort order. - 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. - 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. - name: filter | type: object | description: Filter object. Learn more about the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section). - name: sort | type: array | description: Sort object. Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: PROMISE - name: serviceOptionsAndVariantsList | type: array | description: Retrieved `serviceOptionsAndVariants` objects. - name: _id | type: string | description: GUID of the `serviceOptionsAndVariants` object. - name: serviceId | type: string | description: GUID of the service related to these options and variants. - name: options | type: ServiceOptions | description: Service options. Note that currently only a single option is supported per service. - name: values | type: array | description: Values of the service options. Max: 1 service option - ONE-OF: - name: customData | type: CustomServiceOption | description: Details about the custom option. Available only for `CUSTOM` options. - name: name | type: string | description: Name of the service option. For example, `Age group`, `Location`, `Equipment`, or `Time`. - name: choices | type: array | description: Available choices for the service option. For example, `child`, `student`, `adult`, and `senior` for a service option named `Age group`. Each value must be unique. The value's case is ignored, meaning `Child` and `child` are considered to be identical. Currently, only a single choice is supported because a service can have only a single option. Max: 1 choice - name: durationData | type: DurationServiceOption | description: - name: name | type: string | description: Optional name of the duration option. For example, `Short Class`, or `Extended Class`. - name: _id | type: string | description: GUID of the service option. - name: type | type: ServiceOptionType | description: Type of the service option. - enum: - UNKNOWN: There is no information about the option type. - CUSTOM: The service option is based on a custom parameter. For example, age group, booked equipment, or appointment timing. - STAFF_MEMBER: It's a [staff member](https://dev.wix.com/docs/rest/business-solutions/bookings/staff-members/introduction.md) based option. - DURATION: It's a duration-based option. - name: variants | type: ServiceVariants | description: Information about the service's variants. - name: values | type: array | description: Values of the service variants. - name: choices | type: array | description: Choices for the service option. Currently, only a single choice is supported because a service can have only a single option. Max: 1 choice - ONE-OF: - name: custom | type: string | description: Name of the custom choice. - name: staffMemberId | type: string | description: GUID of the [resource](https://dev.wix.com/docs/api-reference/business-solutions/bookings/resources/resources-v2/introduction.md) associated with the [staff member](https://dev.wix.com/docs/api-reference/business-solutions/bookings/staff-members/introduction.md) providing the service. - name: duration | type: Duration | description: Information about the option's duration. - name: minutes | type: integer | description: Duration of the service in minutes. Min: `1` minute Max: `44639` minutes (30 days, 23 hours, and 59 minutes) - name: name | type: string | description: Name of the duration option. Default: Human-readable text of `minutes`. For example, `1 hr 30 min`. - name: optionId | type: string | description: GUID of the service option. - name: price | type: Money | description: Information about the service variant's price. - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative. - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD). - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative. - name: minPrice | type: Money | description: Price of the cheapest service variant. - name: maxPrice | type: Money | description: Price of the most expensive service variant. - name: revision | type: string | description: Revision number, which increments by 1 each time the `serviceOptionsAndVariants` object is updated. To prevent conflicting changes, the current revision must be passed when updating and deleting the `serviceOptionsAndVariants` object. Ignored when creating a `serviceOptionsAndVariants` object. - name: extendedFields | type: ExtendedFields | description: Extensions enabling users to save custom data related to service options and variants. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: pagingMetadata | type: PagingMetadataV2 | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - 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 string 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. ``` ### Examples ### queryServiceOptionsAndVariants ```javascript import { serviceOptionsAndVariants } from '@wix/bookings'; async function queryServiceOptionsAndVariants(query) { const response = await serviceOptionsAndVariants.queryServiceOptionsAndVariants(query); }; ``` ### queryServiceOptionsAndVariants (with elevated permissions) ```javascript import { serviceOptionsAndVariants } from '@wix/bookings'; import { auth } from '@wix/essentials'; async function myQueryServiceOptionsAndVariantsMethod(query) { const elevatedQueryServiceOptionsAndVariants = auth.elevate(serviceOptionsAndVariants.queryServiceOptionsAndVariants); const response = await elevatedQueryServiceOptionsAndVariants(query); } ``` ### queryServiceOptionsAndVariants (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 { serviceOptionsAndVariants } from '@wix/bookings'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { serviceOptionsAndVariants }, // Include the auth strategy and host as relevant }); async function queryServiceOptionsAndVariants(query) { const response = await myWixClient.serviceOptionsAndVariants.queryServiceOptionsAndVariants(query); }; ``` ---