Accommodation
A Quick Start
There are basically five steps to booking a hotel, but before you start you must get a API Token to use.
export XENI_TOKEN=$(curl -X 'POST' $XENI_API_HOST/api/accounts/get_token \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{"user":{"email": "'"$XENI_USER_EMAIL"'", "password": "'"$XENI_USER_PASSWORD"'"}}' \
| sed "s/{.*\"token\":\"\([^\"]*\).*}/\1/g")
For testing your code it's a good idea to use our simulated repsonses, to do so use the following header:
Searching for a Location
To do an availability search for hotels you will need a location as a start point of where the traveler is looking for accomodations. Use the following API to offer the client a drop down/autocomplete of locations from which you get and can search by the location's id. It needs three or more characters to return a result.
# an alternative to "python -m json.tool" is "json_pp -json_opt pretty,canonical"
curl -X 'GET' \
"$XENI_API_HOST/api/locations/search?starts_with=New%20York" \
-H "accept: application/json" \
-H "authorization: bearer: $XENI_TOKEN" \
| python -m json.tool
{
"data": [
{
"id": "bbc35c49-d2a7-431a-ac40-a4944c3a00e7",
"name": "New York, New York, United States of America",
"type": "city"
},
{
"id": "fda1a5e6-bf14-4caa-99b4-6d896650a047",
"name": "New York, NY (JRA-West 30th Street Heliport), New York, New York, United States of America",
"type": "airport"
},
{
"id": "6b24a5dc-9fde-4770-ac55-ecc86882478a",
"name": "New York, NY (JRE-East 60th Street Heliport), New York, New York, United States of America",
"type": "airport"
},
{
"id": "e35fc3ba-c39a-413d-8a92-ff53e3d9ab63",
"name": "New York, NY (TSS-East 34th Street Heliport), New York, New York, United States of America",
"type": "airport"
}
]
}
Searching for Availability
Once you have a location to search against, for availability you need to provide at a minimum the following pieces of information:
location id
-"bbc35c49-d2a7-431a-ac40-a4944c3a00e7"
check in date
-"2023-10-31"
check out date
-"2023-11-10"
- An array of occupancies -
For more options see the API docs
curl -X 'POST' \
"$XENI_API_HOST/api/accommodation_searches/search" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "authorization: bearer: $XENI_TOKEN" \
-d '{
"customer_ip": "127.0.0.1",
"check_in": "2023-08-27",
"check_out": "2023-08-30",
"destination_id": "2742111a-3a8f-467b-aede-c454d796b86f",
"occupancies": [
{
"adults": 2,
"children_ages": [
10,
2
]
},
{
"adults": 2
}
]
}'
{
"data": {
"availability": [
{
"bye_line": "Near Times Square",
"category": "Hotel",
"chain": "Hilton Worldwide",
"description": "With a stay at Hilton New York Times Square, you'll be centrally located in New York, steps from Madame Tussauds Wax Museum and Broadway. This 4-star hotel is 0.1 mi (0.2 km) from Times Square and 0.6 mi (1 km) from Rockefeller Center.",
"guest_ratings": {
"amenities": 4.1,
"cleanliness": 4.4,
"comfort": 4.3,
"condition": 4.3,
"count": 779,
"overall": 4.2,
"service": 4.2
},
"hero_images": {
"hi": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_z.jpg",
"lo": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_t.jpg",
"med": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_b.jpg"
},
"images": [
{
"caption": "Primary image",
"images": {
"hi": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_z.jpg",
"lo": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_t.jpg",
"med": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/134d2636_b.jpg"
}
},
{
"caption": "Lobby",
"images": {
"hi": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/6c479d39_z.jpg",
"lo": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/6c479d39_t.jpg",
"med": "https://i.travelapi.com/lodging/1000000/430000/423400/423330/6c479d39_b.jpg"
}
}
],
"location": {
"lat": 40.756413,
"lon": -73.98796
},
"name": "Hilton New York Times Square",
"popular_amenities": [
"Restaurant",
"Gym",
"Parking",
"WiFi included"
],
"property_id": "423330",
"public_price": 1764.09,
"review_count": 779.0,
"session_id": null,
"star_rating": 4.0,
"total_price": 1764.09,
"vendor_id": "exepdia",
"vendors_property_id": "423330"
}
],
"search_id": "2a9ee8d4-082c-4931-ace4-5af31b34425e"
}
}
The API returns a summary list of accomodations with enough information to build a search results page. For the Epedia raw data see: Expedia API Docs
This will return a saved search result for availabilty of hotels in New York.
Fetching the Details of a Hotel
To search for an individual hotel availability you need at a minimum the following pieces of information:
search_id
- "962c9315-0e35-45e3-b158-be10c860912d"property_id
- "40553"optionally
a raw flag - true
For more options see the API docs
curl -X 'GET' \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "authorization: bearer: $XENI_TOKEN" \
-H "x-simulate-return: success" \
"$XENI_API_HOST/api/accommodation_searches/accommodation?search_id=962c9315-0e35-45e3-b158-be10c860912d&property_id=40553"
The result contains an overview object to render:
Use the array of room records to build the room choice tab
Booking a Room
In the room record is the room_booking_info
field that you will use in the booking API. The nature of this field can change, vendor by vendor, so deal with it in an abstract way.
curl -X 'POST' \
"$XENI_API_HOST/api/accommodation/book" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "authorization: bearer: $XENI_TOKEN" \
-d '{
"bed_id": "37481",
"price_check_uri": "/v3/properties/40553/rooms/211509376/rates/386134995?token=F~Oj46Zzw3JDE9ZnFgHjNVCxUwZlAybDEDbFQJCwYZUghLAlZxPwtUUQdJCFUZVgF8OjBmIDY0UjsVW1ZXUAMHCgUbAQcAVx0BBFpQSFUGVAYVVwJWVlwGVlpSUwUFWmAOAVQAAw4TN1YIBFUbNQi4YDhWp2Q0BA5RC1KpNz9UEy9QWFcTclBXF5U5STlPQ0RKSQQbC0BzCFYGdwRWFkpBQVxPV0dcFyldWwYTShZCQVMPRFgWGxRYUUxp0GQzBwfzMj9TD1cHCRZSDNkyNY40PckxY706MKNhNawyZZI2ZJlnRgBUA1YDAgBaTgIBVgdODAABVRoKDVNXS1ddV1VeAVBSVgFTBodhKVQBVAcUVAVMA1JsVA4MDAYIUVpMBQFWBVMBUg0Fatg3Y04KgZ-TCw=="
}'
Data Examples
An example of availability and details for an accomodation | |
---|---|
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|