MENU navbar-image

Introduction

Example project cloning booking.com built with Laravel as part of Course in LaravelDaily.com

This documentation aims to provide all the information you need to work with our API.

Authenticating requests

To authenticate requests, include a X-XSRF-TOKEN header with the value "{YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by making a request to /sanctum/csrf-cookie

Authentication

Register a new user.

[Creates a new user and returns a token for authentication.]

Example request:
curl --request POST \
    "http://booking-com-simulation-laravel.test/api/auth/register" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"vjsoxgflpadkawiltji\",
    \"email\": \"muller.tristin@example.com\",
    \"password\": \"ullam\",
    \"role_id\": \"aperiam\"
}"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/auth/register"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "vjsoxgflpadkawiltji",
    "email": "muller.tristin@example.com",
    "password": "ullam",
    "role_id": "aperiam"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://booking-com-simulation-laravel.test/api/auth/register',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'vjsoxgflpadkawiltji',
            'email' => 'muller.tristin@example.com',
            'password' => 'ullam',
            'role_id' => 'aperiam',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "access_token": "1|a9ZcYzIrLURVGx6Xe41HKj1CrNsxRxe4pLA2oISo"
}
 

Example response (422):


{
    "message": "The selected role id is invalid.",
    "errors": {
        "role_id": [
            "The selected role id is invalid."
        ]
    }
}
 

Request   

POST api/auth/register

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

name   string   

Must not be greater than 255 characters. Example: vjsoxgflpadkawiltji

email   string   

Must be a valid email address. Must not be greater than 255 characters. Example: muller.tristin@example.com

password   string   

Example: ullam

role_id   string   

Example: aperiam

Owner

Property management

Properties list - **INCOMPLETE**

requires authentication

[List of owners properties]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/owner/properties" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/owner/properties"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/owner/properties',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "success": true
}
 

Request   

GET api/owner/properties

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

Store property

requires authentication

[Stores new property of the owner]

Example request:
curl --request POST \
    "http://booking-com-simulation-laravel.test/api/owner/properties" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"iure\",
    \"city_id\": \"neque\",
    \"address_street\": \"molestiae\",
    \"address_postcode\": \"aut\"
}"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/owner/properties"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "iure",
    "city_id": "neque",
    "address_street": "molestiae",
    "address_postcode": "aut"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://booking-com-simulation-laravel.test/api/owner/properties',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'iure',
            'city_id' => 'neque',
            'address_street' => 'molestiae',
            'address_postcode' => 'aut',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "name": "My property",
    "city_id": 1,
    "address_street": "Street Address 1",
    "address_postcode": "12345",
    "owner_id": 2,
    "updated_at": "2023-05-10T07:07:45.000000Z",
    "created_at": "2023-05-10T07:07:45.000000Z",
    "id": 1,
    "city": {
        "id": 1,
        "country_id": 1,
        "name": "New York",
        "lat": "40.7127760",
        "long": "-74.0059740",
        "created_at": "2023-05-10T07:07:45.000000Z",
        "updated_at": "2023-05-10T07:07:45.000000Z",
        "country": {
            "id": 1,
            "name": "United States",
            "lat": "37.0902400",
            "long": "-95.7128910",
            "created_at": "2023-05-10T07:07:45.000000Z",
            "updated_at": "2023-05-10T07:07:45.000000Z"
        }
    }
}
 

Request   

POST api/owner/properties

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

name   string   

Example: iure

city_id   string   

Example: neque

address_street   string   

Example: molestiae

address_postcode   string   

Example: aut

Property photo management

Add a photo to a property

requires authentication

[Adds a photo to a property and returns the filename, thumbnail and position of the photo]

Example request:
curl --request POST \
    "http://booking-com-simulation-laravel.test/api/owner/properties/10/photos" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "photo=@/private/var/folders/87/191b_my96m7c_w2ljxt2zv_w0000gn/T/php37SoSR" 
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/owner/properties/10/photos"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('photo', document.querySelector('input[name="photo"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://booking-com-simulation-laravel.test/api/owner/properties/10/photos',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'multipart/form-data',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'photo',
                'contents' => fopen('/private/var/folders/87/191b_my96m7c_w2ljxt2zv_w0000gn/T/php37SoSR', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "filename": "http://localhost:8000/storage/properties/1/photos/1/IMG_20190601_123456.jpg",
    "thumbnail": "http://localhost:8000/storage/properties/1/photos/1/conversions/thumbnail.jpg",
    "position": 1
}
 

Example response (422):


{
    "message": "The photo must be an image.",
    "errors": {
        "photo": [
            "The photo must be an image."
        ]
    }
}
 

Request   

POST api/owner/properties/{property_id}/photos

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: multipart/form-data

Accept      

Example: application/json

URL Parameters

property_id   integer   

The ID of the property. Example: 10

Body Parameters

photo   file  optional  

Must be an image. Must not be greater than 5000 kilobytes. Example: /private/var/folders/87/191b_my96m7c_w2ljxt2zv_w0000gn/T/php37SoSR

Reorder photos of a property

requires authentication

