> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

> **Deprecated.** This method is deprecated. Depending on your use case, you may also replace the method by calling 1 of the following methods:
- Get Availability Time Slot ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/time-slots/availability-time-slots/get-availability-time-slot.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/time-slots-v2/get-availability-time-slot.md))
- List Event Time Slots ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/time-slots/event-time-slots/list-event-time-slots.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/time-slots-v2/list-event-time-slots.md))
- Get Event Time Slot ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/time-slots/event-time-slots/get-event-time-slot.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/time-slots-v2/get-event-time-slot.md))
- List Multi Service Availability Time Slots ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/time-slots/multi-service-availability-time-slots/list-multi-service-availability-time-slots.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/time-slots-v2/list-multi-service-availability-time-slots.md))
- Get Multi Service Availability Time Slot ([SDK](https://dev.wix.com/docs/sdk/backend-modules/bookings/time-slots/multi-service-availability-time-slots/get-multi-service-availability-time-slot.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/time-slots-v2/get-multi-service-availability-time-slot.md)) Replacement: https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/time-slots-v2/list-availability-time-slots.md Planned removal date: 2026-03-31.

# QueryAvailability

# Package: timeSlots

# Namespace: AvailabilityCalendar

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/time-slots/availability-calendar/query-availability?apiView=SDK.md

## Permission Scopes:
Read Bookings Calendar Availability: SCOPE.DC-BOOKINGS.READ-CALENDAR

## Introduction

Retrieves appointment slots or class events that match specified filters.

---

## REST API

### Schema

```
 Method: queryAvailability
 Description: Retrieves appointment slots or class events that match specified filters.  ### Course limitations  Course events can't be retrieved with this method. Follow this [sample flow](https://dev.wix.com/docs/rest/business-solutions/bookings/end-to-end-booking-flows.md#book-a-course) to check course availability.  ### Query filter  You must include `serviceId` in your query filter. For performance, also specify both `startDate` and `endDate`. Refer to the [supported filters article](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.md) for a complete list of supported filters.  ### Limit the number of slots returned per day  To limit the maximum number of appointment slots returned for each date, specify `slotsPerDay`. For example,  specifying `{"slotsPerDay": 3}` returns a maximum of 3 appointment slots/class events for each day that's within the query filter's date range.  ### Unavailable slots  By default, both available and unavailable appointment slots/ class events are returned. To retrieve only available slots/events, specify `{"bookable": true}` in the filter.  ### Sorting  Slots/events can be sorted only by `startDate`. Unavailable slots/events always appear after available ones.  ### Availability calculation  Wix Bookings calculates availability differently for appointment-based services and classes.  #### Appointment availability  An appointment slot is `bookable` if: - The slot's `startDate` is later than or equal to `query.filter.startDate`. - The slot's `endDate` is before or equal to `query.filter.endDate`. - The service's `onlineBooking.enabled` is `true`. - The service's early/late booking policies are either not enabled or the current time is within the defined limits.  #### Class event availability  A class event is `bookable` if: - The event's `startDate` is later than or equal to `query.filter.startDate`. - The event's `endDate` is before or equal to `query.filter.endDate`. - The event's `remainingCapacity` is greater than `0`. - The service's `onlineBooking.enabled` is `true`. - The service's early/late booking policies are either not enabled or the current time is within the defined limits.  If you want to restrict returned class events to those with a minimum number of remaining spots, specify `openSpots` in the filter. By default, all class events, even those with no open spot, are returned.  ### Daylight Savings Time (DST)  Due to DST, some local times may not exist or may occur twice. For example, in Santiago, Chile, on September 7, 2025, 0:05 AM doesn't exist because the clock advances from 0:00 AM to 1:00 AM.  Query Availability* automatically adjusts for these gaps. Non-existent times are moved forward by 1 hour, while existing times remain unchanged. For instance, if you call *Query Availability* with a `startDate` of `2025-09-07T00:00:01.000` and an `endDate` of `2025-09-08T00:00:02.000`, the adjusted query will use `2025-09-07T01:00:01.000` as the new start time.
 URL: https://www.wixapis.com/availability-calendar/v1/availability/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, query.filter
 Method parameters: 
   param name: query | type: QueryV2   | required: true 
        - name: filter | type: object | description: Filter object. For a list of fields you can filter by, see [Availability Calendar supported filters](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.md). You must include `serviceId`, `startDate` and `endDate` in the filter. This avoids large results that can impact performance. | required: true 
        - name: sort | type: array<Sorting> | description: Sort options. Currently, only sorting by `startDate` is supported. For details on sorting, see [Availability Calendar supported sorting](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.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
   param name: slotsPerDay | type: slotsPerDay | description: Maximum number of appointment slots to return for each date. For example, if you specify `{"slotsPerDay": 3}`, a maximum of 3 appointment slots/class events is returned for each day that's within the query filter's date range.  | validation: format int32
   param name: timezone | type: timezone | description: Time zone override for the `endDate` and `startDate` filters, in [IANA tz database format](https://en.wikipedia.org/wiki/Tz_database), such as `America/New_York` or `UTC`.  For example, if you specify `("startDate": "2025-11-25T17:00:00+01:00"}` (note the +01:00 offset) in combination with `{"timezone": "Europe/Bucharest"}` (+02:00 offset), *Query Availability* adjusts the effective start time to reflect the specified time zone. In this case, the start time in UTC would be `2025-11-25T15:00:00` (using the +02:00 offset).  Learn more about [handling Daylight Savings Time](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_daylight-savings-time-dst).  Default: No modification applied to the `endDate` and `startDate` filters.  
 Return type: QueryAvailabilityResponse
  - name: availabilityEntries | type: array<SlotAvailability> | description: List of appointment slots or class events matching the filter.  
     - name: slot | type: Slot | description: The slot for the corresponding session, when the session is either a single session or a specific session generated from a recurring session.  
        - name: serviceId | type: string | description: Service GUID.  
        - name: scheduleId | type: string | description: Schedule GUID.  
        - name: startDate | type: string | description: The start time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format.  If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `start_date` is ignored.  
        - name: endDate | type: string | description: The end time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format.  If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `end_date` is ignored.  
        - name: timezone | type: string | description: The timezone for which slot availability is to be calculated.  Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones) when calculating availability.  
        - name: resource | type: SlotResource | description: The resource required for this slot. Currently, the only supported resource is the relevant staff member for the slot.  
           - name: id | type: string | description: Resource GUID.  | read-only: true | validation: format GUID
           - name: name | type: string | description: Resource name. Read only.  | validation: maxLength 1200
        - name: location | type: Location | description: Geographic location of the slot.  
           - name: id | type: string | description: Business location GUID. Available only for locations that are business locations, meaning the `location_type` is `"OWNER_BUSINESS"`.  | validation: format GUID
           - name: name | type: string | description: Location name.  
           - name: formattedAddress | type: string | description: The full address of this location.  
           - name: formattedAddressTranslated | type: string | description: The full translated address of this location.  | validation: maxLength 512
           - name: locationType | type: LocationType | description: Location type.  
                 - enum:
                 -     UNDEFINED: Undefined location type.
                 -     OWNER_BUSINESS: The business address, as set in the site’s general settings.
                 -     OWNER_CUSTOM: The address as set when creating the service.
                 -     CUSTOM: The address as set for the individual session.
        - name: eventId | type: string | description: GUID for the slot's corresponding event, when the event is either a single event or a specific event generated from a recurring event.  | validation: minLength 36, maxLength 250
     - name: bookable | type: boolean | description: Whether the slot is bookable. Bookability is determined by checking a session's open slots and booking policies. Locks are not taken into account.  
     - name: totalSpots | type: integer | description: Total number of spots for this slot. For example, if a session has a total of 10 spots and 3 spots are booked, `spotsTotal` is 10 and `openSpots` is 7.  | validation: format int32
     - name: openSpots | type: integer | description: Number of open spots for this slot.  | validation: format int32
     - name: waitingList | type: WaitingList | description: An object describing the slot's waitlist and its occupancy.  
        - name: totalSpots | type: integer | description: Total number of spots and open spots for this waitlist. For example, a Yoga class with 10 waitlist spots and 3 registered on the waitlist has 10 `total_spots` and 7 `open_spots`.  | validation: format int32
        - name: openSpots | type: integer | description: Number of open spots for this waitlist.  | validation: format int32
     - name: bookingPolicyViolations | type: BookingPolicyViolations | description: Booking policy violations for the slot.  
        - name: tooEarlyToBook | type: boolean | description: Bookings policy violation. Too early to book this slot.  
        - name: tooLateToBook | type: boolean | description: Bookings policy violation. Too late to book this slot.  
        - name: bookOnlineDisabled | type: boolean | description: Bookings policy violation. Online booking is disabled for this slot.  
        - name: validSubmissionRequired | type: boolean | description: Bookings policy violation. Intake Form submission is required for this slot.  
     - name: locked | type: boolean | description: Indicates whether the slot is locked because a waitlist exists. When a slot frees up, the slot is offered to the next customer on the waitlist. Read-only.  


```

### Examples

### Query for available, bookable slots for a service in a given time range
```curl
curl -X POST 'https://www.wixapis.com/availability-calendar/v1/availability/query' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "filter": {
          "serviceId": [
            "832adc1f-d6cc-412d-894d-f04455baec68", "f018ad57-0403-488f-971d-fc33511bbc3a"
          ],
          "startDate": "2023-05-20T12:17:08.912Z",
          "endDate": "2023-05-25T10:13:49.549Z",
          "bookable": "true"
        }
      }
    }'
```

### Query for available open slots for a specific service in a given time range
```curl
curl -X POST 'https://www.wixapis.com/availability-calendar/v1/availability/query' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "filter": {
          "serviceId": [
            "832adc1f-d6cc-412d-894d-f04455baec68", "f018ad57-0403-488f-971d-fc33511bbc3a"
          ],
          "startDate": "2023-05-20T12:00:00.000Z",
          "endDate": "2023-05-20T13:30:00.000Z",
          "openSpots": {"$gte": "10"}
        }
      }
    }'
```

### Query for available slots for a service by location and date range
```curl
curl -X POST 'https://www.wixapis.com/availability-calendar/v1/availability/query' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "filter": {
          "serviceId": [
            "832adc1f-d6cc-412d-894d-f04455baec68"
          ],
          "startDate": "2023-05-20T12:00:00.000Z",
          "endDate": "2023-05-20T13:00:00.000Z",
          "location.businessLocation.id": ["3dd710bd-3480-49b4-a549-0522b035a8d7"]
        }
      }
    }'
```

### Query for a service's available slots by resource ID for a given time range
```curl
curl -X POST 'https://www.wixapis.com/availability-calendar/v1/availability/query' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "filter": {
          "serviceId": [
            "832adc1f-d6cc-412d-894d-f04455baec68", "f018ad57-0403-488f-971d-fc33511bbc3a"
          ],
          "startDate": "2023-05-20T12:17:08.912Z",
          "endDate": "2023-05-25T10:13:49.549Z",
          "resourceId":["70586e51-b75c-4425-818b-68cfd7954022"]
        }
      }
    }'
```

### Query for available slots for a specific service in a given time range
```curl
curl -X POST 'https://www.wixapis.com/availability-calendar/v1/availability/query' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "filter": {
          "serviceId": ["832adc1f-d6cc-412d-894d-f04455baec68"],
          "startDate": "2023-05-20T12:17:08.912Z",
          "endDate": "2023-05-25T10:13:49.549Z"
        }
      }
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.availabilityCalendar.queryAvailability(query, options)
 Description: Retrieves appointment slots or class events that match specified filters.  ### Course limitations  Course events can't be retrieved with this method. Follow this [sample flow](https://dev.wix.com/docs/rest/business-solutions/bookings/end-to-end-booking-flows.md#book-a-course) to check course availability.  ### Query filter  You must include `serviceId` in your query filter. For performance, also specify both `startDate` and `endDate`. Refer to the [supported filters article](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.md) for a complete list of supported filters.  ### Limit the number of slots returned per day  To limit the maximum number of appointment slots returned for each date, specify `slotsPerDay`. For example,  specifying `{"slotsPerDay": 3}` returns a maximum of 3 appointment slots/class events for each day that's within the query filter's date range.  ### Unavailable slots  By default, both available and unavailable appointment slots/ class events are returned. To retrieve only available slots/events, specify `{"bookable": true}` in the filter.  ### Sorting  Slots/events can be sorted only by `startDate`. Unavailable slots/events always appear after available ones.  ### Availability calculation  Wix Bookings calculates availability differently for appointment-based services and classes.  #### Appointment availability  An appointment slot is `bookable` if: - The slot's `startDate` is later than or equal to `query.filter.startDate`. - The slot's `endDate` is before or equal to `query.filter.endDate`. - The service's `onlineBooking.enabled` is `true`. - The service's early/late booking policies are either not enabled or the current time is within the defined limits.  #### Class event availability  A class event is `bookable` if: - The event's `startDate` is later than or equal to `query.filter.startDate`. - The event's `endDate` is before or equal to `query.filter.endDate`. - The event's `remainingCapacity` is greater than `0`. - The service's `onlineBooking.enabled` is `true`. - The service's early/late booking policies are either not enabled or the current time is within the defined limits.  If you want to restrict returned class events to those with a minimum number of remaining spots, specify `openSpots` in the filter. By default, all class events, even those with no open spot, are returned.  ### Daylight Savings Time (DST)  Due to DST, some local times may not exist or may occur twice. For example, in Santiago, Chile, on September 7, 2025, 0:05 AM doesn't exist because the clock advances from 0:00 AM to 1:00 AM.  Query Availability* automatically adjusts for these gaps. Non-existent times are moved forward by 1 hour, while existing times remain unchanged. For instance, if you call *Query Availability* with a `startDate` of `2025-09-07T00:00:01.000` and an `endDate` of `2025-09-08T00:00:02.000`, the adjusted query will use `2025-09-07T01:00:01.000` as the new start time.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query, query.filter
 Method parameters: 
   param name: query | type: QueryV2   | required: true 
        - name: filter | type: object | description: Filter object. For a list of fields you can filter by, see [Availability Calendar supported filters](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.md). You must include `serviceId`, `startDate` and `endDate` in the filter. This avoids large results that can impact performance. | required: true 
        - name: sort | type: array<Sorting> | description: Sort options. Currently, only sorting by `startDate` is supported. For details on sorting, see [Availability Calendar supported sorting](https://dev.wix.com/docs/rest/business-solutions/bookings/time-slots/availability-calendar/supported-fields-filters-and-sorting.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.  
   param name: options | type: QueryAvailabilityOptions  none  
        - name: timezone | type: string | description: Time zone override for the `endDate` and `startDate` filters, in [IANA tz database format](https://en.wikipedia.org/wiki/Tz_database), such as `America/New_York` or `UTC`.  For example, if you specify `("startDate": "2025-11-25T17:00:00+01:00"}` (note the +01:00 offset) in combination with `{"timezone": "Europe/Bucharest"}` (+02:00 offset), *Query Availability* adjusts the effective start time to reflect the specified time zone. In this case, the start time in UTC would be `2025-11-25T15:00:00` (using the +02:00 offset).  Learn more about [handling Daylight Savings Time](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_daylight-savings-time-dst).  Default: No modification applied to the `endDate` and `startDate` filters.  
        - name: slotsPerDay | type: integer | description: Maximum number of appointment slots to return for each date. For example, if you specify `{"slotsPerDay": 3}`, a maximum of 3 appointment slots/class events is returned for each day that's within the query filter's date range.  | validation: format int32
 Return type: PROMISE<QueryAvailabilityResponse>
  - name: availabilityEntries | type: array<SlotAvailability> | description: List of appointment slots or class events matching the filter.  
     - name: slot | type: Slot | description: The slot for the corresponding session, when the session is either a single session or a specific session generated from a recurring session.  
        - name: serviceId | type: string | description: Service GUID.  
        - name: scheduleId | type: string | description: Schedule GUID.  
        - name: startDate | type: string | description: The start time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format.  If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `start_date` is ignored.  
        - name: endDate | type: string | description: The end time of this slot in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format.  If `timezone` is specified, dates are based on the local date/time. This means that the timezone offset in the `end_date` is ignored.  
        - name: timezone | type: string | description: The timezone for which slot availability is to be calculated.  Learn more about [handling Daylight Savings Time (DST) for local time zones](https://dev.wix.com/api/rest/wix-bookings/availability-calendar/query-availability#wix-bookings_availability-calendar_query-availability_handling-daylight-savings-time-dst-for-local-time-zones) when calculating availability.  
        - name: resource | type: SlotResource | description: The resource required for this slot. Currently, the only supported resource is the relevant staff member for the slot.  
           - name: _id | type: string | description: Resource GUID.  | read-only: true | validation: format GUID
           - name: name | type: string | description: Resource name. Read only.  | validation: maxLength 1200
        - name: location | type: Location | description: Geographic location of the slot.  
           - name: _id | type: string | description: Business location GUID. Available only for locations that are business locations, meaning the `location_type` is `"OWNER_BUSINESS"`.  | validation: format GUID
           - name: name | type: string | description: Location name.  
           - name: formattedAddress | type: string | description: The full address of this location.  
           - name: formattedAddressTranslated | type: string | description: The full translated address of this location.  | validation: maxLength 512
           - name: locationType | type: LocationType | description: Location type.  
                 - enum:
                 -     UNDEFINED: Undefined location type.
                 -     OWNER_BUSINESS: The business address, as set in the site’s general settings.
                 -     OWNER_CUSTOM: The address as set when creating the service.
                 -     CUSTOM: The address as set for the individual session.
        - name: eventId | type: string | description: GUID for the slot's corresponding event, when the event is either a single event or a specific event generated from a recurring event.  | validation: minLength 36, maxLength 250
     - name: bookable | type: boolean | description: Whether the slot is bookable. Bookability is determined by checking a session's open slots and booking policies. Locks are not taken into account.  
     - name: totalSpots | type: integer | description: Total number of spots for this slot. For example, if a session has a total of 10 spots and 3 spots are booked, `spotsTotal` is 10 and `openSpots` is 7.  | validation: format int32
     - name: openSpots | type: integer | description: Number of open spots for this slot.  | validation: format int32
     - name: waitingList | type: WaitingList | description: An object describing the slot's waitlist and its occupancy.  
        - name: totalSpots | type: integer | description: Total number of spots and open spots for this waitlist. For example, a Yoga class with 10 waitlist spots and 3 registered on the waitlist has 10 `total_spots` and 7 `open_spots`.  | validation: format int32
        - name: openSpots | type: integer | description: Number of open spots for this waitlist.  | validation: format int32
     - name: bookingPolicyViolations | type: BookingPolicyViolations | description: Booking policy violations for the slot.  
        - name: tooEarlyToBook | type: boolean | description: Bookings policy violation. Too early to book this slot.  
        - name: tooLateToBook | type: boolean | description: Bookings policy violation. Too late to book this slot.  
        - name: bookOnlineDisabled | type: boolean | description: Bookings policy violation. Online booking is disabled for this slot.  
        - name: validSubmissionRequired | type: boolean | description: Bookings policy violation. Intake Form submission is required for this slot.  
     - name: locked | type: boolean | description: Indicates whether the slot is locked because a waitlist exists. When a slot frees up, the slot is offered to the next customer on the waitlist. Read-only.  


```

### Examples

### Retrieve available slots for a class service (with $w)
```javascript
/********************************************
 * Backend code - my-backend-file.web.js/ts *
 *******************************************/

 import { availabilityCalendar } from '@wix/bookings';
 import { webMethod, Permissions } from '@wix/web-methods';
 
 export const myQueryAvailability = webMethod(
   Permissions.Anyone,
   async (query, options) => {
     try {
       const availableSlots = await availabilityCalendar.queryAvailability(query, options);
       return availableSlots;
     } catch (error) {
       console.error(error);
       // Handle the error
     }
   }
 );

/*************
 * Page code *
 ************/

 import { myQueryAvailability } from 'backend/my-backend-file.web.js/ts';

 $w.onReady(() => {
   // set query time range to 1 week from now
   const today = new Date();
   const endRange = new Date();
   endRange.setDate(today.getDate() + 7);
 
   const query = {
     "filter" : { 
       "serviceId": "036d51c9-d9fd-4459-be7a-a05e882f3e93",
       "startDate": today.toISOString(),
       "endDate": endRange.toISOString()
     }
   };
   const options = {
     "slotsPerDay" : "1"
   }
 
   $w('#submitButton').onClick(async () => {
     try {
       const availability = await myQueryAvailability(query, options);
       // Handle the fulfilled response
       console.log('Availability', availability)
     } catch (error) {
       // Handle the error
       console.error(error);      
     }
   });
 });

/* Promise resolves to:
 *{
 *  "availabilityEntries": [
 *    {
 *      "slot": {
 *        "sessionId": "193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7ExgIRM1UZAV13fLX2gNLq4sCQwIdZIpxI6tDJxatWo81RhW6mQLgcnnO6ONJkvJH5ZYZEwHOIPMbmhqD5t41JnX3cUcIi0QOtrQjuZmfUCJFaA6fTnI97I4b9OD9AbOfkGsYnZW5UL0Yoc0amYhtACJPhRRe3qJSC5Qxp0aHl0j0ExBDV5ZTajTM1L6QktIUelYWU4Fq45KPYFvqc1UXeLTURzcOG4wsATMD47b5XfFqC9Myj02MJFRmz5nBS47v7586qsxgmQTYw6MVp",
 *        "serviceId": "036d51c9-d9fd-4459-be7a-a05e882f3e93",
 *        "scheduleId": "c0cf791e-fbc0-44e7-8db3-4c2eb7aa9253",
 *        "startDate": "2024-04-11T12:30:00.000Z",
 *        "endDate": "2024-04-11T13:30:00.000Z",
 *        "timezone": "UTC",
 *        "resource": {
 *          "name": "Barber Simon",
 *          "scheduleId": "f0212cd6-8437-4f2f-bdb0-019bc407bd84",
 *          "_id": "76570209-101f-409b-af97-b445bdb63125"
 *        },
 *        "location": {
 *          "name": "East 45th Street",
 *          "formattedAddress": "United Nations Headquarters, East 45th Street, New York, NY, USA",
 *          "locationType": "OWNER_BUSINESS",
 *          "_id": "03b3ef52-5700-406d-aa70-1b7f0bc5b067"
 *        }
 *      },
 *      "bookable": true,
 *      "totalSpots": 5,
 *      "openSpots": 5,
 *      "waitingList": {},
 *      "bookingPolicyViolations": {
 *        "tooEarlyToBook": false,
 *        "tooLateToBook": false,
 *        "bookOnlineDisabled": false
 *      },
 *      "locked": false,
 *      "isFromV2": false,
 *      "nestedSlots": []
 *    }
 *  ],
 *  "pagingMetadata": {
 *    "count": 1,
 *    "cursors": {}
 *  }
 *}
 */

```

### queryAvailability (self-managed)
Self-managed 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 { availabilityCalendar } from '@wix/bookings';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


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

---