This endpoint is used to retrieve all the rooms associated with a given host. We may perform a lot of fitlers when fetching those rooms. By default, this endpoint just returns basic information of the room. To retrieve more information, we have to make another API call. The list of room will be paginated.
Method | URI | Headers |
---|---|---|
GET | /api/rooms | Authorization: Bearer <token> Accept: application/json |
Param | Description | Type | Required | Notes |
---|---|---|---|---|
limit | The number of rooms for one page. | Integer | No | Minimum value is 1. Default value is PAGINATION_PER_PAGE |
status | The status of the rooms. | String | No | One of Listed and Unlisted |
room_id | The ID of a specific room. | Integer | No | - |
submit_status | The submit status of the rooms. | String | No | One of Draft, Pending, Accept, Reject and Resubmit |
search | The search pattern. | String | No | Searching process is performed on properties of the rooms such as their name, description and addresses. Minimum length: 3 Maximum length: MAX_STRING_LENGTH |
sort | The attribute of the room used for sorting the results. | String | No | Default to sorting by ID of rooms. However, sorting by status and name are also supported |
ordering | The order of the collection of rooms. | String | No | Default to descending order - DESC. Available order are ASC and DESC (case-insensitive) |
None
You can apply different query string parameters to control the returned list of rooms. You can combine multiple filtering options together to customize the result. We're going to demonstrate all the cases in the examples below.
Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10001,
"name": "Apartment 1",
"num_bedrooms": 3,
"num_bathrooms": 4,
"standard_guests": 3,
"maximum_guests": 5,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10002,
"name": "Apartment 2",
"num_bedrooms": 3,
"num_bathrooms": 4,
"standard_guests": 5,
"maximum_guests": 15,
"status": "Listed",
"submit_status": "Reject"
},
{
"id": 10003,
"name": "Apartment 3",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 4,
"status": "Unlisted",
"submit_status": "Accept"
},
{
"id": 10004,
"name": "Apartment 4",
"num_bedrooms": 3,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 4,
"status": "Listed",
"submit_status": "Accept"
},
...
],
"meta": {
"pagination": {
"total": 231,
"count": 15,
"per_page": 15,
"current_page": 1,
"total_pages": 16,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=2' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10001,
"name": "Apartment 1",
"num_bedrooms": 3,
"num_bathrooms": 4,
"standard_guests": 3,
"maximum_guests": 5,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10003,
"name": "Apartment 2",
"num_bedrooms": 3,
"num_bathrooms": 4,
"standard_guests": 5,
"maximum_guests": 15,
"status": "Listed",
"submit_status": "Accept"
}
],
"meta": {
"pagination": {
"total": 231,
"count": 2,
"per_page": 2,
"current_page": 1,
"total_pages": 116,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
status
query string parameter. Allowed statuses are Listed and Unlisted.Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=2&status=Listed' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=2&status=Unlisted' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10015,
"name": "Apartment 5",
"num_bedrooms": 0,
"num_bathrooms": 2,
"standard_guests": 0,
"maximum_guests": 1,
"status": "Unlisted",
"submit_status": "Accept"
},
{
"id": 10016,
"name": "Apartment 6",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 3,
"maximum_guests": 12,
"status": "Unlisted",
"submit_status": "Pending"
}
],
"meta": {
"pagination": {
"total": 15,
"count": 2,
"per_page": 2,
"current_page": 1,
"total_pages": 8,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
room_id
query string parameter.Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?room_id=10140' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10140,
"name": "Apartment 100",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 3,
"status": "Listed",
"submit_status": "Accept"
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 15,
"current_page": 1,
"total_pages": 1,
"links": []
}
}
}
submit_status
query string parameter.
Allowed statuses are Draft, Pending, Accept, Reject and Resubmit.Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=2&submit_status=Accept' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=2&submit_status=Pending' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10100,
"name": "Apartment 20",
"num_bedrooms": 2,
"num_bathrooms": 4,
"standard_guests": 5,
"maximum_guests": 10,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10101,
"name": "Apartment 21",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 4,
"status": "Listed",
"submit_status": "Accept"
}
],
"meta": {
"pagination": {
"total": 115,
"count": 2,
"per_page": 2,
"current_page": 1,
"total_pages": 58,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
search
query string parameter.Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?search=awesome' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10102,
"name": "Awesome Apartment 22",
"num_bedrooms": 2,
"num_bathrooms": 4,
"standard_guests": 5,
"maximum_guests": 5,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10103,
"name": "Apartment awesome 23",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 4,
"status": "Listed",
"submit_status": "Accept"
}
],
"meta": {
"pagination": {
"total": 115,
"count": 2,
"per_page": 2,
"current_page": 1,
"total_pages": 58,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
sort
and ordering
query string parameters.Example request
curl \
--request GET \
--url 'https://api.luxstay.com/api/rooms?limit=3&sort=name&ordering=asc' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>'
Example response
{
"data": [
{
"id": 10629,
"name": "XYZ",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 2,
"maximum_guests": 4,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10305,
"name": "DEF",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 6,
"maximum_guests": 15,
"status": "Listed",
"submit_status": "Accept"
},
{
"id": 10468,
"name": "ABC",
"num_bedrooms": 2,
"num_bathrooms": 2,
"standard_guests": 42,
"maximum_guests": 3,
"status": "Listed",
"submit_status": "Accept"
}
],
"meta": {
"pagination": {
"total": 125,
"count": 3,
"per_page": 3,
"current_page": 1,
"total_pages": 42,
"links": {
"next": "https://api.luxstay.com/api/rooms?page=2"
}
}
}
}
Reason invalid access token
Example response
{
"message": "Unauthenticated."
}
Reason validation errors
Example response
{
"message": "The given data was invalid.",
"errors": {
"ordering": [
"The selected ordering is invalid."
]
}
}
{
"message": "The given data was invalid.",
"errors": {
"room_id": [
"The room id must be an integer."
]
}
}
{
"message": "The given data was invalid.",
"errors": {
"status": [
"The selected status is invalid."
]
}
}