[Reorders photos of a property and returns the new position of the photo]

Example request:
curl --request POST \
    "http://booking-com-simulation-laravel.test/api/owner/properties/9/photos/2/reorder/2" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/owner/properties/9/photos/2/reorder/2"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://booking-com-simulation-laravel.test/api/owner/properties/9/photos/2/reorder/2',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "newPosition": 2
}
 

Request   

POST api/owner/properties/{property_id}/photos/{photo_id}/reorder/{newPosition}

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

property_id   integer   

The ID of the property. Example: 9

photo_id   integer   

The ID of the photo. Example: 2

newPosition   integer   

The new position of the photo. Example: 2

Public

[Returns a list of filtered properties]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/search?city=1&country=4&geoobject=1&adults=2&children=1&facilities[]=1&facilities[]=2&facilities[]=3&price_from=100&price_to=200&start_date=2024-01-01&end_date=2024-01-03" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/search"
);

const params = {
    "city": "1",
    "country": "4",
    "geoobject": "1",
    "adults": "2",
    "children": "1",
    "facilities[0]": "1",
    "facilities[1]": "2",
    "facilities[2]": "3",
    "price_from": "100",
    "price_to": "200",
    "start_date": "2024-01-01",
    "end_date": "2024-01-03",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/search',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'city' => '1',
            'country' => '4',
            'geoobject' => '1',
            'adults' => '2',
            'children' => '1',
            'facilities[0]' => '1',
            'facilities[1]' => '2',
            'facilities[2]' => '3',
            'price_from' => '100',
            'price_to' => '200',
            'start_date' => '2024-01-01',
            'end_date' => '2024-01-03',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "properties": {
        "data": [
            {
                "id": 2,
                "name": "Qui velit ea.",
                "address": "2392 Zemlak Port Suite 655, 16225-4383, New York",
                "lat": "-54.8191470",
                "long": "-70.2183380",
                "apartments": [
                    {
                        "name": "Mid size apartment",
                        "type": null,
                        "size": null,
                        "beds_list": "",
                        "bathrooms": 0,
                        "price": 0
                    }
                ],
                "photos": [],
                "avg_rating": 8
            },
            {
                "id": 1,
                "name": "Provident enim est.",
                "address": "1487 Ignacio Alley Suite 794, 74215, New York",
                "lat": "13.2359740",
                "long": "-74.2809120",
                "apartments": [
                    {
                        "name": "Cheap apartment",
                        "type": null,
                        "size": null,
                        "beds_list": "",
                        "bathrooms": 0,
                        "price": 0
                    }
                ],
                "photos": [],
                "avg_rating": 7
            }
        ],
        "links": {
            "first": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
            "last": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
            "prev": null,
            "next": null
        },
        "meta": {
            "current_page": 1,
            "from": 1,
            "last_page": 1,
            "links": [
                {
                    "url": null,
                    "label": "« Previous",
                    "active": false
                },
                {
                    "url": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "Next »",
                    "active": false
                }
            ],
            "path": "http://booking-com-simulation-laravel.test/api/search",
            "per_page": 10,
            "to": 2,
            "total": 2
        }
    },
    "facilities": []
}
 

Property

Property details

[Returns details of a property]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/properties/3" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/properties/3"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/properties/3',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "properties": {
        "data": [
            {
                "id": 1,
                "name": "Aspernatur nostrum.",
                "address": "5716 Leann Point, 24974-6081, New York",
                "lat": "8.8008940",
                "long": "-82.9095500",
                "apartments": [
                    {
                        "name": "Mid size apartment",
                        "type": null,
                        "size": null,
                        "beds_list": "",
                        "bathrooms": 0,
                        "price": 0
                    }
                ],
                "photos": [],
                "avg_rating": null
            }
        ],
        "links": {
            "first": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
            "last": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
            "prev": null,
            "next": null
        },
        "meta": {
            "current_page": 1,
            "from": 1,
            "last_page": 1,
            "links": [
                {
                    "url": null,
                    "label": "« Previous",
                    "active": false
                },
                {
                    "url": "http://booking-com-simulation-laravel.test/api/search?city=1&adults=2&children=1&page=1",
                    "label": "1",
                    "active": true
                },
                {
                    "url": null,
                    "label": "Next »",
                    "active": false
                }
            ],
            "path": "http://booking-com-simulation-laravel.test/api/search",
            "per_page": 10,
            "to": 1,
            "total": 1
        }
    },
    "facilities": []
}
 

Request   

GET api/properties/{property_id}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

property_id   integer   

The ID of the property. Example: 3

Apartments

Get apartment details

[Returns details about a specific apartment]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/apartments/16" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/apartments/16"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/apartments/16',
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "name": "Large apartment",
    "type": null,
    "size": null,
    "beds_list": "",
    "bathrooms": 0,
    "facility_categories": {
        "First category": [
            "First facility",
            "Second facility"
        ],
        "Second category": [
            "Third facility"
        ]
    }
}
 

Request   

GET api/apartments/{apartment_id}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

apartment_id   integer   

The ID of the apartment. Example: 16

User

Bookings

List of user bookings

requires authentication

