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: "fa0b5f64-752a-4a26-84fc-04086654f41e"
    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: "8d72b47f-5e93-4aa7-9ac7-cd7c585d117c"
    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: [
      "fa00b5e4-a453-4d37-a9a5-165c962a7102"
      "af3e6452-b3d1-44d9-abad-9186d53679e6"
      "7eb91f0b-fd4c-48f4-a997-469d7146722a"
    ]
  )
}
query GetJourneyRatings {
  getJourneyRatings(
    journeys: [
      "5cab6c11-f8d9-4f2c-a3fb-43af8fa8416c"
      "537e41cf-9ab5-4603-85e2-924edda38162"
      "2ed81178-4db7-450a-9c5c-1280ae15f9b8"
    ]
  )
}