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:
| Parameter | Type | Description |
|---|---|---|
source | string enum | Source table or origin (e.g., rule, slot) |
start_ts | int | Start timestamp (epoch seconds) |
end_ts | int | End timestamp (epoch seconds) |
product_id | int | Filter by product ID |
staff_id | int | Filter by staff ID |
scope | string | Index scope or segmentation |
appointable | bool | Filter by appointable status |
status | string | Status 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
- Calendar Views - Fast loading of availability data for calendar displays
- Dashboards - Quick overview of availability across products/staff
- Slot Computations - Efficient slot calculation within cache horizon
- Analytics - Historical availability data analysis
Best Practices
- Use within cache horizon - Index is only available for recent/future dates
- Filter by time window - Always provide
start_tsandend_tsfor performance - Combine with Slots endpoint - Use Index for overview, Slots for detailed availability
- Handle fallback - Be prepared for non-indexed responses outside cache window
Related Documentation
- Slots Endpoints - For detailed slot availability
- Caching & Performance - Understanding cache behavior
- Availabilities Endpoints - For managing availability rules