Dynamic Filters and Filtering
Contents
Dynamic Filters
The GetHotelResponse and GetFlightsResponse will contain an element called filters, this element is a list of the filter elements that represent dynamic filters calculated for the specific request, these filters are calculated using the data from the response.
Example:
<GetHotelsResponse xmlns="http://www.travelfusion.com/xml/api/simple" sid="YYAjfEYeyF3bsEcI">
...
<filters>
<filter code="hotelId" type="string"></filter>
<filter code="hotelCode" type="string"></filter>
<filter code="starsMin" type="number" min="3" max="5">
<value selected="false" count="53">3</value>
<value selected="false" count="18">5</value>
<value selected="true" count="78">4</value>
</filter>
<!-- DEPRECATED - Please use starsMin, as above, instead -->
<filter code="stars" type="enumeration">
<value selected="true" count="53">3</value>
<value selected="true" count="18">5</value>
<value selected="true" count="78">4</value>
</filter>
<filter code="priceMin" type="number" min="40.56" max="1459.82" currency="GBP"></filter>
<filter code="tripadvisorRatingMin" type="number" min="2.5" max="4.5"></filter>
<filter code="supplier" type="enumeration">
<value selected="false" count="224">bookingdotcom</value>
<value selected="false" count="540">laterooms</value>
<value selected="false" count="92">sunhotels</value>
<value selected="false" count="1124">expediahotels</value>
<value selected="false" count="161">venere</value>
</filter>
<filter code="tfRoomType" type="enumeration">
<value selected="false" count="428">Twin</value>
<value selected="false" count="729">Double</value>
<value selected="false" count="6">Apartment</value>
<value selected="false" count="13">Quad</value>
<value selected="false" count="443">Unknown</value>
<value selected="false" count="56">Family</value>
<value selected="false" count="96">Triple</value>
<value selected="false" count="370">Single</value>
</filter>
<filter code="hotelName" type="string"></filter>
<filter code="priceMax" type="number" min="40.56" max="1459.82" currency="GBP"></filter>
<filter code="facility" type="enumeration">
<value selected="false" count="94">INTERNET</value>
<value selected="false" count="5">BREAKFAST</value>
<value selected="false" count="23">MEETING_FACILITY</value>
<value selected="false" count="124">AIR_CONDITIONING</value>
<value selected="false" count="16">PARKING</value>
<value selected="false" count="11">PETS_PERMITTED</value>
<value selected="false" count="11">POOL</value>
<value selected="false" count="15">WHEEL_CHAIR</value>
<value selected="false" count="72">LIFT</value>
<value selected="false" count="17">ROOM_SERVICE</value>
<value selected="false" count="52">BAR</value>
<value selected="false" count="48">RESTAURANT</value>
</filter>
<filter code="tripadvisorRatingMax" type="number" min="2.5" max="4.5"></filter>
</filters>
...
</GetHotelsResponse>
a dynamic filter contains the following attributes:
code: Identifier of the filter.
type: Indicates the type of information that this filter handles, the available types are:
number: the recommended representation is a slider, the number filters contains two more attributes (max, min) to indicate the maximum and minimum value of the slider. When a value is already selected the element contains an additional attribute (selectedValues) to indicate it.
enumeration: the recommended representation is a checkbox per value. Each value has the following attributes:
selected: indicates if this value is selected.
count: the number of occurrences of this filter value in the searched data.
displayName: the Travelfusion suggested display name for the value.
string: the recommended representation is a text box, when a value has already been entered, the element contains an additional attribute (selectedValues) to indicate it.
(max): optional, explained previously.
(min): optional, explained previously.
(selectedValues): optional, explained previously.
(currency): optional, this attribute appears in the filters that include prices, to indicate the currency of the price. To obtain the prices dynamic filters in an specific currency, the currency element must be submitted on its request.
IMPORTANT: It is important that the client is able to handle dynamic filters automatically. Ideally displaying them all to the user generically such that if a new filter is added, it will automatically be shown. However if some development work is needed for each filter (such as translation), then it is important to at least detect the presence of a new filter and alert your team to it, so that the relevant work can be done and it can be utilised in your UI.
Travelfusion reserves it rights to include new filters or remove them from the API responses without previous notice.
Filtering
Various filters can be applied to the results, of a GetHotelRequest or GetFlightsRequest, by submitting the filters element with a list of filter elements as below. The various available filters are returned as dynamic filters in the responses, so that they can be generically extracted and displayed to the user. Multiple filters of the same type can be submitted - e.g. to receive offers for different product types (plane and train).
Flight example:
<GetFlightsRequest xmlns="http://www.travelfusion.com/xml/api/simple" token="{VALID_TOKEN}" sid="{VALID_SID}">
<filters>
<filter code="supplier">britishairways</filter>
</filters>
</GetFlightsRequest>
Hotel example:
<GetHotelsRequest xmlns="http://www.travelfusion.com/xml/api/simple" token="{VALID_TOKEN}" sid="{VALID_SID}">
<filters>
<filter code="priceMin" currency="GBP">50.6</filter>
<filter code="facility">AIR_CONDITIONING</filter>
<filter code="facility">INTERNET</filter>
<filter code="starsMin">4</filter>
</filters>
</GetHotelsRequest>
a filter contain the following attributes:
code: Identifier of the filter, should be the same as the dynamic filter
(currency): optional, must be submitted for price filters