Skip to main content

Slots Endpoints

Get available appointment slots for products.

V1 Endpoint

GET /wc-appointments/v1/slots

Compute available appointment slots via product logic (non-indexed path).

Permissions: Public read. Non-readable products are filtered out.

Parameters:

ParameterTypeDescription
product_idsarray|intProduct IDs to include (also accepts singular product_id)
category_idsarray|intCategory IDs to include (also accepts singular category_id)
staff_idsarray|intStaff IDs to include (also accepts singular staff_id); see Staff IDs Architecture
min_datestringDate window start (YYYY-MM-DD)
max_datestringDate window end (YYYY-MM-DD)
get_past_timesboolInclude past times
pageintPagination page number
limitintResults per page
hide_unavailableboolExclude results with available = false

Response Fields:

  • product_id (int)
  • product_name (string)
  • date (string, YYYY-MM-DD)
  • timestamp (int, epoch seconds, V1 omits when not applicable)
  • duration (int)
  • duration_unit (string)
  • available (bool)
  • scheduled (int, quantity)
  • staff_id (int|null)

Notes:

  • Honors product configuration: duration, interval, padding, min/max dates, restricted days, staff assignment
  • Avoids deep nesting and favors early returns for performance internally

Example Request:

GET /wp-json/wc-appointments/v1/slots?product_ids=123&min_date=2025-01-01&max_date=2025-01-31

Example Response:

[
{
"product_id": 123,
"product_name": "Haircut",
"date": "2025-01-15",
"timestamp": 1736966400,
"duration": 60,
"duration_unit": "minute",
"available": true,
"scheduled": 0,
"staff_id": 5
}
]

V2 Endpoint

GET /wc-appointments/v2/slots

Same as V1 but uses cached/indexed implementations when available and within cache horizon.

Permissions: Public read; filters out non-readable products.

Parameters:

ParameterTypeDescription
product_idsarray|intProduct IDs to include (also accepts singular product_id)
category_idsarray|intCategory IDs to include (also accepts singular category_id)
staff_idsarray|intStaff IDs to include (also accepts singular staff_id); see Staff IDs Architecture
min_datestringDate window start (YYYY-MM-DD)
max_datestringDate window end (YYYY-MM-DD)
min_timestampintStart timestamp (epoch seconds)
max_timestampintEnd timestamp (epoch seconds)
get_past_timesboolInclude past times
pageintPagination page number
per_pageintResults per page (preferred)
limitintAlias for per_page (backwards compatible)
hide_unavailableboolExclude unavailable slots
combine_staffboolUnion across staff so each timestamp appears once per product with summed remaining capacity
paged_streamboolPage-aware, day-by-day generation that stops early after page * per_page records; only active when combine_staff = true and pagination is requested

Response:

{
"records": [
{
"product_id": 123,
"product_name": "Haircut",
"date": "2025-01-15",
"timestamp": 1736966400,
"duration": 60,
"duration_unit": "minute",
"available": true,
"scheduled": 0,
"staff_id": 5
}
],
"count": 1
}

Response Fields:

  • records (array): Array of slot objects
  • count (int): Total number of records

Slot Object Fields:

  • product_id (int)
  • product_name (string)
  • date (string, YYYY-MM-DD)
  • timestamp (int, epoch seconds)
  • duration (int)
  • duration_unit (string)
  • available (bool)
  • scheduled (int, quantity)
  • staff_id (int|null)

Notes:

  • Falls back to non-indexed path when outside cache window or when indexing is disabled
  • limit is a backwards-compatible alias for per_page and is supported for existing clients
  • Use combine_staff=true to get union of all staff availability
  • Use paged_stream=true with combine_staff=true for efficient pagination

Example Requests:

Basic query:

GET /wp-json/wc-appointments/v2/slots?product_ids=123&min_date=2025-01-01&max_date=2025-01-31

With staff union:

GET /wp-json/wc-appointments/v2/slots?product_id=123&min_date=2025-01-01&max_date=2025-01-31&combine_staff=true&hide_unavailable=true

Paginated with timestamp range:

GET /wp-json/wc-appointments/v2/slots?product_id=123&min_timestamp=1735689600&max_timestamp=1738195200&page=2&limit=25

Paged stream (efficient pagination):

GET /wp-json/wc-appointments/v2/slots?product_id=123&min_timestamp=1735689600&max_timestamp=1738195200&per_page=10&page=1&combine_staff=true&paged_stream=true

Differences: V1 vs V2

FeatureV1V2
CachingNoYes (when available)
Response FormatArrayObject with records and count
Timestamp ParametersNoYes (min_timestamp, max_timestamp)
Staff UnionNoYes (combine_staff)
Paged StreamNoYes (paged_stream)
Paginationlimitper_page (or limit alias)

Best Practices

  1. Use V2 for production - Better performance with caching
  2. Use timestamp parameters - More precise than date strings
  3. Use combine_staff=true - When you don't need staff-specific slots
  4. Use paged_stream=true - For efficient pagination with large datasets
  5. Set hide_unavailable=true - To filter out unavailable slots
  6. Cache results client-side - Reduce API calls