Skip to main content

Index Endpoint (V2)

Read-only access to precomputed availability/occurrence index stored in cache table. This endpoint provides the fastest way to access availability data for calendar views and dashboards when within the indexing horizon.

Endpoint

GET /wc-appointments/v2/index

Purpose: Fast read access to precomputed availability data for calendar views, dashboards, and slot computations within cache horizon.

Permissions: Public read. Filters out non-readable products.

Parameters:

ParameterTypeDescription
sourcestring enumSource table or origin (e.g., rule, slot)
start_tsintStart timestamp (epoch seconds)
end_tsintEnd timestamp (epoch seconds)
product_idintFilter by product ID
staff_idintFilter by staff ID
scopestringIndex scope or segmentation
appointableboolFilter by appointable status
statusstringStatus filter (controller excludes non-readable products regardless)

Response Schema (row):

  • source (string)
  • source_id (int)
  • product_id (int)
  • staff_id (int|null)
  • scope (string)
  • appointable (bool)
  • priority (int)
  • qty (int)
  • start_ts (int, epoch seconds)
  • end_ts (int, epoch seconds)
  • range_type (string)
  • rule_kind (string)
  • status (string)
  • date_created (datetime)
  • date_modified (datetime)

Notes:

  • Designed for fast reads; not a CRUD API
  • Use this endpoint for calendar views, dashboards, and slot computations within cache horizon
  • Index responses use epoch seconds to allow consistent client-side time arithmetic
  • Falls back to per-product computation when outside cache window or indexing is disabled

Example Request:

GET /wp-json/wc-appointments/v2/index?product_id=123&start_ts=1735689600&end_ts=1738195200

Example Response:

[
{
"source": "rule",
"source_id": 45,
"product_id": 123,
"staff_id": null,
"scope": "global",
"appointable": true,
"priority": 10,
"qty": 1,
"start_ts": 1735689600,
"end_ts": 1735776000,
"range_type": "custom",
"rule_kind": "availability",
"status": "active",
"date_created": "2025-01-01T00:00:00",
"date_modified": "2025-01-01T00:00:00"
}
]

Use Cases

  1. Calendar Views - Fast loading of availability data for calendar displays
  2. Dashboards - Quick overview of availability across products/staff
  3. Slot Computations - Efficient slot calculation within cache horizon
  4. Analytics - Historical availability data analysis

Best Practices

  1. Use within cache horizon - Index is only available for recent/future dates
  2. Filter by time window - Always provide start_ts and end_ts for performance
  3. Combine with Slots endpoint - Use Index for overview, Slots for detailed availability
  4. Handle fallback - Be prepared for non-indexed responses outside cache window