BTU.JS is a javascript library that interacts with BTU Protocol. It allows any developer to build a booking application or a widget.
This is the documentation for the hotels module. Click here to go back to the global documentation.
npm install btujs --save
const btujs = require('btujs');
const myBtujs = new btujs();
Search for hotels. There are three possible ways of searching for a hotel depending on the searchType parameter :
-
'query' search that returns a list of cities and hotels corresponding to the query given in parameter. (Useful for a search bar)
-
'location' search that returns a list of hotel for a certain location (coordinates) and guest related parameters.
-
'cities' search that returns a list of hotel for an array of coordinates (Usefull for city samples).
myBtujs.resources.searchResources(String resourceType, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
body:
-
Query
parameter mandatory description searchType true
String
type of search ('query')options.searchQuery true
String
name you want to lookup -
Location
parameter mandatory description searchType true
String
type of search ('location')startDate true
String
start of trip ('YYYY-MM-DD')endDate true
String
end of trip ('YYYY-MM-DD')guest true
Integer
number of guestsoptions.location.longitude true
Float
longitude of center of look-up zoneoptions.location.latitude true
Float
latitude of center of look-up zoneoptions.countryCode false
String
use this to limit results to a certain country ¹options.byDistance false
Boolean
sort by distance (closest first)options.byParking false
Boolean
filter out results without free or paying parkingoptions.byBreakfast false
Boolean
filter out results without a breakfast optionoptions.byMaxStars false
Integer
filter out results with a superior star numberoptions.byMaxDistance false
Integer
filter out results further from distanceoptions.byMaxPrice false
Float
filter out results more expensive than valuepageSize false
Integer
number of elements per page (default 100)¹ Case non sensitive two character string (ex. "FR", "UK"...), can be obtained from the query search. -
Cities
parameter mandatory description searchType true
String
type of search ('location')options.coordArray true
Array
coordinates for finding near-by hotelsoptions.coordArray[].lat true
Float
latitude of pointoptions.coordArray[].lon true
Float
longitude of point
-
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.resources.searchResources('hotel', body).then(res => {...})
-
Query
{ places: [ place_object place_object ... ], hotels: [ hotel_object hotel_object ... ] }
-
Location
{ nbFound: 179, currentPage: 1, totalPages: 1, hotels: [ hotel_object hotel_object ... ] }
-
Cities
{ // The array's first dimension represents the different points asked (same order) // The second is a list of hotel near this point (max ~10km) [ [ hotel_object, hotel_object, ... ], [ hotel_object, hotel_object, ... ], ... ] }
Query resource by its ID to get its details.
myBtujs.resources.getResource(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
resourceId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.resources.getResource('hotel', 'XP23AB2', body).then(res => {...})
hotelDesc_object //The requested hotel
Query a resource by its ID and get its availabilities.
myBtujs.availabilities.getResourceAvailabilities(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description startDate true
String
start of trip ('YYYY-MM-DD')endDate true
String
end of trip ('YYYY-MM-DD')guest true
Integer
number of guests -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.getResourceAvailabilities('hotel', '45327394', body).then(res => {...})
{
count: 20,
rooms: [
room_object,
room_object
...
]
}
Check if a resource is available under different conditions.
myBtujs.availabilities.isResourceAvailable(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description startDate true
String
start of trip ('YYYY-MM-DD')endDate true
String
end of trip ('YYYY-MM-DD')guest true
Integer
number of guestsroomCode true
String
room code (can be found from getAvailibilities) -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.isResourceAvailabilities('hotel', '45327394', body).then(res => {...})
{
isAvailable: true // or false
}
Book a resource availability.
myBtujs.availabilities.bookResource(String resourceType, String resourceId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
resourceId: resource unique identifier.
-
body:
parameter mandatory description roomCode true
[String]
room(s) identity code(s)rateCode true
[String]
rate(s) chosenamountTax true
[String]
price(s) of chosen room(s)fromDate true
String
day of arrival (YYYY-MM-DD)endDate true
String
day of departure (YYYY-MM-DD)cardCode true
String
card codecardNumber true
String
card numberexpireDate true
String
card expire datecvv true
String
card security codenameCard true
String
name of card ownerchainCode true
String
hotel chain codehotelCode true
String
hotel coderoomQuantities true
Integer
room quantitiesnumberGuest true
Integer
number of guestslastName true
[String]
lastnames of guests per roomfirstName true
[String]
firstnames of guests per roomphoneNumber true
[String]
phone Nb. of guests per roomemail true
[String]
email of guests per room -
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.bookResource('hotel', '45327394', body).then(res => {...})
Get informations about a booking you made.
myBtujs.availabilities.getBookingDetails(String resourceType, String bookingId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
bookingId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.getBookingDetails('hotel', '45327394', body).then(res => {...})
Cancel a reservation you booked through the bookResource method.
myBtujs.availabilities.cancelBooking(String resourceType, String bookingId, Object body, Function callback)
-
resourceType: the type of resource you are looking for, here you will pass 'hotel'.
-
bookingId: resource unique identifier.
-
body: none.
-
callback: standard callback function, e.g.
callback(err, res) { ... }
.If not given, the function will create a promise.
let body = { ... }
BtuJs.availabilities.cancelBooking('hotel', '45327394', body).then(res => {...})
field | description |
---|---|
id | Integer hotel id |
code | String hotel code |
name | String hotel name |
image | String hotel main image url |
stars | Integer hotel stars count |
latitude | String hotel position latitude |
longitude | String hotel position longitude |
minRate | String hotel minimum rate |
details | String hotel amenities |
rooms | [room_object] hotel available rooms |
field | description |
---|---|
country | String country name of proposition |
countryCode | String country short code |
defaultName | String name found for query |
region | String region name of proposition |
location.lat | Float latitude of proposition |
location.lon | Float longitude of proposition |
field | description |
---|---|
name | String name of hotel |
hotelCode | String hotel code |
address | String hotel address |
city | String hotel city's name |
zipCode | String hotel zip code |
phone | String hotel phone number |
String hotel mail contact |
|
starRating | Integer number of stars |
countryCode | String country short code |
countryName | String country name |
chainName | String name of hotel chain |
defaultImage | String default image url |
images | [String] other image's urls |
frDesc | String French description |
enDesc | String English description |
location.latitude | Float coordinate of hotel |
location.longitude | Float coordinate of hotel |
services | Object list of services (see below) |
services[].en | String name of service in English |
services[].fr | String name of service in French |
field | description |
---|---|
roomCode | String room code (for booking) |
maxOccupancy | Integer room's max occupancy |
rateQuantity | Integer quantity of this rate |
rateCode | String rate's code |
ratePrice | Float price for this rate |
taxPrice | Float tax price |
rateMealPrice | Float breakfast price |
roomPrice | Float price of this room |
currencyCode | String currency code |
rateName | String name of this rate |
rateInformations | [String] informations about this rate |
features | [String] rate's features |
cancelPenalty | [String] cancel penalties informations |
hasBreakFastInc | Boolean is breakfast included |
hasLunchInc | Boolean is lunch included |
hasDinnerInc | Boolean is dinner included |
rateTax | Float tax for this rate |
rateCancelPolicy | String rate's cancelling policy |
isNegotiatedRate | Boolean is this rate negotiated |
isCreditCardNeeded | Boolean is your credit card needed |
isCancellable | Boolean is this rate cancellable |
isTaxIncluded | Boolean is the tax included in price |