Documentation for the REST API

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1217422
    Loris Plasson
    Participant

    Hello, since the new version there is this line on the changelog (and an advanced tab in the settings).

    4.1.0, Nov 19 2021
    New: Implemented REST API. This will give developers more extensive control over the plugin data, help integrate third-party services, and build new frontend experiences for Hotel Booking in WordPress.

    Could someone tell me more about this interesting looking like feature? I did not see it mentionned anywhere on the documentation.

    Regards,
    Loris.

    #1223573
    Alex M
    Participant

    Documentation is in the progress.

    Authorization: Basic auth.
    You should send Consumer Key and Consumer Secret with your Request.
    https://learning.postman.com/docs/sending-requests/authorization/#basic-auth

    You can navigate to yourwebsite.com/wp-json/mphb/v1/ to see all available routes and params.

    For example:
    1. GET request yourwebsite.com/wp-json/mphb/v1/bookings/ will return 10 recent bookings from your website.

    2. POST request yourwebsite.com/wp-json/mphb/v1/bookings/
    with JSON data

    {
        "reserved_accommodations": [
            {
                "accommodation": 97,
                "adults": 1
            }
        ],
        "check_in_date": "2021-11-27",
        "check_out_date": "2021-11-28"
    }

    will create a new booking with params above.

    3. PUT request yourwebsite.com/wp-json/mphb/v1/bookings/410
    with JSON data

    {
        "status":"cancelled"
    }

    will set status of the booking #410 to Cancelled.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.