Restful-Booker API Documentation
Prepared by:
Md. Ebrahim Hossain
SQA Engineer at Achieve Test Prep (Newark, US)
Former SQA Engineer at ZS Solutions Ltd (BD)
Base URL
The primary endpoint for all API calls is:
https://restful-booker.herokuapp.com
Booking Endpoints
Booking – Create Booking
POST
/booking/
Request Body (JSON Example)
# Command line example: curl -X POST https://restful-booker.herokuapp.com/booking \ -H 'Content-Type: application/json' \ -d '{ "firstname" : "Jim", "lastname" : "Brown", "totalprice" : 111, "depositpaid" : true, "bookingdates" : { "checkin" : "2018-01-01", "checkout" : "2019-01-01" }, "additionalneeds" : "Breakfast" }'
Response (200 OK)
HTTP/1.1 200 OK { "bookingid": 1, "booking": { "firstname": "Jim", "lastname": "Brown", "totalprice": 111, "depositpaid": true, "bookingdates": { "checkin": "2018-01-01", "checkout": "2019-01-01" }, "additionalneeds": "Breakfast" } }
Booking – Get Booking
GET
/booking/{id}
Request
# Example Request (Replace {id} with a valid booking ID)
GET /booking/123 HTTP/1.1
Host: restful-booker.herokuapp.com
Response (200 OK)
HTTP/1.1 200 OK { "firstname": "Sally", "lastname": "Brown", "totalprice": 111, "depositpaid": true, "bookingdates": { "checkin": "2013-02-23", "checkout": "2014-10-23" }, "additionalneeds": "Breakfast" }
Auth – Create Token
POST
/auth
Request Body (Credentials)
{
"username": "admin",
"password": "password123"
}
Response (200 OK)
HTTP/1.1 200 OK { "token": "abc123" }
Booking – Update Booking
PUT
/booking/{id}
Required Headers & Request Body
# Header: Authentication via Cookie -H 'Cookie: token=abc123' # Request Body (Full booking object required) -d '{ "firstname" : "James", "lastname" : "Brown", "totalprice" : 111, "depositpaid" : true, "bookingdates" : { "checkin" : "2018-01-01", "checkout" : "2019-01-01" }, "additionalneeds" : "Breakfast" }'
Expected Response (200 OK)
The response body is the updated booking object, similar to the GET response.
HTTP/1.1 200 OK { "firstname": "James", "lastname": "Brown", "totalprice": 111, ... }
Booking – Delete Booking
DELETE
/booking/{id}
Required Headers
Authentication token is required to authorize the deletion.
# Authentication Header -H 'Cookie: token=abc123'
Expected Response
HTTP/1.1 201 Created (Success) # No Content body is usually returned for a successful DELETE