Getting Prices

Once you have a Journey you can get availability and pricess 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 that of the travelling party.

The number of passengers that can be included varies with carreir 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: "0b0423c8-337c-4111-a31c-c55fa357b3c2"
    passengers: [{ type: ADULT }]
  ) {
    id
    status
    itinerary {
      __typename
      ... on SegmentCollection {
        status
        segments {
          departureAt
          origin {
            name
            countryCode
          }
        }
        fares {
          name
          price {
            amount
            currency
          }
        }
      }
      ... on Stopover {
        location {
          name
          countryCode
        }
      }
    }
  }
}
subscription GetJourneyOffer {
  getJourneyOffer(
    journey: "1b0aa71f-912b-4b80-86c9-041543be730a"
    passengers: [{ type: ADULT }]
  ) {
    id
    status
    itinerary {
      __typename
      ... on SegmentCollection {
        status
        segments {
          departureAt
          origin {
            name
            countryCode
          }
        }
        fares {
          name
          price {
            amount
            currency
          }
        }
      }
      ... on Stopover {
        location {
          name
          countryCode
        }
      }
    }
  }
}

Availability

Getting a Journey search result does not guarantee availability or that offers that are available will match with 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 secured and comfort is guaranteed.

Selecting a Journey

Since getJourneys return 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. Read more about JourneyTypes for more information. If you know what journey type you prefer, you can filter the results by that type.

  • NonStopJourney is the fastest journeys, but can be also quite uncomfortable with excessive changes to save time, long change times or overnight trains without sleeping accomodations.
  • 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 a Blueprint 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 that you want to get the the relative comparative ratings for. 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: [
      "cf8b1647-dc7b-4fd3-b8af-c0b2495f09b4"
      "c550f34a-4295-479c-b8ae-169aacdbea6a"
      "8f099fd9-2b9c-4ff5-88d7-54d5d1fd6d66"
    ]
  )
}
query GetJourneyRatings {
  getJourneyRatings(
    journeys: [
      "eb77b0fb-b47c-4eb7-bf9c-db8b44696337"
      "52b0e4cd-3f55-4d9a-b5e5-5c70b5bf0412"
      "9a4529b7-ad09-47df-9b4d-c7279437a426"
    ]
  )
}