Trains

GetSupplierCountryList command

<CommandList>
<GetSupplierCountryList>
<XmlLoginId>HJHH3K9HTYHJ45T0</XmlLoginId>
<LoginId>HJHH3K9HTYHJ45T0</LoginId>
<Supplier>eurostar</Supplier>
</GetSupplierCountryList>
</CommandList>

Please see here (look for Train tab) for the list of currently available rail supplier on our live system and the supported features. We are constantly adding new rail supplier and new features on existing supplier. 

Trains Integration

Rail suppliers are supported within the flights API, with a few minor differences. To illustrate these differences, an example XML is given below for a search from London to Manchester:

Request

<CommandList>
<StartRouting>
<XmlLoginId>***</XmlLoginId>
<LoginId>***</LoginId>
<Mode>Plane</Mode>
<Origin>
      <Descriptor>LON</Descriptor>
      <Type>airportgroup</Type>
</Origin>
<Destination>
      <Descriptor>MAN</Descriptor>
      <Type>airportgroup</Type>
</Destination>
<OutwardDates>
      <DateOfSearch>20/03/2014-12:00</DateOfSearch>
</OutwardDates>
<MaxChanges>10</MaxChanges>
<MaxHops>10</MaxHops>
<SupplierList>
      <Supplier>thetrainline</Supplier>
</SupplierList>
<Timeout>300</Timeout>
<TravellerList>
      <Traveller>
      <Age>30</Age>
      </Traveller>
</TravellerList>
</StartRouting>
</CommandList>

Various location types for Origin and Destination can be used in the request as specified in the flight search API spec. As with flight search, to search cities <Type> should be set to "airportgroup" and to search airports <Type> should be set to "airportcode". The possible types are covered in the our start routing API documentation. In addition to this if a specific trainstation is to be searched then <Type> "trainstationcode" can be entered, this can be used to specify individual stations. If you wish to do this, please contact Travelfusion for more information. A radius of 1m is recommended to ensure no other stations are searched.using the specific Travelfusion train station code. A list of train stations that is supported can be requested by the ListTrainStations command documented below.

The results will be very similar to normal flight results, but the partial response sample below illustrates the main differences between flight and train results:

Response

<CommandList>
  <CheckRouting millis="4">
......
    <RouterList>
      <Router>
.........
        <RequestedLocations>
          <Origin>
            <Type>city</Type>
            <Code>LON</Code>
          </Origin>
.........
        </RequestedLocations>
        <GroupList>
          <Group>
            <OutwardList>
              <Outward>
.........
<SegmentList>
                  <Segment>
                    <Origin>
                      <Type>trainstation</Type>
                      <Code>EUS</Code>
                      <SupplierDisplayName>London Euston, Gtlon</SupplierDisplayName>
                    </Origin>
......................
                  </Segment>
                </SegmentList>
              </Outward>
            </OutwardList>
          </Group>
        </GroupList>
      </Router>
    </RouterList>
    <Summary>
      <Origin>
...........
        <StationList>
          <Station>
            <Name>London Euston, Gtlon</Name>
            <Code>EUS</Code>
            <City>
              <Name>London</Name>
              <Code>LON</Code>
            </City>
          </Station>
        </StationList>
      </Origin>
..............
    </Summary>
  </CheckRouting>
</CommandList>


Summary of differences:
  • In the RequestedLocations, the location type may be trainstation. This is in cases where a specific station is requested from the supplier, because a specific station is requested from Travelfusion or the supplier does not support a city-based searching and so individual stations must be requested. In these cases, the Descriptor will be the Travelfusion station code.
  • In the Segment, the Origin (and Destination) will normally have type trainstation. The code will be the Travelfusion station code if it is resolvable to one of our codes, if not we simply display the returned station name. The origin code of the first segment and the destination code of the last segment will always be Travelfusion station codes.
  • In the Summary, there is a new element 'StationList'. This lists the relevant stations, with their related cities and the Travelfusion code and name for the station.

List Train Stations

The ListTrainStations returns the trains stations codes as defined on Travelfusion side and the station names and coordinates for a particular rail supplier when <Supplier> element is filled. To obtain the complete Travelfusion stations codes list please omit the <Supplier> entry and add <IsTest> entry set to false. This request should not be performed more often than once per day for each supplier, and infrequently for the full station list since our list does not change that much. It should be accessed during off-peak hours wherever possible (00:00 to 07:00 UK time).

