Rooms Associated With A Host

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.

Endpoint

Method URI Headers
GET /api/rooms Authorization: Bearer <token>
Accept: application/json

URL Params

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)

Data Params

None
1

Request & Response Examples

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.

Successful Response

200

Example request

curl \
  --request GET \
  --url 'https://api.luxstay.com/api/rooms' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'
1
2
3
4
5

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  • Limit the number of rooms per page.

Example request

curl \
  --request GET \
  --url 'https://api.luxstay.com/api/rooms?limit=2' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <token>'
1
2
3
4
5

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  • You can optionally filter rooms by their current status. In order to do that your can use 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>'
1
2
3
4
5
6
7
8
9
10
11

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  • To find a specific room, you can use 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>'
1
2
3
4
5

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": []
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  • You can optionally filter rooms by their current submit status. In order to do that your can use 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>'
1
2
3
4
5
6
7
8
9
10
11

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  • You can search for rooms by their name, description and addresses by providing 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>'
1
2
3
4
5

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  • By default, rooms are sorted by ID attribute in the descending order. You can override that using 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>'
1
2
3
4
5

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"
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

Error Response

401

Reason invalid access token

Example response

{
    "message": "Unauthenticated."
}
1
2
3

422

Reason validation errors

Example response

{
    "message": "The given data was invalid.",
    "errors": {
        "ordering": [
            "The selected ordering is invalid."
        ]
    }
}
1
2
3
4
5
6
7
8
{
    "message": "The given data was invalid.",
    "errors": {
        "room_id": [
            "The room id must be an integer."
        ]
    }
}
1
2
3
4
5
6
7
8
{
    "message": "The given data was invalid.",
    "errors": {
        "status": [
            "The selected status is invalid."
        ]
    }
}
1
2
3
4
5
6
7
8
Last Updated: 11/18/2018, 9:11:26 AM