Finding Journeys
Locations
Before querying for journeys and fares you will need to get the origin and destination locations for the journey. You can either fetch and store all of them on your side or search by name.
Example: Get the London location
graphql
query FindLocations {
getLocations(query: "london") {
uid
name
countryCode
coordinates {
type
coordinates
}
}
}
query FindLocations {
getLocations(query: "london") {
uid
name
countryCode
coordinates {
type
coordinates
}
}
}
Getting the full list of locations
To get the full list of station for you to save and process, please reach out to us at tech@allaboard.eu.
Types of Journeys
With cross border train journeys often involving several trains and train carriers, there's usually a few different routes available. These can vary in duration, accomodations (e.g. day or night trains) and where to change trains. The All Aboard Routing Engine employs several algorithms for addressing the many different requirements and possible connections. The routing engine produce routes with different characteristics and you can choose which one to query for.
There are three journey types produced by the routing engine. The journey search will always try and produce a sensible number of alternatives depending on the request.
- For shorter journeys, a
NonStopJourney
route with few or no changes will often suffice. - Longer journeys may require an overnight stopover. The
SmartJourney
route will automatically split up the trip in comfortable travel days with layovers in select locations. - For situations where you want complete control over departure times and stopovers, there's the
BlueprintJourney
. Read more in the Blueprints section.
Finding Journeys
To find journeys between two locations, use the getJourneys
query (or subscription). The query takes a number of arguments, but the most important ones are origin
and destination
. These are the locations you want to find journeys between. The date
argument is also required, and specifies the date of departure. The getJourneys
query will return all possible journeys departing on the given day.
Routing built in
It's always best to search for the complete journey from origin to destination, and not try and split and piece together a journey of your own. You will most likely reinvent the wheel and end up with a less than optimal journey.
Example: London to Rome
graphql
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
Filter by Journey Type
It is possible to filter the results to specific journey types, e.g. only SmartJourney
. By supplying the filter
argument one can specify which types to include. The argument takes a list of JourneyType
values.
Example: SmartJourneys
from London to Rome
graphql
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
filter: { type: [SMART] }
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
filter: { type: [SMART] }
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
Searching Via Locations
You can influence the search algorithm to a certain degree by suppling a via
argument when searching for journeys. This is useful when you want the journey to include one or more specific locations, optionally spending a given duration
of time at the location(s).
Providing no duration means a simple change of trains. Providing duration in the hours or minutes means a longer stopover to change trains. Providing duration in days means an overnight stopover.
Example: London to Rome, spending 2 nights in Zürich
graphql
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
via: [{ uid: "ObB7ATsZ", duration: "P2D" }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-05-06"
via: [{ uid: "ObB7ATsZ", duration: "P2D" }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifiers
}
}
}
}
}
Journey Status
When routing a journey or looking up availability and prices from our ticketing providers there can be a several reason for why we don't get the expected result. It can be because of a temporary outage, or because the requested journey is not available.
A Journey
can be composed of several SegmentCollections
, some of which may complete successfully while others may fail. The Journey
type has a status
field which indicate wether the journey is loading or wether all it's segments were successful or not.
What's an error?
If a Journey
has a ERROR
status it does not neccesarily mean that the request has failed or that bad arguments were provided. It just means that one or more of the segments failed and you might be able to get a successful journey by trying again.
Each SegmentCollection
also has a status
field which indicate wether the segment collection is loading or if it was successful or not. This can be used to determine which segments failed and why.
json
{
"__typename": "JourneyOffer",
"status": "ERROR",
"itinerary": [
{
"__typename": "SegmentCollection",
"status": "SUCCESS",
},
{
"__typename": "SegmentCollection",
"status": "NO_FARES"
}
]
}
{
"__typename": "JourneyOffer",
"status": "ERROR",
"itinerary": [
{
"__typename": "SegmentCollection",
"status": "SUCCESS",
},
{
"__typename": "SegmentCollection",
"status": "NO_FARES"
}
]
}