Example of obtaining supplier specific station list.

Request

<CommandList>
  <ListTrainStations>
    <XmlLoginId>***</XmlLoginId>
    <LoginId>***</LoginId>
    <Supplier>thetrainline</Supplier>
  </ListTrainStations>
</CommandList>

Reponse

<ListTrainStations millis="144">
    <LoginId>***</LoginId>
    <StationList>
        <Station Code="EU0" Name="London Euston" Country="GB" Lat="51.527862" Lon="-0.132956"/>
        <Station Code="WA2" Name="London Waterloo" Country="GB" Lat="51.501940" Lon="-0.113880"/>
        ......
        ......
    </StationList>
</ListTrainStations>

If the <Supplier> element is omitted we output a test reponse:

Request

<CommandList>
  <ListTrainStations>
    <XmlLoginId>***</XmlLoginId>
    <LoginId>***</LoginId>
  </ListTrainStations>
</CommandList>

Response

<ListTrainStations millis="0">
  <LoginId>HJHH3K9HTYHJ45T0</LoginId>
  <StationList>
    <Station Data="tfCode|Country|Lat,Lon|Name"/>
  </StationList>
</ListTrainStations>

Because the <IsTest> element is missing and not set to false it gives a short test reponse to prevent accidental queries that could waste processing time and bandwidth. Please note that in this case the returned data is "|" delimited in order to minimise response size. The test response shows the format of the data returned starting with tfCode which is the Travelfusion station code, followed by the Country of the station, it's latitude and longitude and finally its name. To get the full list the following query should be submitted:

Request

<CommandList>
  <ListTrainStations>
    <XmlLoginId>***</XmlLoginId>
    <LoginId>***</LoginId>
                <IsTest>false</IsTest>
  </ListTrainStations>
</CommandList>

Response

<ListTrainStations millis="144">
    <LoginId>***</LoginId>
    <StationList>
        <Station Data="BC0|GB|51.463326,-0.036244|Brockley, Greater London"/>
        <Station Data="BBO|AT|47.5907952,14.3583804|ARDNING"/>
        <Station Data="BC2|GB|51.520269,-3.212268|Birchgrove, Gwent"/>
        . . .
    </StationList>
</ListTrainStations>


List Countries Routes

The GetSupplierCountryList return the countries that the train supplier supports. This can also be seen as a retriction to what kind of search locations can be used. Note that although some suppliers might support a particular country they might only have a few stations searchable in that country, to get the specific stations it's best to call ListTrainStations for a closer view.

Example of obtaining specific supplier country list.

Request

<CommandList>
<GetSupplierCountryList>
<XmlLoginId>***</XmlLoginId>
<LoginId>***</LoginId>
<Supplier>eurostar</Supplier>
</GetSupplierCountryList>
</CommandList>

Response

<GetSupplierCountryList millis="2">
<LoginId>***</LoginId>
<CountryList>
<Country>
<CountryCode>BE</CountryCode>
<CountryName>Belgium</CountryName>
</Country>
<Country>
<CountryCode>FR</CountryCode>
<CountryName>France</CountryName>
</Country>
<Country>
<CountryCode>GB</CountryCode>
<CountryName>United Kingdom</CountryName>
</Country>
</CountryList>
</GetSupplierCountryList>

Discount Cards

Most trains supplier support discount cards. Although the specific discount cards and type vary between trains supplier, Travelfusion has unified the process. The discount card types should be submitted in the StartRouting request, one per traveller.

Request

<StartRouting>
   <XmlLoginId>***</XmlLoginId>
   <LoginId>***</LoginId>
   .................
   <BookingProfile>
      <CustomSupplierParameterList>         
         <CustomSupplierParameter>
            <Supplier>DB</Supplier>
            <Name>DiscountType</Name>
            <Value>BC25-1</Value>
         </CustomSupplierParameter>
        <CustomSupplierParameter>
            <Supplier>DB</Supplier>
            <Name>DiscountType</Name>
            <Value>BC50-1</Value>
         </CustomSupplierParameter>           
      </CustomSupplierParameterList>
   </BookingProfile>
</StartRouting>
Comments