Please make sure you read the Conventions before continuing with this guide.
Requirements.
You will need an X-API-KEY.
Finding trips
You will interact with the /inventory-trips/trips endpoint of the Inventory Bucket to find a trip given some parameters.
| Parameter | Type | Example |
|---|---|---|
| departureDate | Date formatted as yyyy-mm-dd | 2017-10-28 |
| returnDate | Date formatted as yyyy-mm-dd if provided the results will include return trips | 2017-10-28 |
| fareIds | Array | 5910cfbafa1b904d0c000013:1,5910cfbafa1b904d0c000012:1 |
| destinationId | String | 5910cfbafa1b904d0c000015 |
| originId | String | 5910cfbafa1b904d0c000014 |
| providersId | String | 5910cfbafa1b904d0c000017 |
| productId | String | 5910cfbafa1b904d0c000016 |
| ignoreCutoffs | Boolean. Indicates if cutoffs should be ignored. | true |
| roundtripChangeset | Boolean. (DEPRECATED) Indicates if the search is for a roundtrip change. | false |
| changeTicketId | String. (Only for roundtrip) The id of the roundtrip return ticket that is being changed. | 5910cfbafa1b904d0c000021 |
| ignoreFilterEarlierReturnTrips | Boolean. Indicates if the search should ignore the filter for earlier return trips. | false |
| minDeparturePrice | Number. The minimum price of the departure that is going to be changed. | 10.00 |
| minReturnPrice | Number. The minimum price of the return that is going to be changed. | 10.00 |
| currency | String. The desired currency in which to perform the trip search (ISO 4217). | USD |
| pathfinder | String. The internal pathfinder system to use. For debugging use only. | |
| showSoldOutTrips | Boolean. Indicates if it should return sold out trips in the response. | false |
| isChange | Boolean. Indicates if the trip results are being used for a ticket change. | false |
| includeMoveToTrips | Boolean. Return trip results where associated manifest is in "published" or "paused" state. | false |
| isMove | Boolean. Return all the trips, including the dispatched trips. | false |
| allowedManifestStatuses | String. A comma-separated list of manifest statuses. | published,paused |
| ignorePerFareCapacityLimits | Boolean. If set to true, the capacity limits configured for each fare will be ignored. | false |
| replaceFaresOnLowAvailability* | Boolean. If set to true, when the requested fare(s) are unavailable but the base fare is available, the trip search will still return the trip. | false |
Notice the fareIds is not only an array of fareIds, but they include the number of passengers for that fare Id as well.
The fareId and the qty are separated by a colon :.
The originId and destinationId parameters are station ids.
The response will contain zero or more departure and return Trips. For each Trip, pricing information can be found in the fares property, or the fareClasses property if you performed a search for a product that has Fare Classes configured.
* Replacement fares
When replaceFaresOnLowAvailability=true is sent and one or more of the requested fares are unavailable (e.g. sold out or past their per-fare capacity limits) but the product's base fare is available, the trip is still returned. The unavailable fares are "replaced" by the base fare so the trip remains bookable — the caller is responsible for detecting the replacement and using the replacement fare's data downstream.
How to detect a replacement
On each trip, inspect every entry in the fares array (or fares inside fareClasses if Journey Pricing is being used) :
- If
replacementFareIdisnullandamountReplacedis0, the fare was not replaced — treat it as a normal fare. - If
replacementFareIdis set, that fare was replaced. The value ofreplacementFareIdmatches theidfield of an entry in the trip'sreplacementFaresarray — look it up there to get the replacement fare's pricing and metadata. amountReplacedis the number of passengers of that fare that were swapped to the replacement fare.
Example
Request asked for 1 Adult and 1 Senior. Senior is unavailable but Adult (base) is, so the trip is returned with the Senior replaced by Adult. Trimmed response:
{
"fares": [
{
"id": "60b94ceb1516d01a41ccbbc4",
"name": "Adult",
"value": 5000000,
"valueToDisplay": "50.00",
"replacementFareId": null,
"amountReplaced": 0,
"cancellable": true,
"changeable": false
},
{
"id": "610aebf7476dc22c1f2d0fee",
"name": "Senior",
"value": 4250000,
"valueToDisplay": "42.50",
"replacementFareId": "60b94ceb1516d01a41ccbbc4",
"amountReplaced": 1,
"cancellable": true,
"changeable": true
}
],
"replacementFares": [
{
"id": "60b94ceb1516d01a41ccbbc4",
"name": "Adult",
"value": 5000000,
"valueToDisplay": "50.00",
"cancellable": true,
"changeable": false
}
]
}
In this response:
- The
Adultentry infaresis a normal fare (replacementFareId: null,amountReplaced: 0). - The
Seniorentry infareswas replaced:replacementFareId: "60b94ceb1516d01a41ccbbc4"points to theAdultentry inreplacementFares, andamountReplaced: 1means 1 Senior passenger was swapped.
How to use the replacement
Once a replacement is detected, treat the matched replacementFares entry as the effective fare for the replaced passengers. It carries normal fare data (value, valueToDisplay, displayCurrencyValue, cancellable, changeable, lexiconKeys, etc.), so it can be used in the same places a regular fare is used:
know how many passengers of the original fare were swapped, and compute the per-passenger delta between the original fare's value and the replacement fare's value when needed (reporting, discount tracking, auditing).
Notes
- Replacement only happens when
replaceFaresOnLowAvailability=trueis sent, the requested fare is unavailable, and the product's base fare is available. Otherwise the trip is filtered out of the response as usual. - If no fares were replaced on a given trip,
replacementFareswill be empty and every entry infareswill havereplacementFareId: nullandamountReplaced: 0.