Discover/thetrainline.com API
live

thetrainline.com APIwww.thetrainline.com

Search UK train stations, find cheapest fares across date ranges, look up live journeys, and generate Trainline booking URLs via a simple REST API.

Endpoints
4
Updated
10d ago
Try it
Maximum number of results to return
Station name or partial name to search for
api.parse.bot/scraper/6ece94aa-46a7-4f0f-916f-e4855ba2a3fd/<endpoint>
Ready to send
Fill in the parameters and hit sign in to send to see live response data here.
Use it in your codegrab a free API key at signup
curl -X GET 'https://api.parse.bot/scraper/6ece94aa-46a7-4f0f-916f-e4855ba2a3fd/search_stations?limit=3&query=Manchester' \
  -H 'X-API-Key: $PARSE_API_KEY'
All endpoints · 4 totalclick to expand

Search for train stations by name. Returns matching stations with their Trainline URN codes (needed for other endpoints), coordinates, and metadata.

Input
ParamTypeDescription
limitintegerMaximum number of results to return
queryrequiredstringStation name or partial name to search for
Response
{
  "type": "object",
  "fields": {
    "query": "string — the search term used",
    "stations": "array of station objects with name, code, short_name, country_code, location_type, latitude, longitude, timezone, and optional parent_name",
    "total_results": "integer — number of stations returned"
  },
  "sample": {
    "data": {
      "query": "Manchester",
      "stations": [
        {
          "code": "urn:trainline:generic:loc:MAN2968gb",
          "name": "Manchester Piccadilly",
          "latitude": 53.4767,
          "timezone": "Europe/London",
          "longitude": -2.229,
          "short_name": "MAN",
          "parent_name": "Manchester",
          "country_code": "GB",
          "location_type": "station"
        }
      ],
      "total_results": 3
    },
    "status": "success"
  }
}

About the thetrainline.com API

The Trainline API covers 4 endpoints for working with UK rail data: search stations by name, look up journeys between two stations on a given date, find the cheapest fare per day across a 30-day window, and generate pre-filled booking URLs. The search_stations endpoint returns Trainline URN codes required as inputs to every other endpoint, making it the natural starting point for any integration.

Station Search and URN Codes

The search_stations endpoint accepts a full or partial station name and returns up to a configurable limit of matches. Each result includes the station's name, short_name, code, country_code, location_type, latitude, longitude, and timezone. The urn field from these results is the identifier you pass to origin and destination parameters in every other endpoint — without it, journey and fare lookups are not possible.

Journey Search

The search_journeys endpoint takes an origin URN, a destination URN, an optional date (ISO 8601 format), optional passengers count, currency (GBP, USD, or EUR), and a journey_type of single or return. Each journey object in the response includes depart_at, arrive_at, duration, changes, distance_km, co2_grams, a legs array, and a fares array. Note that this endpoint may be intermittently unavailable due to site protection on the source.

Cheapest Fares Calendar

The get_cheapest_fares endpoint scans a date range (defaulting to the next 30 days) and returns a daily_fares array with one price_amount and price_currency per day. A cheapest_fare object at the top level identifies the single lowest-priced day in the range — useful for flexible-date travel planning without iterating through individual journey searches.

Booking URL Generation

The get_booking_url endpoint produces a booking_url string that deep-links directly into Trainline's fare selection screen. Inputs include origin, destination, date, optional return_date, passengers, passenger_ages (comma-separated, e.g. 30,25), and journey_type. The URL is ready to hand off to a user who wants to complete the booking on Trainline's own site.

Common use cases
  • Find the cheapest day to travel between two cities using get_cheapest_fares daily_fares data
  • Build a price-alert tool that monitors a route's cheapest_fare over time and notifies users when it drops
  • Auto-complete station name inputs in a booking widget using search_stations results
  • Display journey options with changes, duration, and co2_grams to help users compare routes
  • Generate affiliate or deep-link booking URLs via get_booking_url with pre-filled passenger ages
  • Compare outbound fares across a date window to identify travel patterns for a specific route
  • Embed a rail fare calendar in a travel itinerary app using date-indexed daily_fares objects
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo1005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000250 req/min

One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.

Frequently asked questions
Does Trainline have an official public developer API?+
Trainline does not offer a public developer API. There is no documented endpoint or API key program available to third-party developers on their site.
What does `search_journeys` return beyond just prices?+
Each journey object includes depart_at, arrive_at, duration in minutes, changes count, distance_km, co2_grams, a legs array breaking down individual train segments, and a fares array with pricing options. The currency field in the request controls whether prices come back in GBP, USD, or EUR.
Is `search_journeys` always available?+
Not always. The endpoint notes it may be intermittently blocked by site protection on thetrainline.com. For fare availability across dates without per-journey detail, get_cheapest_fares is a more stable alternative.
Does the API cover rail routes outside the UK, such as European trains?+
The current endpoints are scoped to UK rail data and Trainline's UK station network. International or European cross-border routes are not currently covered. You can fork this API on Parse and revise it to add an endpoint targeting European route data.
Can I retrieve seat availability or specific carriage details for a journey?+
Not currently. The API returns fare amounts, journey duration, change counts, and leg-level data, but does not expose seat maps or carriage-level availability. You can fork the API on Parse and revise it to add an endpoint that surfaces that detail.
Page content last updated . Spec covers 4 endpoints from www.thetrainline.com.
Related APIs in TravelSee all →
opentable.ca API
Search and discover restaurants on OpenTable, view detailed information like menus and reviews, and check real-time dining availability across metro areas. Find top-rated restaurants in your location and instantly see which tables are open for your preferred date and time.
fandango.com API
Search for movies and retrieve nearby theater listings with showtimes by ZIP code and date, plus showtimes for a specific movie at nearby theaters.
data.lime.bike API
Access real-time availability data for Lime bikes and scooters, including station locations, vehicle status, system alerts, and geofencing zones across multiple cities. Monitor micromobility inventory and service information to find nearby vehicles or plan your trips effectively.
turo.com API
Search for peer-to-peer car rentals across Turo by location and dates to browse available vehicles with pricing, specifications, and real-time availability. Get detailed information on specific cars to compare features and make rental decisions.
reservation.pc.gc.ca API
Access real-time campground availability and reservation data from the Parks Canada booking system. Search locations, retrieve available campsites and cabins, filter by equipment type, and review operating date schedules across the national park network. Includes detailed resource metadata and map-based availability overviews.
bahn.com API
Search German train schedules and stations, find connections between destinations, and compare ticket prices across Deutsche Bahn routes. Get real-time station information and transit association details to plan your train journey efficiently.
united.com API
Search United Airlines flights, check real-time flight status, and view detailed seat maps to plan your perfect trip. Compare fare options and use airport autocomplete to quickly find your departure and arrival cities.
thefork.it API
Search and discover Italian restaurants by cuisine, location, or ratings, then access detailed information like menus, reviews, and availability across major cities in Italy. Find top-rated dining options and compare restaurant details to plan your perfect meal.