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.
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-10-10"
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-10-10"
) {
id
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
}
}
}
}
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-10-10"
via: [{ uid: "ObB7ATsZ", duration: "P2D" }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "Sb0ISveC"
destination: "p6fERure"
date: "2024-10-10"
via: [{ uid: "ObB7ATsZ", duration: "P2D" }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
}
}
}
}
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"
}
]
}
Availability
It’s not always clear when is the best time to book a train journey. If you’re looking for tickets long into the future, tickets may not be available yet and if you’re booking on a short notice tickets might already be sold out.
The SegmentCollection
of a Journey
expose availability
which aim to eliminate the guesswork and help make train bookings an as smooth and predictable experience as possible.
Passengers required
Querying for availability required passengers to be provided.
Example: Get availability status and indicative price
graphql
query GetJourneys {
getJourneys(
origin: "6C9s-Z7A"
destination: "sJbfD64u"
date: "2024-10-10"
passengers: [{ type: ADULT }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
availability {
status
priceFrom {
amount
currency
}
}
}
}
}
}
query GetJourneys {
getJourneys(
origin: "6C9s-Z7A"
destination: "sJbfD64u"
date: "2024-10-10"
passengers: [{ type: ADULT }]
) {
status
itinerary {
... on SegmentCollection {
segments {
departureAt
identifier
}
availability {
status
priceFrom {
amount
currency
}
}
}
}
}
}