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: "9ea71d7f-1248-4ff3-875f-5d5649e36291"
    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: "2f5cf589-6598-40c6-9c24-9829a97278e2"
    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: [
      "bad44d52-bdda-47cd-928e-981db24b2e18"
      "3ecc03fa-0969-49d3-b464-f2fc2c5c7868"
      "7ec3770d-b496-427f-bbd6-5389754497a6"
    ]
  )
}
query GetJourneyRatings {
  getJourneyRatings(
    journeys: [
      "18c74963-8b53-4a21-bf19-6be7df32cad5"
      "b097dad0-87a6-4a44-9c53-0842f9ba6500"
      "a4721fae-474e-444a-926f-88ee91331798"
    ]
  )
}