WooCommerce REST API
To use the Appointments booking API, you will need to use Appointments 4.5.0 or newer. Before you start, check the WooCommerce REST API library. It is simple to set up and you basically need to generate REST API key to use it inside your App. Once the API key is generated, you can test it with services like Postman or Insomnia. Read more about API testing here.
API Controllers
Booking API includes 6 controllers you can utilize to read data from your website. Each controller has its own set of attributes that can filter the result according to your needs. There are also links withing results to a single result for more details – for instance, you can access individual appointment by ID.
1. Appointments API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/appointments
Result:
[ { "id": 5560, "all_day": false, "cost": "0", "customer_id": 0, "date_created": 1554385263, "date_modified": 1554385263, "start": 1559912400, "end": 1559916000, "google_calendar_event_id": "0", "google_calendar_staff_event_ids": "", "order_id": 0, "order_item_id": 0, "parent_id": 0, "product_id": 45, "staff_id": [], "staff_ids": [], "status": "paid", "customer_status": "expected", "qty": "1", "timezone": "", "_links": { "self": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/appointments/5560" } ], "collection": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/appointments" } ] } } ]
2. Slots API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/slots
Result:
{ "records": [ { "date": "2019-05-01T00:00", "duration": 2, "duration_unit": "month", "available": 2, "scheduled": 0, "product_id": 6856, "product_name": "Product One" }, { "date": "2019-05-21T00:00", "duration": 1, "duration_unit": "day", "available": 5, "scheduled": 0, "product_id": 6911, "product_name": "Product Two" }, { "date": "2019-05-22T00:00", "duration": 7, "duration_unit": "day", "available": 8, "scheduled": 0, "product_id": 6362, "product_name": "Product Three" }, { "date": "2019-05-22T00:00", "duration": 1, "duration_unit": "day", "available": 6, "scheduled": 0, "product_id": 10528, "product_name": "Product Four" } ], "count": 4 }
3. Availability API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/availabilities
Result:
[ { "ID": "314", "kind": "availability#product", "kind_id": "6911", "event_id": "", "title": "", "range_type": "days", "from_date": "", "to_date": "", "from_range": "1", "to_range": "7", "rrule": "", "appointable": "yes", "priority": "10", "qty": "0", "ordering": "0", "date_created": "2019-03-07 18:16:48", "date_modified": "2019-04-13 16:40:23", "start_date": "0000-00-00", "end_date": "9999-99-99", "type": "days", "to": "7", "from": "1" }, { "ID": "399", "kind": "availability#global", "kind_id": "", "event_id": "5uoj868siln23qoq3m0fuvv7nu", "title": "RRule for dates", "range_type": "rrule", "from_date": "", "to_date": "", "from_range": "2019-04-05", "to_range": "2019-04-05", "rrule": "RRULE:FREQ=WEEKLY;WKST=MO;COUNT=3;BYDAY=FR", "appointable": "no", "priority": "5", "qty": "0", "ordering": "0", "date_created": "2019-03-22 21:16:59", "date_modified": "2019-04-12 14:00:13", "start_date": "0000-00-00", "end_date": "9999-99-99", "type": "rrule", "to": "2019-04-05", "from": "2019-04-05" }, { "ID": "491", "kind": "availability#staff", "kind_id": "6", "event_id": "", "title": "", "range_type": "time:range", "from_date": "2018-11-14", "to_date": "2018-11-15", "from_range": "09:00", "to_range": "13:00", "rrule": "", "appointable": "yes", "priority": "10", "qty": "0", "ordering": "0", "date_created": "2019-03-28 18:10:57", "date_modified": "2019-03-28 18:10:57", "start_date": "2018-11-14", "end_date": "2018-11-15", "type": "time:range", "to": "13:00", "from": "09:00" } ]
4. Staff API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/staff
Result:
[ { "id": 7, "display_name": "Staff Name", "full_name": "Staff Full Name", "email": "staff@email.com", "availability": [ { "ID": "392", "kind": "availability#staff", "kind_id": "7", "event_id": "", "title": "", "range_type": "time:range", "from_date": "2018-12-13", "to_date": "2018-12-14", "from_range": "09:00", "to_range": "13:00", "rrule": "", "appointable": "yes", "priority": "10", "qty": "0", "ordering": "0", "date_created": "2019-03-07 18:16:48", "date_modified": "2019-03-07 18:16:48", "start_date": "2018-12-13", "end_date": "2018-12-14", "type": "time:range", "to": "13:00", "from": "09:00" }, { "ID": "494", "kind": "availability#staff", "kind_id": "7", "event_id": "", "title": "", "range_type": "days", "from_date": "", "to_date": "", "from_range": "1", "to_range": "1", "rrule": "", "appointable": "no", "priority": "10", "qty": "0", "ordering": "1", "date_created": "2019-03-28 18:10:57", "date_modified": "2019-03-28 18:10:57", "start_date": "0000-00-00", "end_date": "9999-99-99", "type": "days", "to": "1", "from": "1" } ], "products": [ { "id": 7165, "name": "Product Name", "price": "50", "price_html": "€50.00 60 minutes ", "staff_cost": "", "staff_qty": "", "self": { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products/7165" }, "collection": { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products" } } ], "_links": { "self": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/staff/7" } ], "collection": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/staff" } ] } } ]
5. Products API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/products
Result:
[ { "id": 18597, "name": "Product Name", "slug": "product-name", "permalink": "https://yoursite.com/product/product-name/", "date_created": "2019-05-14T19:55:18", "date_created_gmt": "2019-05-14T17:55:18", "date_modified": "2019-05-15T19:48:00", "date_modified_gmt": "2019-05-15T17:48:00", "type": "appointment", "status": "publish", "featured": false, "catalog_visibility": "visible", "description": "", "short_description": "", "sku": "", "price": "28", "regular_price": "28", "sale_price": "", "date_on_sale_from": null, "date_on_sale_from_gmt": null, "date_on_sale_to": null, "date_on_sale_to_gmt": null, "price_html": "From $56 1 hour ", "on_sale": false, "purchasable": true, "total_sales": 0, "virtual": true, "downloadable": false, "downloads": [], "download_limit": -1, "download_expiry": -1, "external_url": "", "button_text": "", "tax_status": "taxable", "tax_class": "", "manage_stock": false, "stock_quantity": null, "stock_status": "instock", "backorders": "no", "backorders_allowed": false, "backordered": false, "sold_individually": false, "weight": "", "dimensions": { "length": "", "width": "", "height": "" }, "shipping_required": false, "shipping_taxable": false, "shipping_class": "", "shipping_class_id": 0, "reviews_allowed": true, "average_rating": "0.00", "rating_count": 0, "related_ids": [ 6045, 242, 5900, 6051, 6277 ], "upsell_ids": [], "cross_sell_ids": [], "parent_id": 0, "purchase_note": "", "categories": [ { "id": 15, "name": "Uncategorized", "slug": "uncategorized" } ], "tags": [], "images": [], "attributes": [], "default_attributes": [], "variations": [], "grouped_products": [], "menu_order": 0, "meta_data": [ { "id": 43195, "key": "_product_addons", "value": [] }, { "id": 43196, "key": "_product_addons_exclude_global", "value": "0" }, ], "has_price_label": "1", "price_label": "From $56", "has_pricing": "1", "pricing": [ { "type": "quant", "cost": "", "modifier": "", "base_cost": "3", "base_modifier": "minus", "from": "3", "to": "3" }, { "type": "time", "cost": "", "modifier": "", "base_cost": "4", "base_modifier": "", "from": "17:00", "to": "00:00" } ], "qty": 5, "qty_min": 2, "qty_max": 5, "duration_unit": "hour", "duration": 1, "interval_unit": "hour", "interval": 1, "padding_duration_unit": "day", "padding_duration": 0, "min_date_unit": "day", "min_date": 0, "max_date_unit": "month", "max_date": 12, "user_can_cancel": false, "cancel_limit_unit": "month", "cancel_limit": 1, "requires_confirmation": false, "customer_timezones": false, "cal_color": "#0073aa", "availability_span": "", "availability_autoselect": false, "availability": [ { "ID": "696", "kind": "availability#product", "kind_id": "18597", "event_id": "", "title": "", "range_type": "time", "from_date": "", "to_date": "", "from_range": "11:00", "to_range": "00:00", "rrule": "", "appointable": "yes", "priority": "10", "qty": "0", "ordering": "0", "date_created": "2019-05-14 19:55:18", "date_modified": "2019-05-15 19:48:00", "start_date": "0000-00-00", "end_date": "9999-99-99", "type": "time", "to": "00:00", "from": "11:00" } ], "has_restricted_days": "", "restricted_days": "", "staff_label": "", "staff_assignment": "customer", "staff_nopref": true, "staff_ids": [], "staff_base_costs": [], "staff_qtys": [], "_links": { "self": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products/18597" } ], "collection": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products" } ] } } ]
6. Product Categories API Controller
Endpoint:
GET https://yoursite.com/wp-json/wc-appointments/v1/products/categories
Result:
[ { "id": 26, "name": "Events", "slug": "events", "parent": 0, "description": "", "display": "default", "image": null, "menu_order": 0, "count": 2, "_links": { "self": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products/categories/26" } ], "collection": [ { "href": "https://yoursite.com/wp-json/wc-appointments/v1/products/categories" } ] } } ]
Leave a Reply