Getting Offers
Once you have a Journey
you can get availability and prices for it using the getJourneyOffer
query (or subscription). The query takes a number of arguments, but the most important ones are journey
and passengers
. The journey
is the ID of the Journey
you want to get an offer for. The passengers
argument is also required, and specifies all passengers in the travelling party.
The number of passengers that can be included varies with carrier but up to five passengers works with all train carriers.
Prefer WebSocket
A JourneyOffer
may take a long time to produce depending on cache freshness and the train carrier. The All Aboard API is highly performant and has a minimal effect on the loading times. Some train carriers simply respond faster than others. It's recommended to get prices over WebSocket rather than HTTPS to avoid request timeouts. Even better — use the subscription
to get streamed results as offer data progressively flow in.
Example: Getting a journey offer
graphql
subscription GetJourneyOffer {
getJourneyOffer(
journey: "faf3647d-c33c-4756-95a9-f8639a99ebe7"
passengers: [{ type: ADULT }]
) {
id
status
itinerary {
__typename
... on SegmentCollection {
status
segments {
departureAt
origin {
name
countryCode
}
}
offers {
price {
amount
currency
}
parts {
... on AdmissionPart {
conditions {
description
type
}
flexibility
serviceClass
comfortClass
}
... on ReservationPart {
conditions {
description
type
}
flexibility
comfortClass
accommodation {
type
}
}
}
}
}
... on Stopover {
location {
name
countryCode
}
}
}
}
}
subscription GetJourneyOffer {
getJourneyOffer(
journey: "414dd478-2e3d-4631-b113-acd10b84c3bb"
passengers: [{ type: ADULT }]
) {
id
status
itinerary {
__typename
... on SegmentCollection {
status
segments {
departureAt
origin {
name
countryCode
}
}
offers {
price {
amount
currency
}
parts {
... on AdmissionPart {
conditions {
description
type
}
flexibility
serviceClass
comfortClass
}
... on ReservationPart {
conditions {
description
type
}
flexibility
comfortClass
accommodation {
type
}
}
}
}
}
... on Stopover {
location {
name
countryCode
}
}
}
}
}
Passenger data requirements
For PassengerPlaceholderInput
, provide either birthDate
or age
. For YOUTH
and SENIOR
, one of these is required; for ADULT
it is optional.
Offer availability
Getting a Journey
search result does not guarantee that any offers are available or that offers that are available will match the provided journey exactly. The resulting offer may have slight variations in terms of trains and timings, but the overall itinerary is preserved, safe change times are secured, and comfort is guaranteed.
Selecting a Journey
Since getJourneys
returns all possible journeys departing on the given day, it is up to you to select the journey you want to get an offer for. Which journey to use is up to you. If you are building a user‑facing service you may leave it up to the user to pick the journey, but you might want to promote the option that best suits your use case. In that case there are a few ways of doing so.
Fetching offers responsibly
Use of the All Aboard API is based on an agreement of fair use. We trust you to use the API responsibly and only fetch offers you are reasonably confident are of interest. If you have any questions, please reach out to us at tech@allaboard.eu
By Journey Type
The journey type
can provide a hint of which journey is more probably a good option. If you know what journey type you prefer, you can filter the results by that type.
NonStopJourney
is the fastest journey, but it can also be quite uncomfortable with excessive changes to save time, long change times, or overnight trains without sleeping accommodations.SmartJourney
is the most comfortable journey, with overnight stops in select locations and a good balance between travel time and change times.BlueprintJourney
is a journey based on aBlueprint
which allows for complete control over departure times and stopovers. Read more in the Blueprints section.
By Rating
In composing efficient and comfortable journeys, the routing engine employs, among many other things, a rating system. The rating system is based on a number of factors, such as travel time, change times, comfort, and more. The rating is a number between 0
and 1
, where 1
is the best possible rating. You can query this rating system directly with a set of journeys for which you want to get the relative comparative ratings. The getJourneyRatings
query takes a list of Journey
ids and returns a list of ratings in the same order as the input list.
Example: Getting journey ratings
graphql
query GetJourneyRatings {
getJourneyRatings(
journeys: [
"3fae713d-3a41-4c17-9bdc-fb9f8d1bdb25"
"db1242cc-79e6-40b4-ac82-22675a9e839d"
"4e307be5-51d0-49c2-8446-f6886f358574"
]
)
}
query GetJourneyRatings {
getJourneyRatings(
journeys: [
"a085d1e4-ae90-47a8-b001-82045ae011bd"
"ba585f58-1671-433a-a31f-e92b3d572f50"
"d4e8c7c5-192b-4b87-a268-2bf86398a25e"
]
)
}