[Returns preview list of all user bookings]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/user/bookings" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/user/bookings"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/user/bookings',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "id": 1,
    "apartment_name": "Fugiat saepe sed.: Apartment",
    "start_date": "2023-05-11",
    "end_date": "2023-05-12",
    "guests_adults": 1,
    "guests_children": 0,
    "total_price": 0,
    "cancelled_at": null,
    "rating": null,
    "review_comment": null
}
 

Request   

GET api/user/bookings

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

Create new booking

requires authentication

[Creates new booking for authenticated user]

Example request:
curl --request POST \
    "http://booking-com-simulation-laravel.test/api/user/bookings" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"apartment_id\": \"sunt\",
    \"start_date\": \"2023-05-10T11:51:53\",
    \"end_date\": \"2023-05-10T11:51:53\",
    \"guests_adults\": 5,
    \"guests_children\": 7
}"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/user/bookings"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "apartment_id": "sunt",
    "start_date": "2023-05-10T11:51:53",
    "end_date": "2023-05-10T11:51:53",
    "guests_adults": 5,
    "guests_children": 7
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://booking-com-simulation-laravel.test/api/user/bookings',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'apartment_id' => 'sunt',
            'start_date' => '2023-05-10T11:51:53',
            'end_date' => '2023-05-10T11:51:53',
            'guests_adults' => 5,
            'guests_children' => 7,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (201):


{
    "id": 1,
    "apartment_name": "Hic consequatur qui.: Apartment",
    "start_date": "2023-05-11 08:00:51",
    "end_date": "2023-05-12 08:00:51",
    "guests_adults": 2,
    "guests_children": 1,
    "total_price": 0,
    "cancelled_at": null,
    "rating": null,
    "review_comment": null
}
 

Request   

POST api/user/bookings

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

apartment_id   string   

Example: sunt

start_date   string   

Must be a valid date. Example: 2023-05-10T11:51:53

end_date   string   

Must be a valid date. Example: 2023-05-10T11:51:53

guests_adults   integer  optional  

Example: 5

guests_children   integer  optional  

Example: 7

View booking

requires authentication

[Returns details about a booking]

Example request:
curl --request GET \
    --get "http://booking-com-simulation-laravel.test/api/user/bookings/8" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/user/bookings/8"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
    'http://booking-com-simulation-laravel.test/api/user/bookings/8',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "id": 1,
    "apartment_name": "Hic consequatur qui.: Apartment",
    "start_date": "2023-05-11 08:00:51",
    "end_date": "2023-05-12 08:00:51",
    "guests_adults": 2,
    "guests_children": 1,
    "total_price": 0,
    "cancelled_at": null,
    "rating": null,
    "review_comment": null
}
 

Request   

GET api/user/bookings/{id}

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the booking. Example: 8

Update existing booking rating

requires authentication

[Updates booking with new details]

Example request:
curl --request PUT \
    "http://booking-com-simulation-laravel.test/api/user/bookings/16" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"rating\": 1,
    \"review_comment\": \"ssccvjhgbcmqkhmkpfqnbsqgprxyglhjrezjtayzubihntqqaqcetyntvvrnbytty\"
}"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/user/bookings/16"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "rating": 1,
    "review_comment": "ssccvjhgbcmqkhmkpfqnbsqgprxyglhjrezjtayzubihntqqaqcetyntvvrnbytty"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->put(
    'http://booking-com-simulation-laravel.test/api/user/bookings/16',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'rating' => 1,
            'review_comment' => 'ssccvjhgbcmqkhmkpfqnbsqgprxyglhjrezjtayzubihntqqaqcetyntvvrnbytty',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{
    "id": 1,
    "apartment_name": "Hic consequatur qui.: Apartment",
    "start_date": "2023-05-11 08:00:51",
    "end_date": "2023-05-12 08:00:51",
    "guests_adults": 2,
    "guests_children": 1,
    "total_price": 0,
    "cancelled_at": null,
    "rating": null,
    "review_comment": null
}
 

Request   

PUT api/user/bookings/{id}

PATCH api/user/bookings/{id}

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the booking. Example: 16

Body Parameters

rating   integer  optional  

Must be between 1 and 10. Example: 1

review_comment   string  optional  

Must be at least 20 characters. Example: ssccvjhgbcmqkhmkpfqnbsqgprxyglhjrezjtayzubihntqqaqcetyntvvrnbytty

Delete booking

requires authentication

[Deletes a booking]

Example request:
curl --request DELETE \
    "http://booking-com-simulation-laravel.test/api/user/bookings/9" \
    --header "X-XSRF-TOKEN: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://booking-com-simulation-laravel.test/api/user/bookings/9"
);

const headers = {
    "X-XSRF-TOKEN": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->delete(
    'http://booking-com-simulation-laravel.test/api/user/bookings/9',
    [
        'headers' => [
            'X-XSRF-TOKEN' => '{YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));

Example response (200):


{}
 

Request   

DELETE api/user/bookings/{id}

Headers

X-XSRF-TOKEN      

Example: {YOUR_AUTH_KEY}

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the booking. Example: 9