Recommendations Guide
Table of Contents
Introduction
Each search-endpoint that takes in any kind of information about geography, has the option to supply recommendations.
Recommendations groups offers based on certain attributes, matching the specified recommendationConfig
object of the request.
This can be a particularly useful feature if you are looking for a specific type of offer, but are not sure which one to choose.
It also includes for which travellers and what part of the journey/area the recommendation is valid for.
Grouping configuration
Each recommendation is categorized by different attributes. The client may provide which attributes they would like to group the recommendations by. Note that each offer may be recommended in more than one combination of grouping attributes.
Attributes for recommendations are divided into flexibility, duration type, fare class and facility set, and are specified in the categorySpec
part of the recommendationConfig
.
Flexibility
- how flexible the offer is in terms of exchangeability and refundability. This is requested by thetypesOfRecommendation
array, where the last optionCHEAPEST
ignores the flexibility but selects the cheapest offer that fits the other requested attributes.NON_FLEXIBLE
no refund or exchange optionsSEMI_FLEXIBLE
can refund or exchange but not bothFLEXIBLE
both refundable and exchangeable
DurationType
- the duration of the period ticket the offers describes. The most typical values are:SINGLE_TRIP
valid for one tripDAY_PASS
valid for a dayWEEKLY_PASS
valid for a weekMONTHLY_PASS
valid for a monthSEASON_TICKET
valid for a season or a yearCARNET
valid for a number of trips
FareClass
- the class of the product offered. i.e.PREMIUM_CLASS
orSTANDARD_CLASS
FacilitySet
- to request recommendation for offers with specific facilities that goes beyond a simple right of travel such asSEATING
,RECLINING_SEAT
,SLEEPER
orCOUCHETTE
In addition to specific attributes provided in categorySpec
, it is also possible to specify wildcard values for most of the attributes such as ANY
for fareClasses
or ANY_FACILITY_SET
for facilitySet
.
This allows for combining recommendations that point to offers that have a specific attribute, but also recommend the cheapest options when not taking the attribute into consideration.
Typically useful for grouping offers for e.g. sleeper and non-sleeper, but still recommending the cheapest option within each grouping.
If any of facilitySet
, fareClass
or durationType
is not specified, it will implicitly act as a wild card and the recommendation will include all offers that fit the other specified attributes.
typesOfRecommendation
always has to contain at least one value.
Detailed examples
Below follows some detailed examples showing the result of applying a subset of the available grouping attributes.
All examples below show examples of classification of the following example Offers
Id | Price | Flexibility | DurationType | FacilitySet |
---|---|---|---|---|
NonFlexibleSeating | 10 | NON_FLEXIBLE | SINGLE_TRIP | SEATING |
NonFlexibleCouchette | 20 | NON_FLEXIBLE | SINGLE_TRIP | COUCHETTE |
SemiFlexibleSeating | 30 | SEMI_FLEXIBLE | SINGLE_TRIP | SEATING |
SemiFlexibleSleeper | 40 | SEMI_FLEXIBLE | SINGLE_TRIP | SLEEPER |
FlexibleCouchette | 50 | FLEXIBLE | SINGLE_TRIP | COUCHETTE |
FlexibleSleeper | 60 | FLEXIBLE | SINGLE_TRIP | SLEEPER |
WeekPass | 70 | NON_FLEXIBLE | WEEKLY_PASS | _ |
MonthPass | 80 | NON_FLEXIBLE | MONTHLY_PASS | _ |
Cheapest overall
- typeOfRecommendation: CHEAPEST
Offer recommended | typeOfRecommendation |
---|---|
NonFlexibleSeating | CHEAPEST |
Cheapest across flexibility
- typesOfRecommendation: CHEAPEST, NON_FLEXIBLE, SEMI_FLEXIBLE, FLEXIBLE
Offer recommended | typeOfRecommendation |
---|---|
NonFlexibleSeating | CHEAPEST |
NonFlexibleSeating | NON_FLEXIBLE |
SemiFlexibleSeating | SEMI_FLEXIBLE |
FlexibleCouchette | FLEXIBLE |
Cheapest across FacilitySets
- typesOfRecommendation: CHEAPEST
- facilitySet: ANY_FACILITY_SET, SEATING, COUCHETTE, SLEEPER
Offer recommended | typeOfRecommendation | FacilitySet |
---|---|---|
NonFlexibleSeating | CHEAPEST | ANY_FACILITY_SET |
NonFlexibleSeating | CHEAPEST | SEATING |
NonFlexibleCouchette | CHEAPEST | COUCHETTE |
SemiFlexibleSleeper | CHEAPEST | SLEEPER |
Cheapest across FacilitySets and flexibility
- typesOfRecommendation: CHEAPEST, NON_FLEXIBLE, SEMI_FLEXIBLE, FLEXIBLE
- facilitySet: ANY_FACILITY_SET, SEATING, COUCHETTE, SLEEPER
Offer recommended | typeOfRecommendation | FacilitySet |
---|---|---|
NonFlexibleSeating | CHEAPEST | ANY_FACILITY_SET |
NonFlexibleSeating | CHEAPEST | SEATING |
NonFlexibleCouchette | CHEAPEST | COUCHETTE |
SemiFlexibleSleeper | CHEAPEST | SLEEPER |
NonFlexibleSeating | NON_FLEXIBLE | ANY_FACILITY_SET |
NonFlexibleSeating | NON_FLEXIBLE | SEATING |
NonFlexibleCouchette | NON_FLEXIBLE | COUCHETTE |
SemiFlexibleSeating | SEMI_FLEXIBLE | ANY_FACILITY_SET |
SemiFlexibleSeating | SEMI_FLEXIBLE | SEATING |
SemiFlexibleSleeper | SEMI_FLEXIBLE | SLEEPER |
FlexibleCouchette | FLEXIBLE | ANY_FACILITY_SET |
FlexibleCouchette | FLEXIBLE | COUCHETTE |
FlexibleSleeper | FLEXIBLE | SLEEPER |
Note that the combinations of NON_FLEXIBLE + SLEEPER, SEMI_FLEXIBLE + COUCHETTE and FLEXIBLE + SEATING are not recommended due to no available offers in those combinations of attributes
Cheapest across durationType
- typesOfRecommendation: CHEAPEST
- durationType: SINGLE_TRIP, WEEKLY_PASS, MONTHLY_PASS
Offer recommended | Flexibility | DurationType |
---|---|---|
NonFlexibleSeating | CHEAPEST | SINGLE_TRIP |
WeekPass | CHEAPEST | WEEKLY_PASS |
MonthPass | CHEAPEST | MONTHLY_PASS |
Algorithm configuration
For more control over how the recommendations are calculated, you can specify rules in the ruleSpec
part of the recommendationConfig
:
journeyOrganizeAlgorithm
- how the recommendations are created for parts of a composite journey, where a leg is identified by a service journey id. The available options are (with an example journey of 3 legs; SJ1, SJ2 and SJ3):SUBSEQUENT_COMBINATIONS
- all possible subsequent combinations of legs, i.e. recommendations for SJ1, SJ2, SJ3, SJ1+SJ2, SJ2+SJ3 and SJ1+SJ2+SJ3COMBINATIONS_FROM_OFFERS
- all unique journey combinations covered by offers in the responseFOR_EACH_AND_GROUPED_COMBINATIONS
- one for each individual part of the journey in addition to the entire trip, i.e. recommendations for SJ1, SJ2, SJ3 and SJ1+SJ2+SJ3
priceComparisonAlgorithm
- how the price of the offers are compared when picking offers to buy for a recommendation. The default isTOTAL_PRICE
which compares the actual price for the offer. The other option isBEFORE_SDR
which compares the price of the offer before a discount to the product is applied.BEFORE_SDR
can be useful if the traveller has an entitlement that gives them offers with greatly reduced prices, but the original price matter in terms of later taxation, or other considerations.onlyIncludeRecommendedOffers
- if set totrue
, only offers that are recommended will be included in the response. The default isfalse
.onlyIncludeRecommendationsWithOffersToBuy
- if set totrue
, only recommendations which actually points to offers to buy will be included in the response. Often it does not exist offers such that every criterion in the requested recommendation config can point to an offer to buy, so this can be used to filter out recommendations that can be considered void. The default istrue
.mixinOffersWithHigherFlexibility
- if set totrue
, offers with higher flexibility will be included in the response. F.ex. if FLEXIBLE recommendations are requested and there exists a FLEXIBLE offer that is cheaper than a NON_FLEXIBLE offer, with this parameter set totrue
the FLEXIBLE offer will be recommended in the recommendation with category NON_FLEXIBLE. The default istrue
.
Recommendation response
The Recommendation
object in the response from Offers contains the categories the recommendation is given fore, which matches the categorySpec
in the request.
In addition, it contains geographicalValidityCovered
- the geographical area the recommended offers are valid for.
This can be specific service journeys, validity between two stop places or zonal validity.
Which fields are present depends on the search endpoint used to get the recommendations and the products offered.
offersToBuy
lists the ids of the offers that needs to be reserved in the Sales API to cover the travellers in the recommendation.
selectableProductIds
might be populated and refer to selectable ids of optional products (found in the response entity under the field optionalProducts
)
that has to be reserved in combination with the offer to achieve the fare class of the recommendation, f.ex. premium where the optional product is a premium upgrade.
Selectable ids are parts of the request to the Sales API.
TravellerMapping
The possibleTravellerIds
field lists the ids of the travellers that are valid for each offer recommended. Note that each offer may have restrictions on how many travellers can be assigned to each offer,
described by its travellerMapping
. Each offer may be used by minNumberOfTravellers
and maxNumberOfTravellers
per userType
. Note the difference between the last two examples.
possibleTravellerIds | min/maxNumberOfTravellers | offerConfigurations |
---|---|---|
A | 1 | [{ "selectedTravellerIds": ["A"], ... }] |
A, B | 1 | [{ "selectedTravellerIds": ["A"], ...},{ "selectedTravellerIds": ["B"], ...}] |
A, B | 2 | [{ "selectedTravellerIds": ["A", "B"], ...}] |
A, B, C, D | 2 | [{ "selectedTravellerIds": ["A", "B"], ...}, { "selectedTravellerIds": ["C", "D"], ...}] or [{ "selectedTravellerIds": ["A", "C"], ...}, { "selectedTravellerIds": ["B", "D"], ...}] or [{ "selectedTravellerIds": ["A", "D"], ...}, { "selectedTravellerIds": ["B", "C"], ...}] |
A, B, C, D | 1 userType ADULT, travellerIds: [A, B] 1 userType CHILD, travellerIds: [C, D] | [{ "selectedTravellerIds": ["A", "C"], ...}, { "selectedTravellerIds": ["B", "D"], ...}] or [{ "selectedTravellerIds": ["A", "D"], ...}, { "selectedTravellerIds": ["B", "C"], ...}] |