Getting Offers

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: "ded4fc64-7fbd-4307-b955-701e4ca41113"
    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: "4bb66d25-79b1-441a-9747-e4103f087368"
    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
        }
      }
    }
  }
}

Offer availability

Getting a Journey search result does not guarantee that any offers are available 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. 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: [
      "ad6fe7b3-a877-464c-902a-9e0c4e93e7fb"
      "cd0ae795-203e-461f-9749-ce55fec84d66"
      "0a419d7d-1a08-444a-8d15-b5514bc12fe7"
    ]
  )
}
query GetJourneyRatings {
  getJourneyRatings(
    journeys: [
      "8e558565-bfbd-4217-b7e3-3a5e0aa63d13"
      "4800282f-55bd-4d42-aba9-0791df4543b1"
      "7793ebe7-eaa9-44e3-b5e0-882849404de6"
    ]
  )
}