Train Extensive Search

GET

Train Extensive Search

This API allows you to search trains availability and prices for a single day or date range. It's based on our Rail Instant Search technology, providing you with immediate results from our rail search cache.

This API has content from SNCF (French trains).

The content is also restricted to single-leg trips - where a single train takes you directly from the origin to the destination.

Resource URL

https://api.sandbox.amadeus.com/v1.2 /trains/extensive-search

Query Parameters


Name Values Description
apikey
(required)

API Key provided for your account, to identify you for API access. Make sure to keep this API key secret.

origin
(required)

Identifier of the rail station from which you would like to depart.

destination
(required)

Identifier of the rail station to which you would like to travel.

departure_date
(required)

The date or range of dates on which you would like to depart from the origin station to go to the destination.


Request Body

Make a request and see the response.

Make a request and see the response.

Make a request and see the response.

Working...

 

Response format - Train Extensive Search

The response is returned in JSON with the following elements:

Element Meaning Multiplicity
results Array of result objects for this search. 0..n
Result object
origin Station object with details about the origin station for this search. 1
destination Station object with details about the origin station for this search. 1
itineraries Array of itinerary objects to identify routes from the origin to the destination. 1..n
Station object
station_code ID of this rail station 1
station_name Full name of this rail station. 1
Itinerary object
trains The array of train objects that will be required to complete the given itinerary. Since the cache currently only contains direct itineraries, there will be only one object in this array. 1
Train object
departs_at The ISO 8601 date-time of the train's departure in the local time zone of the departure station, in the format YYYY-MM-DDTHH:mm. 1
departure_station The station object representing the station at which the passenger should board this train in order to complete this part of the itinerary. 1
arrives_at The ISO 8601 date-time of the train's arrival in the local time zone of the arrival station, in the format YYYY-MM-DDTHH:mm. 1
arrival_station The station object representing the station at which the passenger should disembark this train in order to complete this part of the itinerary. 1
marketing_company The name of the train company selling this train journey. This is the name you should see printed on your ticket. 1
operating_company The name of the train company operating this train journey. This is the name you should see written on the train. 1
train_number The identifying number of this train service. Usually the marketing company will only operate on train per day with this train number. 1
train_type The type of train that you may expect for this journey. For example: InterCity, Regional... 1
prices An array of price objects representing the pricing for this train journey. 1..n
Price object
service_class A standard enumeration of the type of seat, bed or service the passenger can expect. 1
booking_code A code the identifies the type of booking class being used. 1
accomodation A standard enumeration of the mode in which the passenger is accommodated. For example: SEAT, BERTH, CABIN, CARGO, UNKNOWN. 1
total_price An amount object representing the total cost of this service. 1
rate A rate object identifying type of charge being levied for this service, and the restrictions that apply. 1
Rate object
rate_code The unique identifier of this rate. 1
rate_name The name used by the company to describe this rate. 1
restrictions An enumeration of the type of restrictions associated with this rate. 1

 

Errors

If no results are found, or a message is required instead of a result, no result object will be returned. Instead, you may receive an array of error objects, accompanied by a HTTP 200 response, like this:

{
  "errors" : [ {
    "status" : 9819,
    "message" : "NOTHING FOUND FOR REQUESTED CRITERIA"
  } ]
}

In the case of a critical service error, you may receive an error object with an error 500 response of the same format.

if the input is invalid or not useful, you may receive a HTTP 400 response like this:

http://api.sandbox.amadeus.com/v1.2/trains/extensive-search?origin=ROMA&destination=MILANO&departure_date=2014-10-13&apikey= YOUR KEY HERE

Will give a HTTP 400 response as follows:

{
  "status" : 400,
  "message" : "ROMA is not a valid origin. Expected a 7 character rail station code"
}
 

Example - Extensive Train Search

Here's a simple search example. Just copy the following URLs in your browser. Don't forget to adjust the departure-date as necessary, and use your own API key.

This API allows you to search trains availability and prices for a single day or date range. It's based on our Rail Instant Search technology, providing you with immediate results from our rail search cache.

This API has content from SNCF (French trains) and Trenitalia (Italian Trains). The content is also restricted to single-leg trips - where a single train takes you directly from the origin to the destination.

The mandatory parameters are:

  • origin   8768600
  • destination   8771304

Use the Autocomplete or Nearest Relevant Rail Station to get the rail station ID you need, and the Schedule Search to find potential destinations from the origin on a given day.

For the parameter departure date, it supports a single day:

  • departure_date   2014-10-01

or a date range:

  • departure_date   2014-10-01--2014-10-13

 

The following request will return the available trains from Florence (8399003) to Rome (8308409) on 2014-10-13:

http://api.sandbox.amadeus.com/v1.2/trains/extensive-search?origin=8399003&destination=8308409&departure_date=2014-10-13&apikey= YOUR API KEY HERE

You will receive a response like this

{
	"results": [
		{
			"origin": {
				"station_id": 8306420,
				"station_name": "FIRENZE RIFREDI"
			},
			"destination": {
				"station_id": 8308409,
				"station_name": "Rome Termini"
			},
			"itineraries": [
				{
					"trains": [
						{
							"departs_at": "2014-10-13T12:20",
							"departure_station": {
								"station_id": 8306420,
								"station_name": "FIRENZE RIFREDI"
							},
							"arrives_at": "2014-10-13T15:20",
							"arrival_station": {
								"station_id": 8308409,
								"station_name": "Rome Termini"
							},
							"marketing_company": "Trenitalia",
							"operating_company": "Trenitalia",
							"train_number": "585",
							"train_type": "InterCity",
							"prices": [
								{
									"service_class": "SECOND_CLASS_RECLINING_SEATS",
									"booking_code": "TRE-IC",
									"accomodation": "SEAT",
									"total_price": {
										"amount": "9.00",
										"currency": "EUR"
									},
									"rate": {
										"rate_code": "SEC1",
										"rate_name": "Change and refund not allowed. Limited seats",
										"restrictions": "NotExchRefWithCondition"
									}
								}
							]
						}
					]
				}, {
					"trains": [
						{
							"departs_at": "2014-10-13T18:48",
							"departure_station": {
								"station_id": 8306421,
								"station_name": "Florence S. M. Novella"
							},
							"arrives_at": "2014-10-13T20:20",
							"arrival_station": {
								"station_id": 8308409,
								"station_name": "Rome Termini"
							},
							"marketing_company": "Trenitalia",
							"operating_company": "Trenitalia",
							"train_number": "9445",
							"train_type": "Freccia Argento",
							"prices": [
								{
									"service_class": "SECOND_CLASS_RECLINING_SEATS",
									"booking_code": "TRE-IC",
									"accomodation": "SEAT",
									"total_price": {
										"amount": "19.00",
										"currency": "EUR"
									},
									"rate": {
										"rate_code": "SEC1",
										"rate_name": "Change and refund not allowed. Limited seats",
										"restrictions": "NotExchRefWithCondition"
									}
								}
							]
						}
					]
				}
			]
		}
	]
}