WuBook Fount Price and Availability

How does it work?

WuBook Fount allows you to query WuBook servers in order to gain access to prices and availabilities of our properties. You must specify a filter, identifying a set or properties to be queried and a range of dates. The filter is usually a property code or a list of property codes.

Response Anatomy

The response of those POSTs are always the same: a JSON encoded structure like this one:

{
  "warnings": "",
  "results": PricesAndAvailability,
  "error": ""
}

The warnings and error values are easy to understand. The results object is not difficult, but requires few lines. First of all, it’s an object: the keys of the objects are the property identifier codes. The values of the objects are simple structures, containing a key/value set where key IS occupancy and value IS average price.

Depending on your query parameters, the PricesAndAvailability object can change. WuBook is able to return you two types of results: Compact or Exploded.

This is an example for Compact Result:
 
{123: {1: 10, 2: 20}}

and means that, for the required dates, the property 123 has a single room and a double room available and the average prices of the rooms are 10 and 20.

So, Compact Result is:
 
{lcode1: {occupancy1: averagePrice1, ...., occupancyN: averagePriceN}}
This is an example of Exploded Result:
 
{123: {1: {100: 10, 101: 12}, 2: {300: 20}}

Which is way more detailed.

We also return the IDs of the available rooms. The previous data means that the property 123 has two single rooms available (with id= 100 and id= 101). For every single room, the average price is returned (10, 12). In the same way, the property 123 has 1 double room availabile (with id= 300) and its average price, for the selected dates, is 20.

If you want details about rooms, accessing names and descriptions, you can use the WuBook Fount Rooms feature.

Now that the results have been explained, let’s describe how you have to POST.

Server2Server profile

Just issue a POST to the following url. You must post a unique parameter: params. The content of this parameter is a JSON encoded structure.

  • A property filter, allowing you to select the properties you want to check
  • dfrom: arrival date
  • dto: departure date
  • origin: for Fount Partners. Fount partners should always specify their origin code. Optional, default value= None
  • compact: 0 (zero) or 1 (one). This allows you to have a Compact or an Exploded return, as previously explained. Optional, default val= 1

About Origin: some property can be available. However, they can disable the reselling activities on your site and, if you specify your origin code, we will consider their preferences.

For example, if a property has disabled the resellting activity for your Site and you specify your origin code, we will return availability= 0. That’s because the hotelier does not want to sell his rooms on your site and, so, he will not pay relative commissions. If you don’t use your origin code, you can produce reservations for hotelier that will not pay fees.

The property filter can be different, depending on your needs. Let’s list the possible filters you can use:

Property filter: an explicit list of properties.

Just use an array of property codes, like this:
 
var params= {lcodes: [123], dfrom: '21/12/2020', dto: '22/12/2020'};
var params= JSON.stringify(params);
$.post('https://wubook.net/wbkd/fount/json', {params: params}, function(data) {console.log(data)});

Warning

The previous example works in javascript only under the wubook.net domain!

You can use another language from your server. An example in python can be:

>>> import urllib, urllib2
>>> d= {'dfrom': '21/12/2020', 'dto': '22/12/2020', 'lcodes': [123]}
>>> q= urllib.urlencode({'params': json.dumps(d)})
>>> urllib2.urlopen('https://wubook.net/wbkd/fount/json', q).read()

Same example in PHP:

<?php
$data = array('lcodes' => array(123), 'dfrom' => '21/12/2020', 'dto' => '22/12/2020');
$data_string = json_encode($data, JSON_UNESCAPED_SLASHES); /* Maybe you need to remove the JSON_UNESCAPED_SLASHES, depending on the PHP version you are using */
$data_string = 'params=' . urlencode($data_string);
$ch = curl_init('https://wubook.net/wbkd/fount/json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('multipart/form-data', 'Content-Length: ' . strlen($data_string)));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>

Property filter: Eurota Just specify your Eurota identifier:

var params= {eurota: 'abc', dfrom: '21/12/2020', dto: '22/12/2020'};
var params= JSON.stringify(params);
$.post('https://wubook.net/wbkd/fount/json', {params: params}, function(data) {console.log(data)});

WuBook Javascript Library

If you use WuBook Fount for a unique property, you can be interested on the method: WuBook.fount(). This is just a reminder. Check the full documentation at Online Reception: WuBook’s Javascript Library.

The method accepts 2 parameters: params and cback. The first one contains a simple struct: {dfrom: ‘21/12/2021’, dto: ‘22/12/2021’}, while the second one is a simple callback.

Example:
var params= {dfrom: '21/12/2020', dto: '22/12/2020'};
WuBook= new _WuBook(123);
WuBook.fount(params, function(data) {console.log(data)});

Good luck and good job!