Trainline Scraper avatar

Trainline Scraper

Pricing

from $3.00 / 1,000 results

Go to Apify Store
Trainline Scraper

Trainline Scraper

Scrape Trainline - the UK & Europe rail/bus metasearch. Journey search (origin → destination → date/time) with departure/arrival times, duration, changes, operator and fares; station autocomplete lookup; and popular routes with 'from' prices.

Pricing

from $3.00 / 1,000 results

Rating

0.0

(0)

Developer

Crawler Bros

Crawler Bros

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

1

Monthly active users

12 days ago

Last modified

Share

Scrape Trainline — Europe's leading rail & bus ticket metasearch (UK, France, Germany, Italy, Spain and 40+ countries). Search train journeys between stations or cities, look up stations with codes and coordinates, and pull Trainline's own popular routes with "from" prices. Browser-based (Playwright) for the journey search flow, with public JSON endpoints for station lookup and popular routes. No login, no cookies required.

What this actor does

  • Three modes: search (journeys), stationLookup (station autocomplete), popularRoutes (curated route list)
  • Journey search: origin → destination → date → time, with departure/arrival times, duration, changes, operator, price and currency
  • Reliable fallback: when the live fare engine blocks automated access, the actor automatically emits the server-rendered route summary (first/last train, average & fastest journey time, frequency, distance, price-from, operators) instead of failing
  • Station autocomplete: names, station IDs, coordinates, countries, timezones and available connections
  • Filters: depart-after / arrive-by times, ticket type (Standard / First / Season), max price
  • Locales & currencies: 18 site locales and 24 ISO 4217 currencies
  • Empty fields are omitted

Data Source

Trainline (www.thetrainline.com). Station lookup and popular routes come from Trainline's public JSON endpoints. Journey search runs the browser-based results flow.

Limitations

  • Trainline's live fare engine (/api/journey-search/) is protected by DataDome bot detection. From some datacenter IPs it returns a CAPTCHA challenge and no journeys. When this happens, search mode automatically falls back to the server-rendered route-summary page, which is reliably accessible and still yields real data (first/last train, fastest & average journey time, trains per day, distance, price-from, operators). The summary fetch retries with backoff on transient 429/500s before giving up. To increase the chance of full per-journey fares (price per train, exact times), enable the optional Apify proxy — it is engaged automatically only when a block is detected (no extra cost on direct traffic).
  • The fallback record is marked recordType: "journeySummary"; full per-journey records are recordType: "journey".
  • Season-ticket filtering (ticketType: "Season") only keeps journeys whose fare class is explicitly detected as seasonal — Trainline rarely exposes it per journey, so this filter may legitimately yield zero records.
  • Trainline requires a valid future travel date; past dates are clamped to today + 7 days.
  • Origin and destination resolving to the same station return 0 records (Trainline serves no data for identical stations) with a clear status message.
  • The train-times summary pages are locale-independent — the locale input affects the station autocomplete and results page, not the summary URL (localized prefixes return 404).

Output

Per journey (recordType: "journey")

  • origin, destination — resolved station names
  • departureTime, arrivalTimeHH:MM
  • departureDateYYYY-MM-DD
  • durationMinutes, changes
  • operator — e.g. Avanti West Coast
  • price, currency — ISO 4217 (GBP, EUR, …)
  • trainId, ticketType, fareClass
  • sourceUrl, scrapedAt, recordType

Per journey summary (recordType: "journeySummary")

  • fromStation, toStation, fromSlug, toSlug
  • firstTrain, lastTrain — first/last departure times of the day
  • fastestJourneyMinutes, averageJourneyMinutes
  • frequencyPerDay, distanceMiles, distanceKm
  • directTrainsOnly, priceFrom, currency
  • operators[]
  • sourceUrl, scrapedAt, recordType

Per station (recordType: "station")

  • stationId, stationUrn, name, shortName (e.g. EUS), countryCode
  • latitude, longitude, locationType, timezone, defaultLanguage
  • parentName, subtitle, attributes[], connections[], matchScore
  • sourceUrl — UK stations link to their /stations/<slug> page; other stations link to the public locations-search endpoint that produced them
  • originName, destinationName, priceFrom, currency
  • durationMinutes, trainTimesPath, trainTimesUrl, isReverse
  • sourceUrl, scrapedAt, recordType

Input

FieldTypeDefaultDescription
modestringsearchsearch / stationLookup / popularRoutes
originStationstringLondon EustonDeparture station or city (mode=search)
destinationStationstringBirmingham New StreetArrival station or city (mode=search)
stationQuerystringStation name to look up (mode=stationLookup)
travelDatedatetoday + 7 daysJourney date YYYY-MM-DD (mode=search)
departAfterstringOnly journeys departing at/after HH:MM
arriveBystringOnly journeys arriving at/before HH:MM
ticketTypestringStandard / First / Season
maxPriceintDrop records priced above this
localestringen-gbSite locale (18 options)
currencystringGBPISO 4217 currency code (24 options)
maxItemsint50Hard cap (1–200)
proxyConfigurationobjectoffOptional Apify proxy, engaged automatically on block
{
"mode": "search",
"originStation": "London Euston",
"destinationStation": "Birmingham New Street",
"travelDate": "2026-09-10",
"departAfter": "07:00",
"maxItems": 20
}

Example: depart-after with filters

{
"mode": "search",
"originStation": "Manchester Piccadilly",
"destinationStation": "London Euston",
"departAfter": "08:30",
"arriveBy": "13:00",
"ticketType": "Standard",
"maxPrice": 60,
"currency": "GBP"
}

Example: station lookup

{
"mode": "stationLookup",
"stationQuery": "Birmingham"
}
{
"mode": "popularRoutes"
}

Use cases

  • Rail price monitoring — track "from" prices on popular UK/EU corridors
  • Journey planning data — first/last trains, frequencies and durations for route research
  • Station reference data — code, coordinates and connection lookups
  • Competitive intelligence — corridor-level pricing intelligence for transport startups
  • Content enrichment — route-level facts (distance, average time, operators) for travel sites

FAQ

What is the data source? Trainline (www.thetrainline.com), a UK/EU train & bus fare metasearch platform. This actor is a third-party tool and is not affiliated with or endorsed by Trainline.

Why did I get journeySummary records instead of journey records? Trainline's fare engine is protected by DataDome bot detection. When it challenges automated traffic, the actor automatically emits the route-summary record (server-rendered, always accessible) so you still get real data. Enable the optional proxy for a better chance at full per-journey fares.

Do I need an account or cookies? No. Everything this actor reads is public.

Are past dates allowed? No — Trainline only serves current/future journeys. Past dates are clamped to today + 7 days.

What currencies can I get? Prices are returned in the currency you select (24 ISO 4217 codes available). The currency field on every record is an ISO 4217 code.

Why are some fields missing? Empty fields are omitted by design. For example, not every journey card shows a trainId, and not every route page lists a priceFrom.

Is this free to run? The actor uses the free Playwright base image. The optional proxy is only used when a block is detected, so most runs cost nothing extra.

How fresh is the data? Live. Journey and route pages are fetched at run time.