tripcom.train.search
Find trains between two cities on Trip.com with stations, times, duration, operator and train number.
At a glance
- Endpoint ID
tripcom.train.search- Price
- 1 credit per call; failed calls are free
- Runs for up to
- 30 seconds
Request
Send the endpoint ID as capability and its fields as input. Set UPSCRAPE_API_KEY to your key first.
curl --request POST \ --url https://data.upscrape.com/execute \ --header "Authorization: Bearer $UPSCRAPE_API_KEY" \ --header "Content-Type: application/json" \ --header "Prefer: wait=30" \ --data '{ "capability": "tripcom.train.search", "input": { "country": "uk", "departure_date": "2026-11-10", "destination": "Birmingham", "max_results": 10, "origin": "London" }}'
import jsonimport osimport requestspayload = json.loads(r'''{ "capability": "tripcom.train.search", "input": { "country": "uk", "departure_date": "2026-11-10", "destination": "Birmingham", "max_results": 10, "origin": "London" }}''')response = requests.post( "https://data.upscrape.com/execute", headers={ "Authorization": f"Bearer {os.environ['UPSCRAPE_API_KEY']}", "Content-Type": "application/json", "Prefer": "wait=30", }, json=payload,)response.raise_for_status()print(json.dumps(response.json(), indent=2))
const response = await fetch("https://data.upscrape.com/execute", { method: "POST", headers: { "Authorization": `Bearer ${process.env.UPSCRAPE_API_KEY}`, "Content-Type": "application/json", "Prefer": "wait=30", }, body: JSON.stringify({ "capability": "tripcom.train.search", "input": { "country": "uk", "departure_date": "2026-11-10", "destination": "Birmingham", "max_results": 10, "origin": "London" }}),});if (!response.ok) { throw new Error(`Upscrape request failed: ${response.status}`);}console.log(JSON.stringify(await response.json(), null, 2));
Input
| Field | Type | Required | What it does | Example |
|---|---|---|---|---|
destination |
string | yes | Arrival city or station name, for example Birmingham | Birmingham |
origin |
string | yes | Departure city or station name, for example London | London |
country |
string | no | Departure-country route segment, for example uk; tried first when resolving the route page | uk |
departure_date |
string | no | Travel date in YYYY-MM-DD; defaults to the source page's current day | 2026-11-10 |
max_results |
integer | no | Maximum number of results to return. At least 0. Default: 0. |
10 |
Response
A finished call answers with HTTP 200; the data is in results[0].data, and billing.credits_charged is what it cost. A call still running after the wait answers 202: see jobs and results.
This is results[0].data from a real run:
{ "arrival_station_id": "GB0278", "departure_station_id": "GB1594", "end_page": 1, "has_more": false, "query": "London-Birmingham", "query_date": "2026-11-10", "returned": 1, "source_url": "https://www.trip.com/trains/uk/route/london-to-birmingham/", "start_page": 1, "total_trains": 1, "trains": [ { "price": 31.56, "arrival_station": "Birmingham", "arrival_time": "08:44", "currency": "USD", "departure_date": "2026-11-10", "departure_station": "London", "departure_time": "06:43", "duration": "2h 1m", "record_type": "lowest_fare", "train_number": "C17953-Y80791", "transfers": 1 } ]}
Fields
| Field | Type | Example |
|---|---|---|
arrival_station_id |
string | GB0278 |
departure_station_id |
string | GB1594 |
end_page |
integer | 1 |
has_more |
boolean | false |
query |
string | London-Birmingham |
query_date |
string | 2026-11-10 |
returned |
integer | 1 |
source_url |
string | https://www.trip.com/trains/uk/route/london-to-birmingham/ |
start_page |
integer | 1 |
total_trains |
integer | 1 |
trains |
array | 1 records |
trains[].arrival_station |
string | Birmingham |
trains[].arrival_time |
string | 08:44 |
trains[].currency |
string | USD |
trains[].departure_date |
string | 2026-11-10 |
trains[].departure_station |
string | London |
trains[].departure_time |
string | 06:43 |
trains[].duration |
string | 2h 1m |
trains[].price |
number | 31.56 |
trains[].record_type |
string | lowest_fare |
trains[].train_number |
string | C17953-Y80791 |
trains[].transfers |
integer | 1 |
If a call fails
A failed call costs nothing. The response carries an error.code you can branch on; Errors and retries lists every code and which ones to retry.
Other Trip.com Travel endpoints
Something missing or unclear? Ask the team that builds the Trip.com Travel endpoints.